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

Doc missing for relations-handling and faker functions #1010

Open
CocoJr opened this issue Dec 3, 2019 · 5 comments
Open

Doc missing for relations-handling and faker functions #1010

CocoJr opened this issue Dec 3, 2019 · 5 comments

Comments

@CocoJr
Copy link

CocoJr commented Dec 3, 2019

Hi,

I use your bundle and today i'm be confronted to a complicated situation with the multiple-references.

I was trying to dynamically create an user and associate dynamicly an object using the <current()> method for reference.
I follow your doc, but you never mention the impossibility tu put the <current()> at other place than the end for reference.

Exemple:

Nelmio\Entity\User:
    # ...

Nelmio\Entity\Group:
    group{1..10}:
        owner: '@user<current()test>'

If you try that, that not working. I have to put the <current()> at the end, and only at the end.

Then, i ask you if you can add documentation into https://github.com/nelmio/alice/blob/master/doc/relations-handling.md page please ?

@theofidry
Copy link
Member

The syntax is a bit confusing in this case to be honest and I'm not sure what the expected behaviour should be;

I would recommend to keep <current()> at the end if that works, otherwise might be worth trying to invest time into #998

@CocoJr
Copy link
Author

CocoJr commented Dec 3, 2019

Thx for your reply and sorry for this confusion.

Take this fixtures exemple:

Nelmio\Entity\User:
    user_{1..10}_test:
        owner: 'user_<current()>'
Nelmio\Entity\Group:
    group_{1..10}:
        owner: '@user_<current()>_test'

I expect in this case for the group_1, to have a relation to user_1_test by the owner propriety. For the group_2, a relation to user_2_test, etc...

But in this case, the bundle get only 1 to found the relation (so user_ and _test is not interpreted).

To solve this, i have to use this syntax:

Nelmio\Entity\User:
    user_{1..10}:
        owner: 'user_<current()>'
Nelmio\Entity\Group:
    group_{1..10}:
        owner: '@user_<current()>'

I think a simple comment in the doc to specify we can't use function for relation at the begin or in the middle of a string, but only at the end can be good.

@CocoJr
Copy link
Author

CocoJr commented Dec 3, 2019

Everything is explain here visibly: #377, but not in the doc.

@theofidry
Copy link
Member

Then it might just be something missing in the code and that could be fixed :) See https://github.com/nelmio/alice/blob/master/CONTRIBUTING.md#expression-language for pointers

@theofidry
Copy link
Member

Reading this again

But in this case, the bundle get only 1 to found the relation (so user_ and _test is not interpreted).

Is definitely a bug

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