FluidTYPO3\Flux\View\TemplatePaths::resolveTemplateFileForControllerAndActionAndFormat PHP Method

resolveTemplateFileForControllerAndActionAndFormat() public method

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
return string | null
    public function resolveTemplateFileForControllerAndActionAndFormat($controller, $action, $format = self::DEFAULT_FORMAT)
    {
        $action = ucfirst($action);
        foreach ($this->getTemplateRootPaths() as $templateRootPath) {
            $candidate = $templateRootPath . $controller . '/' . $action . '.' . $format;
            $candidate = $this->ensureAbsolutePath($candidate);
            if (TRUE === file_exists($candidate)) {
                return $candidate;
            }
        }
        return NULL;
    }

Usage Example

Beispiel #1
0
 public function testResolveTemplateFileForControllerAndActionAndFormatReturnsNullIfNotFound()
 {
     $instance = new TemplatePaths(array('templateRootPaths' => array('EXT:flux/Does/Not/Exist/'), 'layoutRootPaths' => array('EXT:flux/Does/Not/Exist/'), 'partialRootPaths' => array('EXT:flux/Does/Not/Exist/')));
     // note: this is slight abuse of the method: we aim at the Fixtures directory
     // itself and emulate a controller called "Templates" to make TemplatePaths
     // look in the Fixtures/Templates folder.
     $result = $instance->resolveTemplateFileForControllerAndActionAndFormat('Templates', 'AbsolutelyMinimal');
     $this->assertNull($result);
 }
All Usage Examples Of FluidTYPO3\Flux\View\TemplatePaths::resolveTemplateFileForControllerAndActionAndFormat