title: Referencing Fixtures between Bundles Using Hautleook/AliceBundle
body: <p>Can anyone provide me an example about referencing a datafixture yml file between two separates bundles, using HautellokAliceBundle in Simfony 2,7. I need to reference author field in my articles bundle from FOSUserBundle. Im newbie please consider this. thanks. Information in AliceBundle docs lack this issue.</p>
  
  <p>Ok These are my Fixtures for Group and user:</p>
  
  <pre><code>MB\MBBundle\Entity\Group:
  Group1:
      __construct: ['Admins']
      __construct: ["ROLE_ADMIN"]
  Group{2..7}:
      __construct(unique): [&lt;randomGroup()&gt;]
      __construct: [&lt;randomRole()&gt;]
  
  MB\MBBundle\Entity\User:
  
  User1:
      username: admin
      email: admin@local.com
      enabled: 1
      plainPassword: admin
      roles: [ROLE_ADMIN]
      groups: ['@Group1']
  
  User{2..25}:
      username: &lt;firstName()&gt;
      email: &lt;companyEmail()&gt;
      enabled: &lt;boolean(35)&gt;
      plainPassword: &lt;lexify()&gt;
      roles: [&lt;randomRole()&gt;]
      groups: ['@Group*']
  </code></pre>
  
  <p>and this my DataFixtures loader Class for User and Group</p>
  
  <pre><code>&lt;?php
  
  namespace MB\MBBundle\DataFixtures\ORM;
  
  use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
  use Hautelook\AliceBundle\Alice\DataFixtureLoader;
  use Nelmio\Alice\Fixtures;
  
  class MBBundleFixtures extends DataFixtureLoader implements OrderedFixtureInterface
  {
  
      protected function getFixtures()
      {
          return array (
              __DIR__.'/User.yml',
          );
      }
  
      public function rolesFixturesNames ()
      {
  
          return ['ROLE_ADMIN', 'ROLE_USER', 'ROLE_DIRECTORS', 'ROLE_TECHNICIANS', 'ROLE_OPERATORS', 'ROLE_ASISTANTS', 'ROLE_AUDITORS', 'ROLE_EXTERNALS'];
      }
  
      public function randomRole()
      {
          $names = ['ROLE_ADMIN', 'ROLE_USER', 'ROLE_PROFILE_ONE', 'ROLE_PROFILE_TWO'];
  
          return $names[array_rand($names)];
      }
  
      public function randomGroup()
      {
          $names = ['Users', 'Technicians', 'Operators', 'Asistants', 'Auditors', 'Externals'];
  
          return $names[array_rand($names)];
      } 
  
      public function getOrder()
      {
           return 1;
      }
  }
  </code></pre>
  
  <p>And for entity to be referenced, data fixtures by now are like:</p>
  
  <pre><code>MB\LegalBundle\Entity\LegalTitles:
    legalTitles{1..3}:
      category: &lt;categoryTitlesNames()&gt;
      name:  &lt;text($maxNbChars = 5)&gt;  &lt;numberBetween($min = 100, $max = 999)&gt;
      validFrom: &lt;dateTimeBetween('-3 years', 'now')&gt;
      validUntil: &lt;dateTimeBetween($validFrom, '30 years')&gt;
      validFor:  &lt;numberBetween($min = 10, $max = 30)&gt;
      geopointType: &lt;geopointTypesNames()&gt;
      latitude: &lt;latitude($min = -5, $max = 15)&gt;
      longitude: &lt;longitude($min = 67, $max = 80)&gt;
      elevation: &lt;numberBetween($min = 50, $max = 4800)&gt;
      dateCreated: null
      dateModified: null
      author: 
  </code></pre>
  
  <p>The Loader Class looks like:</p>
  
  <pre><code>&lt;?php 
  namespace MB\LegalBundle\DataFixtures\ORM;
  
  use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
  use Hautelook\AliceBundle\Alice\DataFixtureLoader;
  use Nelmio\Alice\Fixtures;
  
  class LegalBundleFixtures extends DataFixtureLoader implements OrderedFixtureInterface
  {
      protected function getFixtures()
      {
          return array (
              __DIR__.'/LegalTitlesFixtures.yml',
          );
      }
  
      public function categoryTitlesNames ()
      {
          $categoryMiningTitles = array (
              'CCON', 
              'LEXP',
              'RPP',
              'CVA',
          );
          return $categoryTitles [array_rand($categoryTitles)];
      }
      public function geopointTypesNames ()
      {
          $geopointTypes = array (
              'UnderGround Access', 
              'Surface Access', 
          );
          return $geopointTypes [array_rand($geopointTypes)];
      }
  
      public function getOrder()
      {
          return 2;
      }
  }
  </code></pre>
  
  <p>As you see what I want is reference an Author from User Entity in MBBundle to legal Entity in LegalBundle. Thanks again for your help</p>