PEEL Shopping
Open source ecommerce : PEEL Shopping
Public Member Functions | Protected Attributes
Twig_Loader_Array Class Reference

Loads a template from an array. More...

Inheritance diagram for Twig_Loader_Array:
Twig_LoaderInterface Twig_ExistsLoaderInterface

Public Member Functions

 __construct (array $templates)
 Constructor. More...
 
 setTemplate ($name, $template)
 Adds or overrides a template. More...
 
 getSource ($name)
 {Gets the source code of a template, given its name.
Parameters
string$nameThe name of the template to load
Returns
string The template source code
Exceptions
Twig_Error_LoaderWhen $name is not found
} More...
 
 exists ($name)
 {Check if we have the source code of a template, given its name.
Parameters
string$nameThe name of the template to check if we can load
Returns
boolean If the template source code is handled by this loader or not
} More...
 
 getCacheKey ($name)
 {Gets the cache key to use for the cache for a given template name.
Parameters
string$nameThe name of the template to load
Returns
string The cache key
Exceptions
Twig_Error_LoaderWhen $name is not found
} More...
 
 isFresh ($name, $time)
 {Returns true if the template is still fresh.
Parameters
string$nameThe template name
timestamp$timeThe last modification time of the cached template
Returns
Boolean true if the template is fresh, false otherwise
Exceptions
Twig_Error_LoaderWhen $name is not found
} More...
 

Protected Attributes

 $templates
 

Detailed Description

Loads a template from an array.

When using this loader with a cache mechanism, you should know that a new cache key is generated each time a template content "changes" (the cache key being the source code of the template). If you don't want to see your cache grows out of control, you need to take care of clearing the old cache file by yourself.

Author
Fabien Potencier fabie.nosp@m.n@sy.nosp@m.mfony.nosp@m..com

Definition at line 22 of file Array.php.

Constructor & Destructor Documentation

__construct ( array  $templates)

Constructor.

Parameters
array$templatesAn array of templates (keys are the names, and values are the source code)
See also
Twig_Loader

Definition at line 33 of file Array.php.

Member Function Documentation

exists (   $name)

{Check if we have the source code of a template, given its name.

Parameters
string$nameThe name of the template to check if we can load
Returns
boolean If the template source code is handled by this loader or not
}

Implements Twig_ExistsLoaderInterface.

Definition at line 68 of file Array.php.

getCacheKey (   $name)

{Gets the cache key to use for the cache for a given template name.

Parameters
string$nameThe name of the template to load
Returns
string The cache key
Exceptions
Twig_Error_LoaderWhen $name is not found
}

Implements Twig_LoaderInterface.

Definition at line 76 of file Array.php.

getSource (   $name)

{Gets the source code of a template, given its name.

Parameters
string$nameThe name of the template to load
Returns
string The template source code
Exceptions
Twig_Error_LoaderWhen $name is not found
}

Implements Twig_LoaderInterface.

Definition at line 55 of file Array.php.

isFresh (   $name,
  $time 
)

{Returns true if the template is still fresh.

Parameters
string$nameThe template name
timestamp$timeThe last modification time of the cached template
Returns
Boolean true if the template is fresh, false otherwise
Exceptions
Twig_Error_LoaderWhen $name is not found
}

Implements Twig_LoaderInterface.

Definition at line 89 of file Array.php.

setTemplate (   $name,
  $template 
)

Adds or overrides a template.

Parameters
string$nameThe template name
string$templateThe template source

Definition at line 47 of file Array.php.

Field Documentation

$templates
protected

Definition at line 24 of file Array.php.


The documentation for this class was generated from the following file:

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