Constants

MAIN_NAMESPACE

MAIN_NAMESPACE = '__main__'

Identifier of the main namespace.

Properties

$paths

$paths : 

Type

$cache

$cache : 

Type

$errorCache

$errorCache : 

Type

$rootPath

$rootPath : 

Type

Methods

__construct()

__construct(string|array  $paths = array(), string|null  $rootPath = null) 

Parameters

string|array $paths

A path or an array of paths where to look for templates

string|null $rootPath

The root path common to all relative paths (null for getcwd())

getPaths()

getPaths(string  $namespace = self::MAIN_NAMESPACE) : array

Returns the paths to the templates.

Parameters

string $namespace

A path namespace

Returns

array —

The array of paths where to look for templates

getNamespaces()

getNamespaces() : array

Returns the path namespaces.

The main namespace is always defined.

Returns

array —

The array of defined namespaces

setPaths()

setPaths(string|array  $paths, string  $namespace = self::MAIN_NAMESPACE) 

Sets the paths where templates are stored.

Parameters

string|array $paths

A path or an array of paths where to look for templates

string $namespace

A path namespace

addPath()

addPath(string  $path, string  $namespace = self::MAIN_NAMESPACE) 

Adds a path where templates are stored.

Parameters

string $path

A path where to look for templates

string $namespace

A path namespace

Throws

\Twig_Error_Loader

prependPath()

prependPath(string  $path, string  $namespace = self::MAIN_NAMESPACE) 

Prepends a path where templates are stored.

Parameters

string $path

A path where to look for templates

string $namespace

A path namespace

Throws

\Twig_Error_Loader

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

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

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

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

findTemplate()

findTemplate(string  $name, boolean  $throw = true) : string|false

Checks if the template can be found.

Parameters

string $name

The template name

boolean $throw

Whether to throw an exception when an error occurs

Returns

string|false —

The template name or false

normalizeName()

normalizeName(  $name) 

Parameters

$name

parseName()

parseName(  $name,   $default = self::MAIN_NAMESPACE) 

Parameters

$name
$default

validateName()

validateName(  $name) 

Parameters

$name

isAbsolutePath()

isAbsolutePath(  $file) 

Parameters

$file