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;
 }
Beispiel #2
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);
 }
 /**
  * {@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));
 }
Beispiel #4
0
    public function testWriteAndRead()
    {
        $config = new Config(array('default' => array('test' => 'foo')));

        $this->writer->toFile($this->getTestAssetFileName(), $config);

        $config = $this->reader->fromFile($this->getTestAssetFileName());

        $this->assertEquals('foo', $config['default']['test']);
    }
Beispiel #5
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);
 }
Beispiel #6
0
 public function toHtmlFromReader($text)
 {
     return $this->reader->getMarkdown($text);
 }