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

Reference used for ternary operator #797

Closed
kermorgant opened this issue Sep 22, 2017 · 3 comments
Closed

Reference used for ternary operator #797

kermorgant opened this issue Sep 22, 2017 · 3 comments

Comments

@kermorgant
Copy link

Hello,

Sorry if this is already answered, I've looked for existing issue about my problem but with no luck.

So, I have this working (with doctrine 2.5.11 & nelmio/alice v3.0.1)

AppBundle\Entity\UserInformation: # embeddable
    legalRepresentative_{1..20}:
        firstname: <firstname()>
        lastname: <lastname()>
        email: <email()>
        nationalityCode: <countryCode()>
        countryOfResidenceCode: <countryCode()>

AppBundle\Entity\Organization:
    organization_{1..20}:
        organizationAddress: '@org_address_<current()>'
        differentLegalRepresentative: <boolean(50)>
        legalRepresentative: '@legalRepresentative_<current()>'

I would like to add a legalRepresentative to an organisation only if the flag "differentLegalRepresentative" is set. But when I change the last line to this, it fails
legalRepresentative: '@self->differentLegalRepresentative ? @legalRepresentative_<current()>'

 [Fidry\AliceDataFixtures\Exception\MaxPassReachedException]                                                                                                                                                                                  
  Loading files limit of 15 reached. Could not load the following files:                                                                                                                                                                       
  /var/www/app/Resources/fixtures/orm/organization.yml:                                                                                                                                                                                        
   - Nelmio\Alice\Throwable\Exception\Generator\Resolver\UnresolvableValueException: Could not evaluate the expression "legalRepresentative_<current(array (                                                                                   
    0 =>                                                                                                                                                                                                                                       
    Nelmio\Alice\Definition\Value\ValueForCurrentValue::__set_state(array(                                                                                                                                                                     
    )),                                                                                                                                                                                                                                        
  ))>". in /var/www/vendor/nelmio/alice/src/Throwable/Exception/Generator/Resolver/UnresolvableValueExceptionFactory.php:52  

Am doing it wrong somewhere ?

Regards
Mikael

@theofidry theofidry added the Bug label Sep 22, 2017
@theofidry
Copy link
Member

I think the problematic part may be @legalRepresentative_<current()>, try @legalRepresentative_$current or maybe @<("legalRepresentative".$current)>

In any case I think there is a bug here that should be solved

@theofidry theofidry added this to the 3.x milestone Sep 22, 2017
@kermorgant
Copy link
Author

Thanks for the reply.

I tried the two alternatives but got those results

legalRepresentative: "@self->differentLegalRepresentative ? @legalRepresentative_.$current"

Loading files limit of 15 reached. Could not load the following files:
/var/www/app/Resources/fixtures/orm/organization.yml:

  • Nelmio\Alice\Throwable\Exception\Generator\Resolver\FixtureNotFoundException: Could not find the fixture "legalRepresentative_.$current". in /var/www/vendor/nelmio/alice/src/Throwable/Exception/Generator/Resolver/FixtureNotFoundExc
    eptionFactory.php:23

legalRepresentative: "@self->differentLegalRepresentative ? @<('legalRepresentative_'.$current)>"

Loading files limit of 15 reached. Could not load the following files:
/var/www/app/Resources/fixtures/orm/organization.yml:

  • Nelmio\Alice\Throwable\Exception\Generator\Resolver\UnresolvableValueException: Could not evaluate the expression "<identity(array (
    0 =>
    Nelmio\Alice\Definition\Value\EvaluatedValue::_set_state(array(
    'expression' => ''legalRepresentative
    '.$current',
    )),
    ))>". in /var/www/vendor/nelmio/alice/src/Throwable/Exception/Generator/Resolver/UnresolvableValueExceptionFactory.php:52

@theofidry theofidry changed the title reference used for ternary operator Reference used for ternary operator Oct 20, 2017
@theofidry
Copy link
Member

I think this should work ok unfortunately it's not. So there is 3 options:

I'm not really up for the first one but I'll accept any work on it of course. Meanwhile I'll be closing this issue as the real fix is in #601 IMO.

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

No branches or pull requests

2 participants