Neos\FluidAdaptor\View\TemplatePaths::expandGenericPathPattern PHP Method

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
    protected function expandGenericPathPattern($pattern, array $patternReplacementVariables, $bubbleControllerAndSubpackage, $formatIsOptional)
    {
        $paths = [$pattern];
        $paths = $this->expandPatterns($paths, '@templateRoot', isset($patternReplacementVariables['templateRoot']) ? [$patternReplacementVariables['templateRoot']] : $this->getTemplateRootPaths());
        $paths = $this->expandPatterns($paths, '@partialRoot', isset($patternReplacementVariables['partialRoot']) ? [$patternReplacementVariables['partialRoot']] : $this->getPartialRootPaths());
        $paths = $this->expandPatterns($paths, '@layoutRoot', isset($patternReplacementVariables['layoutRoot']) ? [$patternReplacementVariables['layoutRoot']] : $this->getLayoutRootPaths());
        $subPackageKey = isset($patternReplacementVariables['subPackageKey']) ? $patternReplacementVariables['subPackageKey'] : '';
        $controllerName = isset($patternReplacementVariables['controllerName']) ? $patternReplacementVariables['controllerName'] : '';
        $format = isset($patternReplacementVariables['format']) ? $patternReplacementVariables['format'] : '';
        unset($patternReplacementVariables['subPackageKey']);
        unset($patternReplacementVariables['controllerName']);
        unset($patternReplacementVariables['format']);
        $paths = $this->expandSubPackageAndController($paths, $controllerName, $subPackageKey, $bubbleControllerAndSubpackage);
        if ($formatIsOptional) {
            $paths = $this->expandPatterns($paths, '.@format', ['.' . $format, '']);
            $paths = $this->expandPatterns($paths, '@format', [$format, '']);
        } else {
            $paths = $this->expandPatterns($paths, '.@format', ['.' . $format]);
            $paths = $this->expandPatterns($paths, '@format', [$format]);
        }
        foreach ($patternReplacementVariables as $variableName => $variableValue) {
            $paths = $this->replacePatternVariable($paths, $variableName, $variableValue);
        }
        return array_values(array_unique($paths));
    }