From 64d46017a69adbb6b46401ba520115644f49fa96 Mon Sep 17 00:00:00 2001 From: Nikolai Besschetnov Date: Sun, 15 Jun 2014 13:05:39 +0400 Subject: [PATCH] Extra autoload paths for a Twig as the extension option --- ETwigViewRenderer.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/ETwigViewRenderer.php b/ETwigViewRenderer.php index ceedc4f..66ee5f0 100644 --- a/ETwigViewRenderer.php +++ b/ETwigViewRenderer.php @@ -61,6 +61,15 @@ class ETwigViewRenderer extends CApplicationComponent implements IViewRenderer * ) */ public $lexerOptions = array(); + /** + * The default autoload paths are + * * application base path + * * theme path + * Push extra paths if you feel the need in these + * Example: array('application.views'); + * @var array autoload paths + */ + public $paths = array(); private $_twig; private $_paths; @@ -83,6 +92,12 @@ function init() $this->_paths[] = $app->getBasePath(); + if(is_array($this->paths) && sizeof($this->paths) > 0) { + foreach($this->paths as $pathAlias) { + $this->_paths[] = Yii::getPathOfAlias($pathAlias); + } + } + $loader = new Twig_Loader_Filesystem($this->_paths); $defaultOptions = array(