phpsymfonyfakernelmio-alice

Generating Doctrine fixture data for Nested Set entity with Alice Fixtures


I'm using hautelook/AliceBundle (which uses nelmio/alice and fzaninotto/Faker) to generate fixtures for an application. I have a Doctrine entity Group which is a nested set entity (using the Tree functionality provided by StofDoctrineExtensionsBundle). What I can't figure out is how I can generate fixture data for the nested set entity - making sure that groups are generated as a tree with accurate root IDs and parents. Thanks for any guidance.

My current fixture file is as simple as;

MyBundle\Entity\Group:
  group{1..25}:
    title: <word()>

Solution

  • I've got it to work by manually defining the groups for each level of the nested set like so;

    MyBundle\Entity\Group:
      group_root{1..5}:
        title: <word()>
    
      group_level_1{1..50}:
        parent: '@group_root*'
        title: <word()>