コード例 #1
0
ファイル: Loader.php プロジェクト: rznzippy/AliceBundle
 /**
  * {@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;
 }
コード例 #2
0
ファイル: Loader.php プロジェクト: luchaninov/AliceBundle
 /**
  * Goes through all fixtures files to try to load them one by one and specify for each if the file could
  * successfuly be loaded or not.
  *
  * @param PersisterInterface $persister
  * @param array              $normalizedFixturesFiles Array with the file real path as key and true as a value if
  *                                                    the files has been loaded.
  * @param array              $references
  *
  * @return \object[] All objects that could have been loaded.
  */
 private function tryToLoadFiles(PersisterInterface $persister, array &$normalizedFixturesFiles, array $references)
 {
     $objects = [];
     foreach ($normalizedFixturesFiles as $fixtureFilePath => $hasBeenLoaded) {
         if (true === $hasBeenLoaded) {
             continue;
         }
         try {
             $dataSet = $this->fixturesLoader->load($fixtureFilePath, $references);
             $normalizedFixturesFiles[$fixtureFilePath] = true;
             if (false === $this->persistOnce) {
                 $this->persist($persister, $dataSet);
             }
             $objects = array_merge($objects, $dataSet);
         } catch (\UnexpectedValueException $exception) {
             $this->registerErrorMessage($fixtureFilePath, $exception->getMessage());
         }
     }
     return $objects;
 }