-
-
Notifications
You must be signed in to change notification settings - Fork 331
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
how to use current() in identity() #374
Comments
Hello,
You have a piece of doc here, but I agree it could be better. However here's some examples: Nelmio\Entity\User:
user1:
username: 'testuser'
fullname: '<identity($username)>'
user2:
username: 'test_user'
fullname: '<identity(str_replace("_", " ", $username))>'
In short, Nelmio\Entity\User:
user_{1..10}: # creates 10 users "user_1", ..., "user_10"
username: '<current()>' # will be "1", ..., "10"
user_{alice, bob}: # creates two users "user_alice" and "user_bob"
username: '<current()>' # respectively "alice" and then "bob" If my memory serves me right, it throws an exception if you try to use Best, |
Hi @theofidry Thanks for your response. I know both features What I want to achieve is this (which is not working): Acme\Entity\User:
user_ {3..10}:
anything: <identity(<current()> - 2)> Is there a syntax which will give me 1..8 or is this not possible at all? |
Ah, as mentioned in #360 the correct syntax would be |
I just gave it a try but did not work:
|
Indeed, I'm not sure why I couldn't find much after a bit of debugging. I'm honestly not sure that this will be fixed in v2. In the meantime what you can do is having a provider to do the calculation: Acme\Entity\User:
user_ {3..10}:
anything: '<anything(current())>' |
Not sure if that works as |
Erf, I don't know then. I can only make sure that this will be fixed in v3 for now. If I find a fix on the way I'll make sure to include it. |
Closing in favour of #360 |
I found the documentation about identity and its use of variables in it. I also found several issues regarding using current() in identity(). Still I did not manage to get it working.
As far as I could read in the issues it has been implemented. So... Can anyone provide an example? As a bonus you could in that case directly add a PR explaining it in the docs.
The text was updated successfully, but these errors were encountered: