W3cubDocs

/Symfony 4.1

TemplateLocator

class TemplateLocator implements FileLocatorInterface

TemplateLocator locates templates in bundles.

Properties

protected $locator
protected $cache

Methods

__construct(FileLocatorInterface $locator, string $cacheDir = null)
string getCacheKey($template)

Returns a full path for a given file.

string|array locate(TemplateReferenceInterface $template, string|null $currentPath = null, bool $first = true)

Returns a full path for a given file.

Details

__construct(FileLocatorInterface $locator, string $cacheDir = null)

Parameters

FileLocatorInterface $locator A FileLocatorInterface instance
string $cacheDir The cache path

protected string getCacheKey($template)

Returns a full path for a given file.

Parameters

$template

Return Value

string The full path for the file

string|array locate(TemplateReferenceInterface $template, string|null $currentPath = null, bool $first = true)

Returns a full path for a given file.

Parameters

TemplateReferenceInterface $template A template
string|null $currentPath The current path
bool $first Whether to return the first occurrence or an array of filenames

Return Value

string|array The full path to the file or an array of file paths

Exceptions

InvalidArgumentException When the template is not an instance of TemplateReferenceInterface
InvalidArgumentException When the template file can not be found

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