コード例 #1
0
 /**
  * Load the fixture jobs in database
  *
  * @return null
  */
 public function load()
 {
     $rawJobs = array();
     $fileLocator = $this->container->get('file_locator');
     foreach ($this->jobsFilePaths as $jobsFilePath) {
         $realPath = $fileLocator->locate('@' . $jobsFilePath);
         $this->reader->setFilePath($realPath);
         // read the jobs list
         while ($rawJob = $this->reader->read()) {
             $rawJobs[] = $rawJob;
         }
         // sort the jobs by order
         usort($rawJobs, function ($item1, $item2) {
             if ($item1['order'] === $item2['order']) {
                 return 0;
             }
             return $item1['order'] < $item2['order'] ? -1 : 1;
         });
     }
     // store the jobs
     foreach ($rawJobs as $rawJob) {
         unset($rawJob['order']);
         $job = $this->processor->process($rawJob);
         $config = $job->getRawConfiguration();
         $config['filePath'] = sprintf('%s/%s', $this->installerDataPath, $config['filePath']);
         $job->setRawConfiguration($config);
         $this->em->persist($job);
     }
     $this->em->flush();
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  *
  * @return CategoryInterface[]
  */
 public function process($data)
 {
     $categories = [];
     $parents = [];
     $items = [];
     foreach ($data as $item) {
         $parents[$item['code']] = isset($item['parent']) ? $item['parent'] : null;
         unset($item['parent']);
         if ($category = parent::process($item)) {
             $categories[$item['code']] = $category;
             $items[$item['code']] = $item;
         }
     }
     $this->setParents($categories, $parents, $items);
     if (true === $this->circularRefsChecked) {
         $this->checkCircularReferences($categories, $items);
     }
     return $categories;
 }