Ejemplo n.º 1
0
 public function testShouldThrowExceptionForUnknownHelper()
 {
     $view = new View();
     $volt = new View\Engine\Volt($view);
     $exception = null;
     try {
         $volt->registerHelper('test');
     } catch (\Exception $e) {
         $exception = $e;
     }
     $this->assertInstanceOf('\\Vegas\\Mvc\\View\\Engine\\Volt\\Exception\\UnknownHelperException', $exception);
 }
Ejemplo n.º 2
0
 /**
  * Constructor
  * Prepares view settings and engine
  *
  * @override
  * @param null $options
  * @param null $viewDir
  */
 public function __construct($options = null, $viewDir = null)
 {
     parent::__construct($options);
     if (isset($options['layoutsDir'])) {
         $this->setLayoutsDir($options['layoutsDir']);
     }
     if (isset($options['partialsDir']) && $options['partialsDir']) {
         $this->setPartialsDir($options['partialsDir']);
     }
     if (!$this->getPartialsDir() && $viewDir) {
         $this->setPartialsDir($viewDir);
     }
     if (isset($options['layout']) && !empty($options['layout'])) {
         $this->setLayout($options['layout']);
     }
     $this->registerEngines(array('.volt' => function ($this, $di) use($options) {
         $volt = new Volt($this, $di);
         if (isset($options['cacheDir'])) {
             $volt->setOptions(array('compiledPath' => $options['cacheDir'], 'compiledSeparator' => '_', 'compileAlways' => isset($options['compileAlways']) ? $options['compileAlways'] : false));
         }
         $volt->registerFilters();
         $volt->registerHelpers();
         $volt->setExtension('.volt');
         return $volt;
     }, '.phtml' => 'Phalcon\\Mvc\\View\\Engine\\Php'));
 }