TemplatePaths
class TemplatePaths extends TemplatePaths (View source)
Class TemplatePaths
Custom implementation for template paths resolving, one which differs from the base implementation in that it is capable of resolving template paths based on Fusion configuration when given a package name, and is aware of the Frontend/Backend contexts of TYPO3.
Properties
protected string | $templateRootPathPattern | ||
protected string | $layoutRootPathPattern | ||
protected string | $partialRootPathPattern | ||
protected string[] | $patternReplacementVariables | A map of key => values to be replaced in path patterns. |
|
protected array | $options | ||
protected PackageManager | $packageManager |
Methods
No description
No description
No description
No description
No description
No description
Resolves the template root to be used inside other paths.
No description
No description
No description
No description
No description
No description
Resolves a template file based on the given controller and action, together with eventually defined patternReplacementVariables.
Resolve the path and file name of the layout file, based on $this->options['layoutPathAndFilename'] and $this->options['layoutPathAndFilenamePattern'].
Resolve the partial path and filename based on $this->options['partialPathAndFilenamePattern'].
No description
Sanitize a path, ensuring it is absolute and if a directory, suffixed by a trailing slash.
No description
Processes following placeholders inside $pattern:
- "@templateRoot"
- "@partialRoot"
- "@layoutRoot"
- "@subpackage"
- "@controller"
- "@format"
No description
No description
Expands the given $patterns by adding an array element for each $replacement replacing occurrences of $search.
Get a specific option of this object
Set a specific option of this object
Returns a unique identifier for the given file in the format
Details
__construct(array $options = [])
No description
injectPackageManager(PackageManager $packageManager)
No description
string
getTemplateRootPathPattern()
No description
setTemplateRootPathPattern(string $templateRootPathPattern)
No description
setLayoutRootPathPattern(string $layoutRootPathPattern)
No description
setPartialRootPathPattern(string $partialRootPathPattern)
No description
setTemplateRootPath(string $templateRootPath)
No description
array
getTemplateRootPaths()
Resolves the template root to be used inside other paths.
array
getLayoutRootPaths()
No description
getPartialRootPaths()
No description
setLayoutRootPath(string $layoutRootPath)
No description
setPartialRootPath(string $partialRootPath)
No description
string[]
getPatternReplacementVariables()
No description
setPatternReplacementVariables(string[] $patternReplacementVariables)
No description
mixed|string
resolveTemplateFileForControllerAndActionAndFormat(string $controller, string $action, string $format = null)
Resolves a template file based on the given controller and action, together with eventually defined patternReplacementVariables.
string
getLayoutPathAndFilename(string $layoutName = 'Default')
Resolve the path and file name of the layout file, based on $this->options['layoutPathAndFilename'] and $this->options['layoutPathAndFilenamePattern'].
In case a layout has already been set with setLayoutPathAndFilename(), this method returns that path, otherwise a path and filename will be resolved using the layoutPathAndFilenamePattern.
string
getPartialPathAndFilename(string $partialName)
Resolve the partial path and filename based on $this->options['partialPathAndFilenamePattern'].
protected string
getPackagePath(string $packageName)
No description
protected string
sanitizePath(string $path)
Sanitize a path, ensuring it is absolute and if a directory, suffixed by a trailing slash.
protected string|null
getPackagePrivateResourcesPath(string $packageKey)
No description
protected array
expandGenericPathPattern(string $pattern, array $patternReplacementVariables, bool $bubbleControllerAndSubpackage, bool $formatIsOptional)
Processes following placeholders inside $pattern:
- "@templateRoot"
- "@partialRoot"
- "@layoutRoot"
- "@subpackage"
- "@controller"
- "@format"
This method is used to generate "fallback chains" for file system locations where a certain Partial can reside.
If $bubbleControllerAndSubpackage is false and $formatIsOptional is false, then the resulting array will only have one element with all the above placeholders replaced.
If you set $bubbleControllerAndSubpackage to true, then you will get an array with potentially many elements: The first element of the array is like above. The second element has the @ controller part set to "" (the empty string) The third element now has the @ controller part again stripped off, and has the last subpackage part stripped off as well. This continues until both "@subpackage" and "@controller" are empty.
Example for $bubbleControllerAndSubpackage is true, we have the MyCompany\MyPackage\MySubPackage\Controller\MyController as Controller Object Name and the current format is "html"
If pattern is "@templateRoot/@subpackage/@controller/@action.@format", then the resulting array is:
- "Resources/Private/Templates/MySubPackage/My/@action.html"
- "Resources/Private/Templates/MySubPackage/@action.html"
- "Resources/Private/Templates/@action.html"
If you set $formatIsOptional to true, then for any of the above arrays, every element will be duplicated - once with "@format" replaced by the current request format, and once with ."@format" stripped off.
protected array
replacePatternVariable(array $paths, string $variableName, string $variableValue)
No description
protected array
expandSubPackageAndController(array $paths, string $controllerName, string $subPackageKey = '', bool $bubbleControllerAndSubpackage = false)
No description
protected array
expandPatterns(array $patterns, string $search, array $replacements)
Expands the given $patterns by adding an array element for each $replacement replacing occurrences of $search.
mixed
getOption(string $optionName)
Get a specific option of this object
void
setOption(string $optionName, mixed $value)
Set a specific option of this object
protected string
createIdentifierForFile(string|null $pathAndFilename, string $prefix)
Returns a unique identifier for the given file in the format