mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 22:28:51 +00:00
[feature/twig] Pass parameters required to twig env via constructor
Instead of creating set functions PHPBB3-11598
This commit is contained in:
parent
ea785efb30
commit
68225d9f29
2 changed files with 36 additions and 43 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue