Beispiel #1
0
 /**
  * Loads a fixture file into an object container
  *
  * @param string|array $file filename to load data from or data array
  * @param object       $container object container
  * @param array        $options available options:
  *                                - providers: an array of additional faker providers
  *                                - locale: the faker locale
  */
 public static function load($file, $container, array $options = array())
 {
     $defaults = array('locale' => 'en_US', 'providers' => array());
     $options = array_merge($defaults, $options);
     if (is_string($file) && preg_match('{\\.ya?ml(\\.php)?$}', $file)) {
         $loader = new Loader\Yaml($options['locale'], $options['providers']);
     } elseif (is_string($file) && preg_match('{\\.php$}', $file) || is_array($file)) {
         $loader = new Loader\Base($options['locale'], $options['providers']);
     } else {
         throw new \InvalidValueException('Unknown file/data type: ' . gettype($file) . ' (' . json_encode($file) . ')');
     }
     if ($container instanceof ObjectManager) {
         $persister = new ORM\Doctrine($container);
     } else {
         throw new \InvalidValueException('Unknown container type ' . get_class($container));
     }
     $objects = $loader->load($file);
     $persister->persist($objects);
     return $objects;
 }
Beispiel #2
0
 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     $objects = Fixtures::load(__DIR__ . '/../data/accounts/*.yml', $manager, ['locale' => 'fr_FR']);
     $persister = new FixturesORM($manager);
     $persister->persist($objects);
 }
Beispiel #3
0
 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     $objects = Fixtures::load(__DIR__ . '/../data/default/*.yml', $manager, ['providers' => [$this], 'locale' => 'fr_FR']);
     $persister = new FixturesORM($manager);
     $persister->persist($objects);
 }
 /**
  * @param EntityManager $entityManager
  */
 private function createAdminUser(EntityManager $entityManager)
 {
     $users = Fixtures::load(__DIR__ . '/../Resources/fixtures/users.yml', $entityManager);
     $persister = new Persister($entityManager);
     $persister->persist($users);
 }