/**
  * extractConfig
  *
  * @param string $template
  *
  * @return  string
  */
 public function prepareData($template)
 {
     $template = explode('---', $template, 3);
     if (!trim($template[0])) {
         array_shift($template);
         $template = implode('---', $template);
         $template = explode('---', $template, 2);
     }
     try {
         $config = Yaml::parse($template[0]);
         if ($config) {
             array_shift($template);
         }
         $this->config->loadArray($config);
         $this->config->merge(Ioc::getConfig());
         $this->getData()->bind(array('config' => $this->config->toArray()));
         // Target permalink
         if ($this->config['permalink']) {
             $this->target = rtrim($this->config['permalink'], '/');
             if (substr($this->target, -5) != '.html') {
                 $this->target .= '/index.html';
             }
             $this->data->uri['base'] = ProcessorHelper::getBackwards($this->target) ?: './';
             $this->data->uri['media'] = ProcessorHelper::getBackwards($this->target) . 'media/';
         } else {
             $this->target = $this->getTarget();
         }
         $template = implode('---', $template);
     } catch (ParseException $e) {
         $template = implode('---', $template);
     }
     $event = new Event('loadProvider');
     $event['data'] = $this->data;
     $event['processor'] = $this;
     $dispatcher = Ioc::getDispatcher();
     $dispatcher->triggerEvent($event);
     return $template;
 }
Beispiel #2
0
 /**
  * Method to test loadArray().
  *
  * @return void
  *
  * @covers Windwalker\Registry\Registry::loadArray
  */
 public function testLoadArray()
 {
     $registry = new Registry();
     $registry->loadArray($this->getTestData());
     $this->assertEquals($registry->get('olive'), 'peace');
     $this->assertEquals($registry->get('pos1.sunflower'), 'love');
 }
Beispiel #3
0
 /**
  * Class init.
  *
  * @param \SplPriorityQueue $paths
  * @param array             $config
  */
 public function __construct($paths = null, $config = array())
 {
     $this->setPaths($paths);
     $this->config = new Registry($this->config);
     $this->config->loadArray($config);
 }