Hi,
I just updated a kirby 3 project to Kirby 4 and I get an error in a Model page where I overwrite the Page content method.
In Kirby 3, I used this syntax:
public function content( $languageCode ) { ... }
Now in Kirby 4, this line return an Exception
Content must be compatible with Kirby\Cms\ModelWithContent::content(?string $languageCode = null): Kirby\Content\Content
So I suppose there is another syntax in Kirby 4 to call the content() method in our Model ?
I tried this without success:
public function content( $languageCode ): Content { ... }
That’s the new method signature, so you would have to add the type hint for the language code, set the default and add the return type.
public function content(string|null $languageCode = null): Content
Thanks Sonja, I made the correction but get this Exception now:
“Could not check compatibility between ProposalPage::content(?string $languageCode = null): Content and Kirby\Cms\ModelWithContent::content(?string $languageCode = null): Kirby\Content\Content, because class Content is not available”
You need to either import the class or use the FQN Kirby\Content\Content
texnixe:
Kirby\Content\Content
Yep, works now! Thank you very much