ArrayLoader
in package
implements
LoaderInterface
FinalYes
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
Table of Contents
Interfaces
- LoaderInterface
- Interface all loaders must implement.
Properties
- $templates : mixed
Methods
- __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)
exists()
public
exists(string $name) : bool
Parameters
- $name : string
Return values
boolgetCacheKey()
Gets the cache key to use for the cache for a given template name.
public
getCacheKey(string $name) : string
Parameters
- $name : string
Return values
stringgetSourceContext()
Returns the source context for a given template logical name.
public
getSourceContext(string $name) : Source
Parameters
- $name : string
Return values
SourceisFresh()
public
isFresh(string $name, int $time) : bool
Parameters
- $name : string
- $time : int
-
Timestamp of the last modification time of the cached template
Return values
boolsetTemplate()
public
setTemplate(string $name, string $template) : void
Parameters
- $name : string
- $template : string