aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/template/twig/loader.php
blob: b153bd81eae186e5ccbbc406d3a7a11e0b1b9935 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
/**
*
* @package phpBB3
* @copyright (c) 2013 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/

// @todo remove if not needed
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;
    }
}