Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translatable classes not working with orm lazyGhostObjects enabled #719

Open
mmarton opened this issue Jan 12, 2023 · 1 comment
Open

Translatable classes not working with orm lazyGhostObjects enabled #719

mmarton opened this issue Jan 12, 2023 · 1 comment

Comments

@mmarton
Copy link

mmarton commented Jan 12, 2023

Hi!

enable_lazy_ghost_objects: true became the default config for doctrinebundle
symfony/recipes#1140

With it turned on I got this error from any translatable entity:

Proxies\__CG__\...\Entity\PageTranslation::createLazyGhost(): Argument #1 ($initializer) must be of type Closure|array, null given

this is because by default the translation property is not initialized by default as ArrayCollection in TranslatablePropertiesTrait.

related: doctrine/orm#10376


tldr: from now, you have to have

public function __construct()
{
    $this->translations = new ArrayCollection();
}

in your translatable classes

@wyster
Copy link

wyster commented Feb 27, 2023

Not helped for me, resolved by redefine Knp\DoctrineBehaviors\Model\Translatable\TranslatableMethodsTrait::getTranslationEntityClass in entity:

public static function getTranslationEntityClass(): string
{
    return self::class.'Translation';
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants