123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- <?php
-
-
-
-
- class Twig_Loader_Array implements Twig_LoaderInterface
- {
- protected $templates;
-
-
-
- public function __construct(array $templates)
- {
- $this->templates = array();
- foreach ($templates as $name => $template) {
- $this->templates[$name] = $template;
- }
- }
-
-
-
- public function setTemplate($name, $template)
- {
- $this->templates[(string) $name] = $template;
- }
-
-
-
- public function getSource($name)
- {
- $name = (string) $name;
- if (!isset($this->templates[$name])) {
- throw new Twig_Error_Loader(sprintf('Template "%s" is not defined.', $name));
- }
-
- return $this->templates[$name];
- }
-
-
-
- public function getCacheKey($name)
- {
- $name = (string) $name;
- if (!isset($this->templates[$name])) {
- throw new Twig_Error_Loader(sprintf('Template "%s" is not defined.', $name));
- }
-
- return $this->templates[$name];
- }
-
-
-
- public function isFresh($name, $time)
- {
- $name = (string) $name;
- if (!isset($this->templates[$name])) {
- throw new Twig_Error_Loader(sprintf('Template "%s" is not defined.', $name));
- }
-
- return true;
- }
- }
|