Twig API
Class

Twig_Loader_Filesystem

class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderInterface

Loads template from the filesystem.

Methods

__construct(string|array $paths)

Constructor.

array getPaths(string $namespace = '__main__')

Returns the paths to the templates.

array getNamespaces()

Returns the path namespaces.

setPaths(string|array $paths, string $namespace = '__main__')

Sets the paths where templates are stored.

addPath(string $path, string $namespace = '__main__')

Adds a path where templates are stored.

prependPath(string $path, string $namespace = '__main__')

Prepends a path where templates are stored.

string getSource(string $name)

Gets the source code of a template, given its name.

string getCacheKey(string $name)

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

boolean exists(string $name)

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

Boolean isFresh(string $name, timestamp $time)

Returns true if the template is still fresh.

Details

at line 27
public __construct(string|array $paths)

Constructor.

Parameters

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

at line 39
public array getPaths(string $namespace = '__main__')

Returns the paths to the templates.

Parameters

string $namespace A path namespace

Return Value

array The array of paths where to look for templates

at line 51
public array getNamespaces()

Returns the path namespaces.

The "__main__" namespace is always defined.

Return Value

array The array of defined namespaces

at line 62
public setPaths(string|array $paths, string $namespace = '__main__')

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

at line 82
public addPath(string $path, string $namespace = '__main__')

Adds a path where templates are stored.

Parameters

string $path A path where to look for templates
string $namespace A path name

Exceptions

Twig_Error_Loader

at line 102
public prependPath(string $path, string $namespace = '__main__')

Prepends a path where templates are stored.

Parameters

string $path A path where to look for templates
string $namespace A path name

Exceptions

Twig_Error_Loader

at line 123
public string getSource(string $name)

Gets the source code of a template, given its name.

Parameters

string $name The name of the template to load

Return Value

string The template source code

Exceptions

Twig_Error_Loader When $name is not found

at line 131
public string getCacheKey(string $name)

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

Parameters

string $name The name of the template to load

Return Value

string The cache key

Exceptions

Twig_Error_Loader When $name is not found

at line 139
public boolean exists(string $name)

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

Return Value

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

at line 158
public Boolean isFresh(string $name, timestamp $time)

Returns true if the template is still fresh.

Parameters

string $name The template name
timestamp $time The last modification time of the cached template

Return Value

Boolean true if the template is fresh, false otherwise

Exceptions

Twig_Error_Loader When $name is not found