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

make:factory fails when there is more than one level of embedded classes #608

Open
rimas-kudelis opened this issue May 22, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@rimas-kudelis
Copy link

rimas-kudelis commented May 22, 2024

When attempting to generate a factory for a class that has a protected property of Money\Money type, I get the following error:

In LegacyORMDefaultPropertiesGuesser.php line 73:

  Property App\Entity\MyEntity::$price.currency does not exist

I'm using Foundry version 1.37.0.

@rimas-kudelis
Copy link
Author

rimas-kudelis commented May 22, 2024

This happens because $metadata->embeddedClasses contains a list that is too comprehensive (it lists not only child objects, but also deeper descendants).

A seemingly working fix is to add a simple check before the faulty line:

            if (str_contains($fieldName, '.')) {
                continue;
            }

@kbond kbond added the bug Something isn't working label May 22, 2024
@rimas-kudelis rimas-kudelis changed the title make:factory fails on a class that has a property of Money\Money from moneyphp type make:factory fails when there is more than one level of embedded classes Jun 6, 2024
@nikophil
Copy link
Member

Hi @rimas-kudelis

would you mind adding a little bit more context, please? as least, how would look the minimal entity that makes the command break.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

3 participants