/** * {@inheritdoc} * * @param ViewBaseInterface $view * @param DiInterface $di * @param array $options * @param array $userFunctions */ public function __construct(ViewBaseInterface $view, DiInterface $di = null, $options = array(), $userFunctions = array()) { $loader = new \Twig_Loader_Filesystem($view->getViewsDir()); $this->twig = new Twig\Environment($di, $loader, $options); $this->twig->addExtension(new Twig\CoreExtension()); $this->registryFunctions($view, $di, $userFunctions); parent::__construct($view, $di); }
/** * view register function for tests * * @param \Phalcon\Mvc\ViewBaseInterface $view new class instance * @return \Phalcon\Mvc\ViewBaseInterface */ function testViewRegister(\Phalcon\Mvc\ViewBaseInterface $view) { $view->setViewsDir('views/'); $eventsManager = new \Phalcon\Events\Manager(); // // For XML debug // if ($_GET['debug'] == 1) { $eventsManager->attach('view:beforeRender', function ($event, \Phalcon\Mvc\ViewBaseInterface $view) { header('Content-Type: text/plain;charset=utf-8'); echo XSLT::createXmlFromArray((array) $view->getParamsToView(), 'variables')->saveXML(); exit; }); } $view->setEventsManager($eventsManager); $view->registerEngines(array('.xsl' => '\\Z\\Phalcon\\Mvc\\View\\Engine\\XSLT', '.xsl' => function ($view, $di) { $engine = new XSLT($view, $di); $engine->setOptions(array('phpFunctions' => array('ucfirst'))); return $engine; })); return $view; }
protected function renderPartialBuffered(ViewBaseInterface $view, $partial, $expectedParams = null) { ob_start(); $view->partial($partial, $expectedParams); ob_clean(); }
public function __construct(\Phalcon\Mvc\ViewBaseInterface $view, \Phalcon\DiInterface $di = null) { $loader = new Twig_Loader_Filesystem($view->getViewsDir()); $this->_twig = new Twig_Environment($loader); parent::__construct($view, $di); }
/** * Twig constructor. * * @param ViewBaseInterface $view * @param DiInterface|null $dependencyInjector */ public function __construct(ViewBaseInterface $view, DiInterface $dependencyInjector = null) { $this->twig = new Twig_Environment(new Twig_Loader_Filesystem($view->getViewsDir())); parent::__construct($view, $dependencyInjector); }