1 |
1686
|
darkviper
|
<?php
|
2 |
|
|
|
3 |
|
|
/*
|
4 |
|
|
* This file is part of Twig.
|
5 |
|
|
*
|
6 |
|
|
* (c) 2009 Fabien Potencier
|
7 |
|
|
*
|
8 |
|
|
* For the full copyright and license information, please view the LICENSE
|
9 |
|
|
* file that was distributed with this source code.
|
10 |
|
|
*/
|
11 |
|
|
|
12 |
|
|
/**
|
13 |
|
|
* Loads a template from a string.
|
14 |
|
|
*
|
15 |
1852
|
darkviper
|
* This loader should only be used for unit testing as it has many limitations
|
16 |
|
|
* (for instance, the include or extends tag does not make any sense for a string
|
17 |
|
|
* loader).
|
18 |
|
|
*
|
19 |
1686
|
darkviper
|
* When using this loader with a cache mechanism, you should know that a new cache
|
20 |
|
|
* key is generated each time a template content "changes" (the cache key being the
|
21 |
|
|
* source code of the template). If you don't want to see your cache grows out of
|
22 |
|
|
* control, you need to take care of clearing the old cache file by yourself.
|
23 |
|
|
*
|
24 |
|
|
* @package twig
|
25 |
|
|
* @author Fabien Potencier <fabien@symfony.com>
|
26 |
|
|
*/
|
27 |
1852
|
darkviper
|
class Twig_Loader_String implements Twig_LoaderInterface, Twig_ExistsLoaderInterface
|
28 |
1686
|
darkviper
|
{
|
29 |
|
|
/**
|
30 |
1852
|
darkviper
|
* {@inheritdoc}
|
31 |
1686
|
darkviper
|
*/
|
32 |
|
|
public function getSource($name)
|
33 |
|
|
{
|
34 |
|
|
return $name;
|
35 |
|
|
}
|
36 |
|
|
|
37 |
|
|
/**
|
38 |
1852
|
darkviper
|
* {@inheritdoc}
|
39 |
1686
|
darkviper
|
*/
|
40 |
1852
|
darkviper
|
public function exists($name)
|
41 |
|
|
{
|
42 |
|
|
return true;
|
43 |
|
|
}
|
44 |
|
|
|
45 |
|
|
/**
|
46 |
|
|
* {@inheritdoc}
|
47 |
|
|
*/
|
48 |
1686
|
darkviper
|
public function getCacheKey($name)
|
49 |
|
|
{
|
50 |
|
|
return $name;
|
51 |
|
|
}
|
52 |
|
|
|
53 |
|
|
/**
|
54 |
1852
|
darkviper
|
* {@inheritdoc}
|
55 |
1686
|
darkviper
|
*/
|
56 |
|
|
public function isFresh($name, $time)
|
57 |
|
|
{
|
58 |
|
|
return true;
|
59 |
|
|
}
|
60 |
|
|
}
|