W3cubDocs

/Symfony 4.1

FilesystemLoader

class FilesystemLoader extends FilesystemLoader

FilesystemLoader extends the default Twig filesystem loader to work with the Symfony paths and template references.

Properties

protected $locator
protected $parser

Methods

__construct(FileLocatorInterface $locator, TemplateNameParserInterface $parser, string $rootPath = null)
exists($name)

{@inheritdoc}

string findTemplate(string|TemplateReferenceInterface $template, bool $throw = true)

Returns the path to the template file.

Details

__construct(FileLocatorInterface $locator, TemplateNameParserInterface $parser, string $rootPath = null)

Parameters

FileLocatorInterface $locator
TemplateNameParserInterface $parser
string $rootPath

exists($name)

{@inheritdoc}

The name parameter might also be a TemplateReferenceInterface.

Parameters

$name

protected string findTemplate(string|TemplateReferenceInterface $template, bool $throw = true)

Returns the path to the template file.

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

string|TemplateReferenceInterface $template The template
bool $throw When true, a LoaderError exception will be thrown if a template could not be found

Return Value

string The path to the template file

Exceptions

LoaderError if the template could not be found

© 2004–2017 Fabien Potencier
Licensed under the MIT License.
https://api.symfony.com/4.1/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.html