diff --git a/phpBB/includes/template/twig/environment.php b/phpBB/includes/template/twig/environment.php index d9b56a56f6..5032df9483 100644 --- a/phpBB/includes/template/twig/environment.php +++ b/phpBB/includes/template/twig/environment.php @@ -18,14 +18,26 @@ if (!defined('IN_PHPBB')) class phpbb_template_twig_environment extends Twig_Environment { /** @var array */ - protected $phpbbExtensions; + protected $phpbb_extensions; /** @var phpbb_config */ - protected $phpbbConfig; + protected $phpbb_config; + + /** @var string */ + protected $phpbb_root_path; /** @var array **/ protected $namespaceLookUpOrder = array('__main__'); + public function __construct(phpbb_config $phpbb_config, $phpbb_extensions, $phpbb_root_path, Twig_LoaderInterface $loader = null, $options = array()) + { + $this->phpbb_config = $phpbb_config; + $this->phpbb_extensions = $phpbb_extensions; + $this->phpbb_root_path = $phpbb_root_path; + + return parent::__construct($loader, $options); + } + /** * Gets the cache filename for a given template. * @@ -51,20 +63,7 @@ class phpbb_template_twig_environment extends Twig_Environment */ public function get_phpbb_extensions() { - return $this->phpbbExtensions; - } - - /** - * Store the list of enabled phpBB extensions - * - * @param array $extensions - * @return Twig_Environment - */ - public function set_phpbb_extensions($extensions) - { - $this->phpbbExtensions = $extensions; - - return $this; + return $this->phpbb_extensions; } /** @@ -74,20 +73,17 @@ class phpbb_template_twig_environment extends Twig_Environment */ public function get_phpbb_config() { - return $this->phpbbConfig; + return $this->phpbb_config; } - /** - * Set phpBB config - * - * @param phpbb_config $config - * @return Twig_Environment - */ - public function set_phpbb_config($config) - { - $this->phpbbConfig = $config; - - return $this; + /** + * Get the phpBB root path + * + * @return string + */ + public function get_phpbb_root_path() + { + return $this->phpbb_root_path; } /** diff --git a/phpBB/includes/template/twig/twig.php b/phpBB/includes/template/twig/twig.php index af8ab615e6..97bba3f433 100644 --- a/phpBB/includes/template/twig/twig.php +++ b/phpBB/includes/template/twig/twig.php @@ -114,21 +114,18 @@ class phpbb_template_twig implements phpbb_template // Initiate the loader, __main__ namespace paths will be setup later in set_style_names() $loader = new Twig_Loader_Filesystem(''); - $this->twig = new phpbb_template_twig_environment($loader, array( - 'cache' => $this->cachepath, - 'debug' => true, // @todo - 'auto_reload' => true, // @todo - 'autoescape' => false, - )); - - // Set enabled phpbb extensions - if ($this->extension_manager) - { - $this->twig->set_phpbb_extensions($this->extension_manager->all_enabled()); - } - - // Set config - $this->twig->set_phpbb_config($this->config); + $this->twig = new phpbb_template_twig_environment( + $this->config, + ($this->extension_manager) ? $this->extension_manager->all_enabled() : array(), + $this->phpbb_root_path, + $loader, + array( + 'cache' => $this->cachepath, + 'debug' => true, // @todo + 'auto_reload' => true, // @todo + 'autoescape' => false, + ) + ); // Clear previous cache files (while WIP) // @todo remove