FilesystemLoader
extends FilesystemLoader
in package
FilesystemLoader extends the default Twig filesystem loader to work with the Symfony paths and template references.
Tags
Table of Contents
- MAIN_NAMESPACE = '__main__'
- Identifier of the main namespace.
- $cache : mixed
- $errorCache : mixed
- $locator : mixed
- $parser : mixed
- $paths : mixed
- $rootPath : mixed
- __construct() : mixed
- addPath() : void
- exists() : bool
- getCacheKey() : string
- Gets the cache key to use for the cache for a given template name.
- getNamespaces() : array<string|int, mixed>
- Returns the path namespaces.
- getPaths() : array<string|int, mixed>
- Returns the paths to the templates.
- getSourceContext() : Source
- Returns the source context for a given template logical name.
- isFresh() : bool
- prependPath() : void
- setPaths() : void
- findTemplate() : string
- Returns the path to the template file.
- isAbsolutePath() : bool
- normalizeName() : string
- parseName() : array<string|int, mixed>
- validateName() : void
Constants
MAIN_NAMESPACE
Identifier of the main namespace.
public
mixed
MAIN_NAMESPACE
= '__main__'
Properties
$cache
protected
mixed
$cache
= []
$errorCache
protected
mixed
$errorCache
= []
$locator
protected
mixed
$locator
$parser
protected
mixed
$parser
$paths
protected
mixed
$paths
= []
$rootPath
private
mixed
$rootPath
Methods
__construct()
public
__construct(FileLocatorInterface $locator, TemplateNameParserInterface $parser[, string|null $rootPath = null ]) : mixed
Parameters
- $locator : FileLocatorInterface
- $parser : TemplateNameParserInterface
- $rootPath : string|null = null
-
The root path common to all relative paths (null for getcwd())
Return values
mixed —addPath()
public
addPath(string $path[, string $namespace = self::MAIN_NAMESPACE ]) : void
Parameters
- $path : string
- $namespace : string = self::MAIN_NAMESPACE
Tags
Return values
void —exists()
public
exists(mixed $name) : bool
The name parameter might also be a TemplateReferenceInterface.
Parameters
- $name : mixed
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 —getNamespaces()
Returns the path namespaces.
public
getNamespaces() : array<string|int, mixed>
The main namespace is always defined.
Return values
array<string|int, mixed> —getPaths()
Returns the paths to the templates.
public
getPaths([string $namespace = self::MAIN_NAMESPACE ]) : array<string|int, mixed>
Parameters
- $namespace : string = self::MAIN_NAMESPACE
Return values
array<string|int, mixed> —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 —prependPath()
public
prependPath(string $path[, string $namespace = self::MAIN_NAMESPACE ]) : void
Parameters
- $path : string
- $namespace : string = self::MAIN_NAMESPACE
Tags
Return values
void —setPaths()
public
setPaths(string|array<string|int, mixed> $paths[, string $namespace = self::MAIN_NAMESPACE ]) : void
Parameters
- $paths : string|array<string|int, mixed>
-
A path or an array of paths where to look for templates
- $namespace : string = self::MAIN_NAMESPACE
Return values
void —findTemplate()
Returns the path to the template file.
protected
findTemplate(string|TemplateReferenceInterface $template[, bool $throw = true ]) : string
The file locator is used to locate the template when the naming convention is the symfony one (i.e. the name can be parsed). Otherwise the template is located using the locator from the twig library.
Parameters
- $template : string|TemplateReferenceInterface
-
The template
- $throw : bool = true
-
When true, a LoaderError exception will be thrown if a template could not be found
Tags
Return values
string —The path to the template file
isAbsolutePath()
private
isAbsolutePath(string $file) : bool
Parameters
- $file : string
Return values
bool —normalizeName()
private
normalizeName(string $name) : string
Parameters
- $name : string
Return values
string —parseName()
private
parseName(string $name[, string $default = self::MAIN_NAMESPACE ]) : array<string|int, mixed>
Parameters
- $name : string
- $default : string = self::MAIN_NAMESPACE
Return values
array<string|int, mixed> —validateName()
private
validateName(string $name) : void
Parameters
- $name : string