17

https://github.com/nelmio/alice/blob/master/README.md#multiple-references

group{1..10}:
members: @user{1..10}

this example is giving problem

Entity with Id @user_{1..2} and Class Eggs\CoreBundle\Entity\User not found

It is putting as it is. If i change it to @user_* or @user_1, this works fine, but above range is giving me problem.

Code:

user_{1..10}:
email (unique): email()

group_{1..10}:
user: @user_{1..10}
name: name of the group

user: @user_{1..10} <--- this line gives problem. (I have change business to user)

Basit
  • 16,316
  • 31
  • 93
  • 154
  • How do you create the users? – A.L May 03 '15 at 22:29
  • first I create the users fine, then i want to assign them to group. so one user would have 10 group. so total would be 100 group (10 per user) – Basit May 04 '15 at 02:22
  • Please add all your code, the error is about `@business_{1..2}` but this reference is not defined in the code of your question. – A.L May 04 '15 at 10:26
  • Hi @Basit, in the installation section the bundle suggest to use in conjunction with hautelook/alice-bundle or h4cc/alice-fixtures-bundle. Do you use any of this? Do you use any of it? – Matteo May 10 '15 at 05:38
  • Yes hautelook/alice-bundle – Basit May 10 '15 at 09:15
  • Why don't you first create the necessary 10 groups and then start creating users? Or all of the groups are per user (rather than global groups)? – tftd May 13 '15 at 19:36
  • @tftd all the groups are per user. 10 groups per user. – Basit May 13 '15 at 21:12
  • Do you have a method which accepts an `ArrayCollection` of `users` in your `Group` entity? – tftd May 13 '15 at 21:38

1 Answers1

2

It is not particularly clear from Alice fixtures' documentation, but this syntax is for when you want to pass an array of users. Does your $group->user field accept array?

If you want each group to get one user, the solution would be:

group_{1..10}:
    user: @user_<current()>
    name: name of the group
Konstantin Pereiaslov
  • 1,786
  • 1
  • 18
  • 26
  • I want to create each group for 10 users, so if there is 10 group, it will = 100 groups. group (10) x user (10) = 100, your example will create only 10 group and assign user to it by sequence. – Basit May 08 '15 at 18:26