PEEL Shopping
Open source ecommerce : PEEL Shopping
Array.php
Go to the documentation of this file.
1 <?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 
23 {
24  protected $templates;
25 
33  public function __construct(array $templates)
34  {
35  $this->templates = array();
36  foreach ($templates as $name => $template) {
37  $this->templates[$name] = $template;
38  }
39  }
40 
47  public function setTemplate($name, $template)
48  {
49  $this->templates[(string) $name] = $template;
50  }
51 
55  public function getSource($name)
56  {
57  $name = (string) $name;
58  if (!isset($this->templates[$name])) {
59  throw new Twig_Error_Loader(sprintf('Template "%s" is not defined.', $name));
60  }
61 
62  return $this->templates[$name];
63  }
64 
68  public function exists($name)
69  {
70  return isset($this->templates[(string) $name]);
71  }
72 
76  public function getCacheKey($name)
77  {
78  $name = (string) $name;
79  if (!isset($this->templates[$name])) {
80  throw new Twig_Error_Loader(sprintf('Template "%s" is not defined.', $name));
81  }
82 
83  return $this->templates[$name];
84  }
85 
89  public function isFresh($name, $time)
90  {
91  $name = (string) $name;
92  if (!isset($this->templates[$name])) {
93  throw new Twig_Error_Loader(sprintf('Template "%s" is not defined.', $name));
94  }
95 
96  return true;
97  }
98 }
Loads a template from an array.
Definition: Array.php:22
getCacheKey($name)
{Gets the cache key to use for the cache for a given template name.The name of the template to loadst...
Definition: Array.php:76
setTemplate($name, $template)
Adds or overrides a template.
Definition: Array.php:47
Adds an exists() method for loaders.
__construct(array $templates)
Constructor.
Definition: Array.php:33
exists($name)
{Check if we have the source code of a template, given its name.The name of the template to check if ...
Definition: Array.php:68
Interface all loaders must implement.
getSource($name)
{Gets the source code of a template, given its name.The name of the template to loadstring The templa...
Definition: Array.php:55
Exception thrown when an error occurs during template loading.
Definition: Loader.php:25
isFresh($name, $time)
{Returns true if the template is still fresh.The template name The last modification time of the cach...
Definition: Array.php:89

This documentation for Open ecommerce PEEL Shopping and PEEL.fr has been generated by Doxygen on Thu Oct 15 2015 14:41:18 - Peel ecommerce is a product of Agence web Advisto SAS. All rights reserved.