Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function load(PersisterInterface $persister, array $fixtures)
 {
     if ($this->fixturesLoader instanceof FixturesLoader) {
         $_persister = $this->fixturesLoader->getPersister();
         $this->fixturesLoader->setPersister($persister);
     }
     if (0 === count($fixtures)) {
         return [];
     }
     $objects = [];
     foreach ($fixtures as $file) {
         $dataSet = $this->fixturesLoader->load($file);
         if (false === $this->persistOnce) {
             $this->persist($persister, $dataSet);
         }
         $objects = array_merge($objects, $dataSet);
     }
     if (true === $this->persistOnce) {
         $this->persist($persister, $objects);
     }
     if (isset($_persister)) {
         $this->fixturesLoader->setPersister($_persister);
     }
     return $objects;
 }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function load(PersisterInterface $persister, array $fixturesFiles)
 {
     if ($this->fixturesLoader instanceof FixturesLoader) {
         $_persister = $this->fixturesLoader->getPersister();
         $this->fixturesLoader->setPersister($persister);
     }
     if (0 === count($fixturesFiles)) {
         return [];
     }
     $objects = [];
     $loadFileAttempts = 0;
     $normalizedFixturesFiles = $this->normalizeFixturesFiles($fixturesFiles);
     $this->errorMessages = [];
     while (true) {
         $objects = array_merge($objects, $this->tryToLoadFiles($persister, $normalizedFixturesFiles, $objects));
         if (true === $this->areAllFixturesLoaded($normalizedFixturesFiles)) {
             break;
         }
         if ($this->loadingLimit <= $loadFileAttempts) {
             throw new LoadingLimitException($this->loadingLimit, $normalizedFixturesFiles, $this->errorMessages);
         }
         ++$loadFileAttempts;
     }
     if (true === $this->persistOnce) {
         $this->persist($persister, $objects);
     }
     if (isset($_persister)) {
         $this->fixturesLoader->setPersister($_persister);
     }
     return $objects;
 }