Пример #1
0
 /**
  * Initialise data for configuration
  * @return void
  */
 protected function initData()
 {
     $data = $this->cache->load($this->cacheId);
     if (false === $data) {
         $data = $this->reader->read();
         $this->cache->save(serialize($data), $this->cacheId, $this->cacheTags);
     } else {
         $data = unserialize($data);
     }
     $this->merge($data);
 }
Пример #2
0
 public static function discover($path, ReaderInterface $reader)
 {
     $data = array();
     $ext = $reader->getFileExtensions();
     if (empty($ext)) {
         $pattern = '*';
     } else {
         if (1 === count($ext)) {
             $pattern = '*.' . $ext;
         } else {
             $pattern = '*.{' . implode(',', $ext) . '}';
         }
     }
     foreach (glob($path . '/' . $pattern, GLOB_BRACE | GLOB_NOESCAPE) as $filename) {
         $additions = $reader->read($filename);
         // Fetch section name
         $parts = explode('.', basename($filename));
         array_pop($parts);
         $current =& $data;
         foreach ($parts as $part) {
             if (empty($current[$part])) {
                 $current[$part] = array();
             }
             $current =& $current[$part];
         }
         $current = drupal_array_merge_deep($additions, $current);
     }
     return $data;
 }
Пример #3
0
 /**
  * {@inheritdoc}
  */
 public function load($file)
 {
     $this->eventDispatcher->dispatch(static::EVENT_STARTED, new FixtureLoaderEvent($file));
     $this->reader->setFilePath($file);
     if ($this->multiple) {
         $items = $this->reader->read();
         foreach ($this->processor->process($items) as $object) {
             $this->persistObjects($object);
         }
     } else {
         while ($item = $this->reader->read()) {
             $this->persistObjects($this->processor->process($item));
         }
     }
     $this->objectManager->flush();
     $this->objectManager->clear();
     $this->doctrineCache->clear();
     $this->eventDispatcher->dispatch(static::EVENT_COMPLETED, new FixtureLoaderEvent($file));
 }
Пример #4
0
 /**
  * Method returns an array with configuration for specified tag in specified source.
  *
  * @param $tagName
  * @param $source
  * @return array
  */
 public function getConfig($tagName, $source)
 {
     $config = $this->reader->read($tagName, $source);
     return $this->converter->convert($config);
 }