mirror of
https://github.com/phpbb/phpbb.git
synced 2025-02-24 20:13:22 +01:00
[feature/twig] Use phpBB's resource locator to find templates
PHPBB3-11598
This commit is contained in:
parent
74f19830f3
commit
fa86f45f62
50
phpBB/includes/template/twig/loader.php
Normal file
50
phpBB/includes/template/twig/loader.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package phpBB3
|
||||
* @copyright (c) 2013 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
class phpbb_template_twig_loader extends Twig_Loader_Filesystem
|
||||
{
|
||||
protected $phpbb_locator;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string|array $paths A path or an array of paths where to look for templates
|
||||
* @param phpbb_template_locator
|
||||
*/
|
||||
public function __construct($paths = array(), phpbb_template_locator $phpbb_locator)
|
||||
{
|
||||
if ($paths) {
|
||||
$this->setPaths($paths);
|
||||
}
|
||||
|
||||
$this->phpbb_locator = $phpbb_locator;
|
||||
}
|
||||
|
||||
protected function findTemplate($name)
|
||||
{
|
||||
$name = (string) $name;
|
||||
|
||||
if (!$name)
|
||||
{
|
||||
throw new Twig_Error_Loader(sprintf('Unable to find template "%s".', $name));
|
||||
}
|
||||
|
||||
$this->phpbb_locator->set_filenames(array(
|
||||
'temp' => $name,
|
||||
));
|
||||
$location = $this->phpbb_locator->get_source_file_for_handle('temp');
|
||||
|
||||
if (!$location)
|
||||
{
|
||||
throw new Twig_Error_Loader(sprintf('Unable to find template "%s".', $name));
|
||||
}
|
||||
|
||||
return $this->cache[$name] = $location;
|
||||
}
|
||||
}
|
@ -107,7 +107,7 @@ class phpbb_template_twig implements phpbb_template
|
||||
$this->context = $context;
|
||||
$this->extension_manager = $extension_manager;
|
||||
|
||||
$loader = new Twig_Loader_Filesystem($phpbb_root_path . 'styles/prosilver/template/');
|
||||
$loader = new phpbb_template_twig_loader($phpbb_root_path . 'styles/prosilver/template/', $this->locator);
|
||||
//$loader = new Twig_Loader_Filesystem($phpbb_root_path . 'adm/style/');
|
||||
$this->twig = new Twig_Environment($loader, array(
|
||||
'cache' => $phpbb_root_path . 'cache/twig/',
|
||||
|
Loading…
x
Reference in New Issue
Block a user