class loader extends FilesystemLoader

Twig Template loader

Properties

protected $safe_directories

Methods

__construct(string|array $paths = array())

Constructor

FilesystemLoader
setSafeDirectories(array $directories = array())

Set safe directories

FilesystemLoader
addSafeDirectory(string $directory)

Add safe directory

array
getSafeDirectories()

Get current safe directories

validateName($name)

Override for parent::validateName()

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

Adds a realpath call to fix a BC break in Twig 1.26 (https://github.com/twigphp/Twig/issues/2145)

findTemplate($name, $throw = true)

Find the template

Details

at line 30
__construct(string|array $paths = array())

Constructor

Parameters

string|array $paths

at line 41
FilesystemLoader setSafeDirectories(array $directories = array())

Set safe directories

Parameters

array $directories

Array of directories that are safe (empty to clear)

Return Value

FilesystemLoader

at line 62
FilesystemLoader addSafeDirectory(string $directory)

Add safe directory

Parameters

string $directory

Directory that should be added

Return Value

FilesystemLoader

at line 79
array getSafeDirectories()

Get current safe directories

Return Value

array

at line 92
protected validateName($name)

Override for parent::validateName()

This is done because we added support for safe directories, and when Twig findTemplate() is called, validateName() is called first, which would always throw an exception if the file is outside of the configured template directories.

Parameters

$name

at line 102
void addPath($path, $namespace = self::MAIN_NAMESPACE)

Adds a realpath call to fix a BC break in Twig 1.26 (https://github.com/twigphp/Twig/issues/2145)

{@inheritdoc}

Parameters

$path
$namespace

Return Value

void

at line 113
protected findTemplate($name, $throw = true)

Find the template

Override for \Twig\Loader\FilesystemLoader::findTemplate to add support for loading from safe directories.

Parameters

$name
$throw