ArrayLoader
in package
implements
LoaderInterface
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.
Tags
Interfaces, Classes, Traits and Enums
- LoaderInterface
- Interface all loaders must implement.
Table of Contents
- $templates : mixed
- __construct() : mixed
- exists() : bool
- getCacheKey() : string
- Gets the cache key to use for the cache for a given template name.
- getSourceContext() : Source
- Returns the source context for a given template logical name.
- isFresh() : bool
- setTemplate() : void
Properties
$templates
private
mixed
$templates
= []
Methods
__construct()
public
__construct([array<string|int, mixed> $templates = [] ]) : mixed
Parameters
- $templates : array<string|int, mixed> = []
-
An array of templates (keys are the names, and values are the source code)
Return values
mixed —exists()
public
exists(string $name) : bool
Parameters
- $name : string
Return values
bool —getCacheKey()
Gets the cache key to use for the cache for a given template name.
public
getCacheKey(string $name) : string
Parameters
- $name : string
Return values
string —getSourceContext()
Returns the source context for a given template logical name.
public
getSourceContext(string $name) : Source
Parameters
- $name : string
Return values
Source —isFresh()
public
isFresh(string $name, int $time) : bool
Parameters
- $name : string
- $time : int
-
Timestamp of the last modification time of the cached template
Return values
bool —setTemplate()
public
setTemplate(string $name, string $template) : void
Parameters
- $name : string
- $template : string