PHP Класс FluidTYPO3\Flux\View\TemplatePaths

Class used to hold and resolve template files and paths in multiple supported ways. The purpose of this class is to homogenise the API that is used when working with template paths coming from TypoScript, as well as serve as a way to quickly generate default template-, layout- and partial root paths by package. The constructor accepts two different types of input - anything not of those types is silently ignored: - a string input is assumed a package name and will call the fillDefaultsByPackageName value filling method. - an array input is assumed a TypoScript-style array of root paths in one or more of the supported structures and will call the fillFromTypoScriptArray method. Either method can also be called after instance is created, but both will overwrite any paths you have previously configured.
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$layoutRootPaths array
$partialRootPaths array
$templateRootPaths array

Открытые методы

Метод Описание
__construct ( string | null $packageOrPaths = NULL )
fillDefaultsByPackageName ( string $packageName ) : void Fills path arrays with default expected paths based on package name (converted to extension key automatically).
fillFromTypoScriptArray ( array $paths ) : void Fills path arrays based on a traditional TypoScript array which may contain one or more of the supported structures, in order of priority:
getLayoutRootPaths ( ) : array
getPartialRootPaths ( ) : array
getTemplateRootPaths ( ) : array
resolveAvailableLayoutFiles ( string $format = self::DEFAULT_FORMAT ) : array
resolveAvailablePartialFiles ( string $format = self::DEFAULT_FORMAT ) : array
resolveAvailableTemplateFiles ( string $controllerName, string $format = self::DEFAULT_FORMAT ) : array
resolveTemplateFileForControllerAndActionAndFormat ( string $controller, string $action, string $format = self::DEFAULT_FORMAT ) : string | null Attempts to resolve an absolute filename of a template (i.e. templateRootPaths) using a controller name, action and format.
setLayoutRootPaths ( array $layoutRootPaths ) : void
setPartialRootPaths ( array $partialRootPaths ) : void
setTemplateRootPaths ( array $templateRootPaths ) : void
toArray ( ) : array

Защищенные методы

Метод Описание
ensureAbsolutePath ( mixed $reference ) : mixed Guarantees that $reference is turned into a correct, absolute path. The input can be a relative path or a FILE: or EXT: reference but cannot be a FAL resource identifier.
extractPathArrays ( array $paths ) : array Extract an array of three arrays of paths, one for each of the types of Fluid file resources.
resolveFilesInFolders ( array $folders, string $format ) : array

Описание методов

__construct() публичный Метод

public __construct ( string | null $packageOrPaths = NULL )
$packageOrPaths string | null

ensureAbsolutePath() защищенный Метод

Guarantees that $reference is turned into a correct, absolute path. The input can be a relative path or a FILE: or EXT: reference but cannot be a FAL resource identifier.
protected ensureAbsolutePath ( mixed $reference ) : mixed
$reference mixed
Результат mixed

extractPathArrays() защищенный Метод

Accepts one or both of the singular and plural path definitions in the input - returns the combined collections of paths based on both the singular and plural entries with the singular entries being recorded first and plurals second. Sorts the passed paths by index in array, in reverse, so that the base View class will iterate the array in the right order when resolving files. Adds legacy singular name as last option, if set.
protected extractPathArrays ( array $paths ) : array
$paths array
Результат array

fillDefaultsByPackageName() публичный Метод

Will replace any currently configured paths.
public fillDefaultsByPackageName ( string $packageName ) : void
$packageName string
Результат void

fillFromTypoScriptArray() публичный Метод

- plugin.tx_yourext.view.templateRootPath and siblings. - plugin.tx_yourext.view.templateRootPaths and siblings. - plugin.tx_yourext.view.overlays.otherextension.templateRootPath and siblings. The paths are treated as follows, using the template-type paths as an example: - If templateRootPath is defined, it gets used as the _first_ path in the internal paths array. - If templateRootPaths is defined, all values from it are _appended_ to the internal paths array. - If overlays.* exists in the array it is iterated, each templateRootPath entry from it _appended_ to the internal array. The result is that after filling, the path arrays will contain one or more entries in the order described above, depending on how many of the possible configurations were present in the input array. Will replace any currently configured paths.
public fillFromTypoScriptArray ( array $paths ) : void
$paths array
Результат void

getLayoutRootPaths() публичный Метод

public getLayoutRootPaths ( ) : array
Результат array

getPartialRootPaths() публичный Метод

public getPartialRootPaths ( ) : array
Результат array

getTemplateRootPaths() публичный Метод

public getTemplateRootPaths ( ) : array
Результат array

resolveAvailableLayoutFiles() публичный Метод

public resolveAvailableLayoutFiles ( string $format = self::DEFAULT_FORMAT ) : array
$format string
Результат array

resolveAvailablePartialFiles() публичный Метод

public resolveAvailablePartialFiles ( string $format = self::DEFAULT_FORMAT ) : array
$format string
Результат array

resolveAvailableTemplateFiles() публичный Метод

public resolveAvailableTemplateFiles ( string $controllerName, string $format = self::DEFAULT_FORMAT ) : array
$controllerName string
$format string
Результат array

resolveFilesInFolders() защищенный Метод

protected resolveFilesInFolders ( array $folders, string $format ) : array
$folders array
$format string
Результат array

resolveTemplateFileForControllerAndActionAndFormat() публичный Метод

Works _backwards_ through template paths in order to achieve an "overlay"-type behavior where the last paths added are the first to be checked and the first path added acts as fallback if no other paths have the file. If the file does not exist in any path, including fallback path, NULL is returned. Path configurations filled from TypoScript is automatically recorded in the right order (see fillFromTypoScriptArray), but when manually setting the paths that should be checked, you as user must be aware of this reverse behavior (which you should already be, given that it is the same way TypoScript path configurations work).
public resolveTemplateFileForControllerAndActionAndFormat ( string $controller, string $action, string $format = self::DEFAULT_FORMAT ) : string | null
$controller string
$action string
$format string
Результат string | null

setLayoutRootPaths() публичный Метод

public setLayoutRootPaths ( array $layoutRootPaths ) : void
$layoutRootPaths array
Результат void

setPartialRootPaths() публичный Метод

public setPartialRootPaths ( array $partialRootPaths ) : void
$partialRootPaths array
Результат void

setTemplateRootPaths() публичный Метод

public setTemplateRootPaths ( array $templateRootPaths ) : void
$templateRootPaths array
Результат void

toArray() публичный Метод

public toArray ( ) : array
Результат array

Описание свойств

$layoutRootPaths защищенное свойство

protected array $layoutRootPaths
Результат array

$partialRootPaths защищенное свойство

protected array $partialRootPaths
Результат array

$templateRootPaths защищенное свойство

protected array $templateRootPaths
Результат array