/** * Method to instantiate the view. * * @param App $app The application object. * @param ModelInterface $model The model object. * @param string|array $templatesPaths The templates paths. * * @throws \RuntimeException * @since 1.0 */ public function __construct(App $app, ModelInterface $model, $templatesPaths = '') { parent::__construct($model); $this->app = $app; $renderer = $app->getContainer()->get('config')->get('renderer.type'); $className = 'App\\View\\Renderer\\' . ucfirst($renderer); if (false == class_exists($className)) { throw new \RuntimeException(sprintf('Invalid renderer: %s', $renderer)); } $config = array(); $config['templates_base_dir'] = JPATH_TEMPLATES; // Load the renderer. $this->renderer = new $className($config); // Register application's Twig extension. $this->renderer->addExtension(new TwigExtension($app)); // Register additional paths. if (!empty($templatesPaths)) { $this->renderer->setTemplatesPaths($templatesPaths, true); } // Register the theme path $this->renderer->set('themePath', DEFAULT_THEME . '/'); // Retrieve and clear the message queue $this->renderer->set('flashBag', $app->getMessageQueue()); $app->clearMessageQueue(); }
/** * Tests the escape method. * * @return void * * @covers Joomla\View\AbstractView::escape * @since 1.0 */ public function testEscape() { $this->assertEquals('foo', $this->instance->escape('foo')); }
/** * Method to instantiate the view. * * @param ModelInterface $model The model object. * @param RendererInterface $renderer The renderer object. * * @since 1.0 * @throws \RuntimeException */ public function __construct(ModelInterface $model, RendererInterface $renderer) { parent::__construct($model); $this->renderer = $renderer; }
/** * Method to instantiate the view. * * @param ModelInterface $model The model object. * @param \SplPriorityQueue $paths The paths queue. * * @since 1.0 */ public function __construct(ModelInterface $model, \SplPriorityQueue $paths = null) { parent::__construct($model); // Setup dependencies. $this->paths = isset($paths) ? $paths : $this->loadPaths(); }