aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/template
diff options
context:
space:
mode:
authorNathaniel Guse <nathaniel.guse@gmail.com>2013-06-25 14:58:55 -0500
committerNathaniel Guse <nathaniel.guse@gmail.com>2013-06-25 14:58:55 -0500
commit68225d9f298f5f9de5f931b28241329931d16574 (patch)
tree4689864ed5caea228e9d2ca1c0d1965d9f480804 /phpBB/includes/template
parentea785efb30ced6ab399b290df6f202cb97315f80 (diff)
downloadforums-68225d9f298f5f9de5f931b28241329931d16574.tar
forums-68225d9f298f5f9de5f931b28241329931d16574.tar.gz
forums-68225d9f298f5f9de5f931b28241329931d16574.tar.bz2
forums-68225d9f298f5f9de5f931b28241329931d16574.tar.xz
forums-68225d9f298f5f9de5f931b28241329931d16574.zip
[feature/twig] Pass parameters required to twig env via constructor
Instead of creating set functions PHPBB3-11598
Diffstat (limited to 'phpBB/includes/template')
-rw-r--r--phpBB/includes/template/twig/environment.php52
-rw-r--r--phpBB/includes/template/twig/twig.php27
2 files changed, 36 insertions, 43 deletions
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