\Twig_Loader_Array

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.

This loader should only be used for unit testing.

Summary

Methods
Properties
Constants
__construct()
setTemplate()
getSourceContext()
exists()
getCacheKey()
isFresh()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
$templates
N/A

Properties

$templates

$templates : 

Type

Methods

__construct()

__construct(array  $templates = array()) 

Parameters

array $templates

An array of templates (keys are the names, and values are the source code)

setTemplate()

setTemplate(string  $name, string  $template) 

Adds or overrides a template.

Parameters

string $name

The template name

string $template

The template source

getSourceContext()

getSourceContext(string  $name) : \Twig_Source

Returns the source context for a given template logical name.

Parameters

string $name

The template logical name

Returns

\Twig_Source

exists()

exists(string  $name) : boolean

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

Parameters

string $name

The name of the template to check if we can load

Returns

boolean —

If the template source code is handled by this loader or not

getCacheKey()

getCacheKey(string  $name) : string

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

Parameters

string $name

The name of the template to load

Returns

string —

The cache key

isFresh()

isFresh(string  $name, integer  $time) : boolean

Returns true if the template is still fresh.

Parameters

string $name

The template name

integer $time

Timestamp of the last modification time of the cached template

Returns

boolean —

true if the template is fresh, false otherwise