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
|
class phpbb_template_twig_environment extends Twig_Environment
|
||||||
{
|
{
|
||||||
/** @var array */
|
/** @var array */
|
||||||
protected $phpbbExtensions;
|
protected $phpbb_extensions;
|
||||||
|
|
||||||
/** @var phpbb_config */
|
/** @var phpbb_config */
|
||||||
protected $phpbbConfig;
|
protected $phpbb_config;
|
||||||
|
|
||||||
|
/** @var string */
|
||||||
|
protected $phpbb_root_path;
|
||||||
|
|
||||||
/** @var array **/
|
/** @var array **/
|
||||||
protected $namespaceLookUpOrder = array('__main__');
|
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.
|
* 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()
|
public function get_phpbb_extensions()
|
||||||
{
|
{
|
||||||
return $this->phpbbExtensions;
|
return $this->phpbb_extensions;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Store the list of enabled phpBB extensions
|
|
||||||
*
|
|
||||||
* @param array $extensions
|
|
||||||
* @return Twig_Environment
|
|
||||||
*/
|
|
||||||
public function set_phpbb_extensions($extensions)
|
|
||||||
{
|
|
||||||
$this->phpbbExtensions = $extensions;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -74,20 +73,17 @@ class phpbb_template_twig_environment extends Twig_Environment
|
||||||
*/
|
*/
|
||||||
public function get_phpbb_config()
|
public function get_phpbb_config()
|
||||||
{
|
{
|
||||||
return $this->phpbbConfig;
|
return $this->phpbb_config;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set phpBB config
|
* Get the phpBB root path
|
||||||
*
|
*
|
||||||
* @param phpbb_config $config
|
* @return string
|
||||||
* @return Twig_Environment
|
*/
|
||||||
*/
|
public function get_phpbb_root_path()
|
||||||
public function set_phpbb_config($config)
|
{
|
||||||
{
|
return $this->phpbb_root_path;
|
||||||
$this->phpbbConfig = $config;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -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()
|
// Initiate the loader, __main__ namespace paths will be setup later in set_style_names()
|
||||||
$loader = new Twig_Loader_Filesystem('');
|
$loader = new Twig_Loader_Filesystem('');
|
||||||
|
|
||||||
$this->twig = new phpbb_template_twig_environment($loader, array(
|
$this->twig = new phpbb_template_twig_environment(
|
||||||
'cache' => $this->cachepath,
|
$this->config,
|
||||||
'debug' => true, // @todo
|
($this->extension_manager) ? $this->extension_manager->all_enabled() : array(),
|
||||||
'auto_reload' => true, // @todo
|
$this->phpbb_root_path,
|
||||||
'autoescape' => false,
|
$loader,
|
||||||
));
|
array(
|
||||||
|
'cache' => $this->cachepath,
|
||||||
// Set enabled phpbb extensions
|
'debug' => true, // @todo
|
||||||
if ($this->extension_manager)
|
'auto_reload' => true, // @todo
|
||||||
{
|
'autoescape' => false,
|
||||||
$this->twig->set_phpbb_extensions($this->extension_manager->all_enabled());
|
)
|
||||||
}
|
);
|
||||||
|
|
||||||
// Set config
|
|
||||||
$this->twig->set_phpbb_config($this->config);
|
|
||||||
|
|
||||||
// Clear previous cache files (while WIP)
|
// Clear previous cache files (while WIP)
|
||||||
// @todo remove
|
// @todo remove
|
||||||
|
|
Loading…
Add table
Reference in a new issue