mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-27 21:58:52 +00:00
[feature/twig] Setup the style chain/loader properly
PHPBB3-11598
This commit is contained in:
parent
c5db8be580
commit
93d94d5cbe
1 changed files with 26 additions and 18 deletions
|
@ -111,29 +111,13 @@ class phpbb_template_twig implements phpbb_template
|
||||||
|
|
||||||
$this->cachepath = $phpbb_root_path . 'cache/twig/';
|
$this->cachepath = $phpbb_root_path . 'cache/twig/';
|
||||||
|
|
||||||
// Setup loader with __main__ paths
|
// Initiate the loader, __main__ namespace paths will be setup later in set_style_names()
|
||||||
$loader = new Twig_Loader_Filesystem(array(
|
$loader = new Twig_Loader_Filesystem('');
|
||||||
$phpbb_root_path . 'styles/prosilver/template/',
|
|
||||||
), $this->locator);
|
|
||||||
|
|
||||||
// Add core namespace
|
|
||||||
$loader->addPath($this->phpbb_root_path . 'styles/prosilver/template/', 'core');
|
|
||||||
|
|
||||||
// Add admin namespace
|
// Add admin namespace
|
||||||
// @todo use phpbb_admin path
|
// @todo use phpbb_admin path
|
||||||
$loader->addPath($this->phpbb_root_path . 'adm/style/', 'admin');
|
$loader->addPath($this->phpbb_root_path . 'adm/style/', 'admin');
|
||||||
|
|
||||||
// Add all namespaces for all extensions
|
|
||||||
if ($this->extension_manager instanceof phpbb_extension_manager)
|
|
||||||
{
|
|
||||||
foreach ($this->extension_manager->all_enabled() as $ext_namespace => $ext_path)
|
|
||||||
{
|
|
||||||
// @todo proper style chain
|
|
||||||
$loader->addPath($ext_path . 'styles/prosilver/', $ext_namespace);
|
|
||||||
$loader->addPath($ext_path . 'styles/all/', $ext_namespace);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->twig = new Twig_Environment($loader, array(
|
$this->twig = new Twig_Environment($loader, array(
|
||||||
'cache' => $this->cachepath,
|
'cache' => $this->cachepath,
|
||||||
'debug' => true, // @todo
|
'debug' => true, // @todo
|
||||||
|
@ -179,8 +163,32 @@ class phpbb_template_twig implements phpbb_template
|
||||||
{
|
{
|
||||||
$this->style_names = $style_names;
|
$this->style_names = $style_names;
|
||||||
|
|
||||||
|
// Set as __main__ namespace
|
||||||
$this->twig->getLoader()->setPaths($style_paths);
|
$this->twig->getLoader()->setPaths($style_paths);
|
||||||
|
|
||||||
|
// Core style namespace from phpbb_style::set_style()
|
||||||
|
if ($style_names === array($this->user->style['style_path']) || $style_names[0] == $this->user->style['style_path'])
|
||||||
|
{
|
||||||
|
$this->twig->getLoader()->setPaths($style_paths, 'core');
|
||||||
|
|
||||||
|
// Add all namespaces for all extensions
|
||||||
|
if ($this->extension_manager instanceof phpbb_extension_manager)
|
||||||
|
{
|
||||||
|
$style_names[] = 'all';
|
||||||
|
|
||||||
|
foreach ($this->extension_manager->all_enabled() as $ext_namespace => $ext_path)
|
||||||
|
{
|
||||||
|
foreach ($style_names as $style_name)
|
||||||
|
{
|
||||||
|
if (is_dir($ext_path . 'styles/' . $style_name))
|
||||||
|
{
|
||||||
|
$this->twig->getLoader()->addPath($ext_path . 'styles/' . $style_name, $ext_namespace);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue