PHP Class Neos\FluidAdaptor\View\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 TypoScript configuration when given a package name, and is aware of the Frontend/Backend contexts of TYPO3.
Inheritance: extends TYPO3Fluid\Fluid\View\TemplatePaths
Show file Open project: neos/flow-development-collection

Protected Properties

Property Type Description
$layoutRootPathPattern string
$options array
$packageManager Neos\Flow\Package\PackageManagerInterface
$partialRootPathPattern string
$patternReplacementVariables string[] A map of key => values to be replaced in path patterns.
$templateRootPathPattern string

Public Methods

Method Description
__construct ( array $options = [] )
getLayoutPathAndFilename ( string $layoutName = 'Default' ) : string Resolve the path and file name of the layout file, based on $this->options['layoutPathAndFilename'] and $this->options['layoutPathAndFilenamePattern'].
getLayoutRootPaths ( ) : array
getOption ( string $optionName ) : mixed Get a specific option of this object
getPartialPathAndFilename ( string $partialName ) : string Resolve the partial path and filename based on $this->options['partialPathAndFilenamePattern'].
getPartialRootPaths ( )
getPatternReplacementVariables ( ) : string[]
getTemplateRootPathPattern ( ) : string
getTemplateRootPaths ( ) : array Resolves the template root to be used inside other paths.
injectPackageManager ( Neos\Flow\Package\PackageManagerInterface $packageManager )
resolveTemplateFileForControllerAndActionAndFormat ( string $controller, string $action, string $format = null ) : mixed | string Resolves a template file based on the given controller and action, together with eventually defined patternReplacementVariables.
setLayoutRootPath ( string $layoutRootPath )
setLayoutRootPathPattern ( string $layoutRootPathPattern )
setOption ( string $optionName, mixed $value ) : void Set a specific option of this object
setPartialRootPath ( string $partialRootPath )
setPartialRootPathPattern ( string $partialRootPathPattern )
setPatternReplacementVariables ( string[] $patternReplacementVariables )
setTemplateRootPath ( string $templateRootPath )
setTemplateRootPathPattern ( string $templateRootPathPattern )

Protected Methods

Method Description
createIdentifierForFile ( string $pathAndFilename, string $prefix ) : string Returns a unique identifier for the given file in the format ____ The SH1 hash is a checksum that is based on the file path and last modification date
expandGenericPathPattern ( string $pattern, array $patternReplacementVariables, boolean $bubbleControllerAndSubpackage, boolean $formatIsOptional ) : array Processes following placeholders inside $pattern: - "@templateRoot" - "@partialRoot" - "@layoutRoot" - "@subpackage" - "@controller" - "@format"
expandPatterns ( array $patterns, string $search, array $replacements ) : void Expands the given $patterns by adding an array element for each $replacement replacing occurrences of $search.
expandSubPackageAndController ( array $paths, string $controllerName, null $subPackageKey = null, boolean $bubbleControllerAndSubpackage = false ) : array
getPackagePath ( string $packageName ) : string
getPackagePrivateResourcesPath ( string $packageKey ) : string | null
replacePatternVariable ( array $paths, string $variableName, string $variableValue ) : array
sanitizePath ( string $path ) : string Sanitize a path, ensuring it is absolute and if a directory, suffixed by a trailing slash.

Method Details

__construct() public method

public __construct ( array $options = [] )
$options array

createIdentifierForFile() protected method

Returns a unique identifier for the given file in the format ____ The SH1 hash is a checksum that is based on the file path and last modification date
protected createIdentifierForFile ( string $pathAndFilename, string $prefix ) : string
$pathAndFilename string
$prefix string
return string

expandGenericPathPattern() protected method

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 expandGenericPathPattern ( string $pattern, array $patternReplacementVariables, boolean $bubbleControllerAndSubpackage, boolean $formatIsOptional ) : array
$pattern string Pattern to be resolved
$patternReplacementVariables array The variables to replace in the pattern
$bubbleControllerAndSubpackage boolean if TRUE, then we successively split off parts from "@controller" and "@subpackage" until both are empty.
$formatIsOptional boolean if TRUE, then half of the resulting strings will have ."@format" stripped off, and the other half will have it.
return array unix style paths

expandPatterns() protected method

Expands the given $patterns by adding an array element for each $replacement replacing occurrences of $search.
protected expandPatterns ( array $patterns, string $search, array $replacements ) : void
$patterns array
$search string
$replacements array
return void

expandSubPackageAndController() protected method

protected expandSubPackageAndController ( array $paths, string $controllerName, null $subPackageKey = null, boolean $bubbleControllerAndSubpackage = false ) : array
$paths array
$controllerName string
$subPackageKey null
$bubbleControllerAndSubpackage boolean
return array

getLayoutPathAndFilename() public method

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.
public getLayoutPathAndFilename ( string $layoutName = 'Default' ) : string
$layoutName string Name of the layout to use. If none given, use "Default"
return string Path and filename of layout files

getLayoutRootPaths() public method

public getLayoutRootPaths ( ) : array
return array

getOption() public method

Get a specific option of this object
public getOption ( string $optionName ) : mixed
$optionName string
return mixed

getPackagePath() protected method

protected getPackagePath ( string $packageName ) : string
$packageName string
return string

getPackagePrivateResourcesPath() protected method

protected getPackagePrivateResourcesPath ( string $packageKey ) : string | null
$packageKey string
return string | null

getPartialPathAndFilename() public method

Resolve the partial path and filename based on $this->options['partialPathAndFilenamePattern'].
public getPartialPathAndFilename ( string $partialName ) : string
$partialName string The name of the partial
return string the full path which should be used. The path definitely exists.

getPartialRootPaths() public method

public getPartialRootPaths ( )

getPatternReplacementVariables() public method

public getPatternReplacementVariables ( ) : string[]
return string[]

getTemplateRootPathPattern() public method

getTemplateRootPaths() public method

Resolves the template root to be used inside other paths.
public getTemplateRootPaths ( ) : array
return array Path(s) to template root directory

injectPackageManager() public method

public injectPackageManager ( Neos\Flow\Package\PackageManagerInterface $packageManager )
$packageManager Neos\Flow\Package\PackageManagerInterface

replacePatternVariable() protected method

protected replacePatternVariable ( array $paths, string $variableName, string $variableValue ) : array
$paths array
$variableName string
$variableValue string
return array

resolveTemplateFileForControllerAndActionAndFormat() public method

Resolves a template file based on the given controller and action, together with eventually defined patternReplacementVariables.
public resolveTemplateFileForControllerAndActionAndFormat ( string $controller, string $action, string $format = null ) : mixed | string
$controller string
$action string
$format string
return mixed | string

sanitizePath() protected method

Sanitize a path, ensuring it is absolute and if a directory, suffixed by a trailing slash.
protected sanitizePath ( string $path ) : string
$path string
return string

setLayoutRootPath() public method

public setLayoutRootPath ( string $layoutRootPath )
$layoutRootPath string

setLayoutRootPathPattern() public method

public setLayoutRootPathPattern ( string $layoutRootPathPattern )
$layoutRootPathPattern string

setOption() public method

Set a specific option of this object
public setOption ( string $optionName, mixed $value ) : void
$optionName string
$value mixed
return void

setPartialRootPath() public method

public setPartialRootPath ( string $partialRootPath )
$partialRootPath string

setPartialRootPathPattern() public method

public setPartialRootPathPattern ( string $partialRootPathPattern )
$partialRootPathPattern string

setPatternReplacementVariables() public method

public setPatternReplacementVariables ( string[] $patternReplacementVariables )
$patternReplacementVariables string[]

setTemplateRootPath() public method

public setTemplateRootPath ( string $templateRootPath )
$templateRootPath string

setTemplateRootPathPattern() public method

public setTemplateRootPathPattern ( string $templateRootPathPattern )
$templateRootPathPattern string

Property Details

$layoutRootPathPattern protected property

protected string $layoutRootPathPattern
return string

$options protected property

protected array $options
return array

$packageManager protected property

protected PackageManagerInterface,Neos\Flow\Package $packageManager
return Neos\Flow\Package\PackageManagerInterface

$partialRootPathPattern protected property

protected string $partialRootPathPattern
return string

$patternReplacementVariables protected property

A map of key => values to be replaced in path patterns.
protected string[] $patternReplacementVariables
return string[]

$templateRootPathPattern protected property

protected string $templateRootPathPattern
return string