first commit
This commit is contained in:
commit
1218dd1517
12716 files changed
+989233
No files matched your search
@@ -0,0 +1,169 @@
|
||||
<?php
|
||||
namespace TYPO3\CMS\Fluid\View;
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Extbase\Object\ObjectManager;
|
||||
use TYPO3\CMS\Fluid\Core\Rendering\RenderingContext;
|
||||
use TYPO3\CMS\Fluid\View\Exception\InvalidTemplateResourceException;
|
||||
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
|
||||
use TYPO3Fluid\Fluid\View\TemplateView;
|
||||
|
||||
/**
|
||||
* Abstract Fluid Template View.
|
||||
*
|
||||
* Contains the fundamental methods which any Fluid based template view needs.
|
||||
*/
|
||||
abstract class AbstractTemplateView extends TemplateView implements \TYPO3\CMS\Extbase\Mvc\View\ViewInterface
|
||||
{
|
||||
/**
|
||||
* @var \TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext
|
||||
*/
|
||||
protected $controllerContext;
|
||||
|
||||
/**
|
||||
* Initializes this view.
|
||||
*/
|
||||
public function initializeView()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param RenderingContextInterface $context
|
||||
* @internal
|
||||
*/
|
||||
public function __construct(RenderingContextInterface $context = null)
|
||||
{
|
||||
if (!$context) {
|
||||
$context = GeneralUtility::makeInstance(ObjectManager::class)->get(RenderingContext::class, $this);
|
||||
}
|
||||
parent::__construct($context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells if the view implementation can render the view for the given context.
|
||||
*
|
||||
* By default we assume that the view implementation can handle all kinds of
|
||||
* contexts. Override this method if that is not the case.
|
||||
*
|
||||
* @param \TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext $controllerContext Controller context which is available inside the view
|
||||
* @return bool TRUE if the view has something useful to display, otherwise FALSE
|
||||
*/
|
||||
public function canRender(\TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext $controllerContext)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the current controller context
|
||||
*
|
||||
* @param \TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext $controllerContext
|
||||
* @internal
|
||||
*/
|
||||
public function setControllerContext(\TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext $controllerContext)
|
||||
{
|
||||
$request = $controllerContext->getRequest();
|
||||
$this->controllerContext = $controllerContext;
|
||||
$this->baseRenderingContext->getTemplatePaths()->fillDefaultsByPackageName($request->getControllerExtensionKey());
|
||||
$this->baseRenderingContext->getTemplatePaths()->setFormat($request->getFormat());
|
||||
if ($this->baseRenderingContext instanceof RenderingContext) {
|
||||
$this->baseRenderingContext->setControllerContext($controllerContext);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $templateName
|
||||
* @internal
|
||||
*/
|
||||
public function setTemplate($templateName)
|
||||
{
|
||||
$this->baseRenderingContext->setControllerAction($templateName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the path and name of of the template file. Effectively overrides the
|
||||
* dynamic resolving of a template file.
|
||||
*
|
||||
* @param string $templatePathAndFilename Template file path
|
||||
*/
|
||||
public function setTemplatePathAndFilename($templatePathAndFilename)
|
||||
{
|
||||
$this->baseRenderingContext->getTemplatePaths()->setTemplatePathAndFilename($templatePathAndFilename);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the root path(s) to the templates.
|
||||
* If set, overrides the one determined from $this->templateRootPathPattern
|
||||
*
|
||||
* @param string[] $templateRootPaths Root path(s) to the templates. If set, overrides the one determined from $this->templateRootPathPattern
|
||||
*/
|
||||
public function setTemplateRootPaths(array $templateRootPaths)
|
||||
{
|
||||
$this->baseRenderingContext->getTemplatePaths()->setTemplateRootPaths($templateRootPaths);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves the template root to be used inside other paths.
|
||||
*
|
||||
* @return string[] Path(s) to template root directory
|
||||
*/
|
||||
public function getTemplateRootPaths()
|
||||
{
|
||||
return $this->baseRenderingContext->getTemplatePaths()->getTemplateRootPaths();
|
||||
}
|
||||
/**
|
||||
* Set the root path(s) to the partials.
|
||||
* If set, overrides the one determined from $this->partialRootPathPattern
|
||||
*
|
||||
* @param string[] $partialRootPaths Root paths to the partials. If set, overrides the one determined from $this->partialRootPathPattern
|
||||
*/
|
||||
public function setPartialRootPaths(array $partialRootPaths)
|
||||
{
|
||||
$this->baseRenderingContext->getTemplatePaths()->setPartialRootPaths($partialRootPaths);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the absolute path to the folder that contains Fluid partial files
|
||||
*
|
||||
* @return string[] Fluid partial root paths
|
||||
* @throws InvalidTemplateResourceException
|
||||
*/
|
||||
public function getPartialRootPaths()
|
||||
{
|
||||
return $this->baseRenderingContext->getTemplatePaths()->getPartialRootPaths();
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves the layout root to be used inside other paths.
|
||||
*
|
||||
* @return string[] Fluid layout root paths
|
||||
* @throws InvalidTemplateResourceException
|
||||
*/
|
||||
public function getLayoutRootPaths()
|
||||
{
|
||||
return $this->baseRenderingContext->getTemplatePaths()->getLayoutRootPaths();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the root path(s) to the layouts.
|
||||
* If set, overrides the one determined from $this->layoutRootPathPattern
|
||||
*
|
||||
* @param string[] $layoutRootPaths Root path to the layouts. If set, overrides the one determined from $this->layoutRootPathPattern
|
||||
*/
|
||||
public function setLayoutRootPaths(array $layoutRootPaths)
|
||||
{
|
||||
$this->baseRenderingContext->getTemplatePaths()->setLayoutRootPaths($layoutRootPaths);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,165 @@
|
||||
<?php
|
||||
namespace TYPO3\CMS\Fluid\View;
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
|
||||
use TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext;
|
||||
use TYPO3\CMS\Extbase\Mvc\Web\Request as WebRequest;
|
||||
use TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder;
|
||||
use TYPO3\CMS\Extbase\Object\ObjectManager;
|
||||
use TYPO3\CMS\Fluid\Core\Rendering\RenderingContext;
|
||||
use TYPO3\CMS\Fluid\View\Exception\InvalidTemplateResourceException;
|
||||
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
|
||||
|
||||
/**
|
||||
* A standalone template view.
|
||||
* Should be used as view if you want to use Fluid without Extbase extensions
|
||||
*/
|
||||
class StandaloneView extends AbstractTemplateView
|
||||
{
|
||||
/**
|
||||
* @var ObjectManager|null
|
||||
*/
|
||||
protected $objectManager;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param ContentObjectRenderer $contentObject The current cObject. If NULL a new instance will be created
|
||||
* @throws \InvalidArgumentException
|
||||
* @throws \UnexpectedValueException
|
||||
*/
|
||||
public function __construct(ContentObjectRenderer $contentObject = null)
|
||||
{
|
||||
$this->objectManager = GeneralUtility::makeInstance(ObjectManager::class);
|
||||
|
||||
/** @var ConfigurationManagerInterface $configurationManager */
|
||||
$configurationManager = $this->objectManager->get(ConfigurationManagerInterface::class);
|
||||
if ($contentObject === null) {
|
||||
/** @var ContentObjectRenderer $contentObject */
|
||||
$contentObject = GeneralUtility::makeInstance(ContentObjectRenderer::class);
|
||||
}
|
||||
$configurationManager->setContentObject($contentObject);
|
||||
|
||||
/** @var WebRequest $request */
|
||||
$request = $this->objectManager->get(WebRequest::class);
|
||||
$request->setRequestUri(GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'));
|
||||
$request->setBaseUri(GeneralUtility::getIndpEnv('TYPO3_SITE_URL'));
|
||||
/** @var UriBuilder $uriBuilder */
|
||||
$uriBuilder = $this->objectManager->get(UriBuilder::class);
|
||||
$uriBuilder->setRequest($request);
|
||||
/** @var ControllerContext $controllerContext */
|
||||
$controllerContext = $this->objectManager->get(ControllerContext::class);
|
||||
$controllerContext->setRequest($request);
|
||||
$controllerContext->setUriBuilder($uriBuilder);
|
||||
$renderingContext = $this->objectManager->get(RenderingContext::class, $this);
|
||||
$renderingContext->setControllerContext($controllerContext);
|
||||
parent::__construct($renderingContext);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the format of the current request (default format is "html")
|
||||
*
|
||||
* @param string $format
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function setFormat($format)
|
||||
{
|
||||
if ($this->baseRenderingContext instanceof RenderingContext) {
|
||||
$this->baseRenderingContext->getControllerContext()->getRequest()->setFormat($format);
|
||||
$this->baseRenderingContext->getTemplatePaths()->setFormat($format);
|
||||
} else {
|
||||
throw new \RuntimeException('The rendering context must be of type ' . RenderingContext::class, 1482251886);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the format of the current request (defaults is "html")
|
||||
*
|
||||
* @return string $format
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function getFormat()
|
||||
{
|
||||
if ($this->baseRenderingContext instanceof RenderingContext) {
|
||||
return $this->baseRenderingContext->getControllerContext()->getRequest()->getFormat();
|
||||
}
|
||||
throw new \RuntimeException('The rendering context must be of type ' . RenderingContext::class, 1482251887);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current request object
|
||||
*
|
||||
* @return WebRequest
|
||||
* @throws \RuntimeException
|
||||
* @internal
|
||||
*/
|
||||
public function getRequest()
|
||||
{
|
||||
if ($this->baseRenderingContext instanceof RenderingContext) {
|
||||
return $this->baseRenderingContext->getControllerContext()->getRequest();
|
||||
}
|
||||
throw new \RuntimeException('The rendering context must be of type ' . RenderingContext::class, 1482251888);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the absolute path to a Fluid template file if it was specified with setTemplatePathAndFilename() before.
|
||||
* If the template filename was never specified, Fluid attempts to resolve the file based on controller and action.
|
||||
*
|
||||
* NB: If TemplatePaths was previously told to use the specific template path and filename it will short-circuit
|
||||
* and return that template path and filename directly, instead of attempting to resolve it.
|
||||
*
|
||||
* @return string Fluid template path
|
||||
*/
|
||||
public function getTemplatePathAndFilename()
|
||||
{
|
||||
$templatePaths = $this->baseRenderingContext->getTemplatePaths();
|
||||
return $templatePaths->resolveTemplateFileForControllerAndActionAndFormat(
|
||||
$this->baseRenderingContext->getControllerName(),
|
||||
$this->baseRenderingContext->getControllerAction(),
|
||||
$templatePaths->getFormat()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Fluid template source
|
||||
* You can use setTemplatePathAndFilename() alternatively if you only want to specify the template path
|
||||
*
|
||||
* @param string $templateSource Fluid template source code
|
||||
*/
|
||||
public function setTemplateSource($templateSource)
|
||||
{
|
||||
$this->baseRenderingContext->getTemplatePaths()->setTemplateSource($templateSource);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether a template can be resolved for the current request
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasTemplate()
|
||||
{
|
||||
try {
|
||||
$this->baseRenderingContext->getTemplatePaths()->getTemplateSource(
|
||||
$this->baseRenderingContext->getControllerName(),
|
||||
$this->baseRenderingContext->getControllerAction()
|
||||
);
|
||||
return true;
|
||||
} catch (InvalidTemplateResourceException $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,223 @@
|
||||
<?php
|
||||
namespace TYPO3\CMS\Fluid\View;
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
use TYPO3\CMS\Core\Utility\ArrayUtility;
|
||||
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Core\Utility\PathUtility;
|
||||
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
|
||||
use TYPO3\CMS\Extbase\Object\ObjectManager;
|
||||
|
||||
/**
|
||||
* 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 TypoScript
|
||||
* configuration when given a package name, and is aware of the Frontend/Backend contexts of TYPO3.
|
||||
*
|
||||
* @internal This is for internal Fluid use only.
|
||||
*/
|
||||
class TemplatePaths extends \TYPO3Fluid\Fluid\View\TemplatePaths
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $templateSource;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $templatePathAndFilename;
|
||||
|
||||
/**
|
||||
* @param string $extensionKey
|
||||
* @return string|null
|
||||
*/
|
||||
protected function getExtensionPrivateResourcesPath($extensionKey)
|
||||
{
|
||||
$extensionKey = trim($extensionKey);
|
||||
if ($extensionKey && ExtensionManagementUtility::isLoaded($extensionKey)) {
|
||||
return ExtensionManagementUtility::extPath($extensionKey) . 'Resources/Private/';
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ConfigurationManagerInterface
|
||||
*/
|
||||
protected function getConfigurationManager()
|
||||
{
|
||||
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
|
||||
$configurationManager = $objectManager->get(ConfigurationManagerInterface::class);
|
||||
return $configurationManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $extensionKey
|
||||
* @return array
|
||||
*/
|
||||
protected function getContextSpecificViewConfiguration($extensionKey)
|
||||
{
|
||||
if (empty($extensionKey)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$resources = $this->getExtensionPrivateResourcesPath($extensionKey);
|
||||
$paths = [
|
||||
self::CONFIG_TEMPLATEROOTPATHS => [$resources . 'Templates/'],
|
||||
self::CONFIG_PARTIALROOTPATHS => [$resources . 'Partials/'],
|
||||
self::CONFIG_LAYOUTROOTPATHS => [$resources . 'Layouts/']
|
||||
];
|
||||
|
||||
$configuredPaths = [];
|
||||
if (!empty($this->templateRootPaths) || !empty($this->partialRootPaths) || !empty($this->layoutRootPaths)) {
|
||||
// The view was configured already
|
||||
$configuredPaths = [
|
||||
self::CONFIG_TEMPLATEROOTPATHS => $this->templateRootPaths,
|
||||
self::CONFIG_PARTIALROOTPATHS => $this->partialRootPaths,
|
||||
self::CONFIG_LAYOUTROOTPATHS => $this->layoutRootPaths,
|
||||
];
|
||||
} else {
|
||||
$typoScript = (array)$this->getConfigurationManager()->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT);
|
||||
$signature = str_replace('_', '', $extensionKey);
|
||||
if ($this->isBackendMode() && isset($typoScript['module.']['tx_' . $signature . '.']['view.'])) {
|
||||
$configuredPaths = (array)$typoScript['module.']['tx_' . $signature . '.']['view.'];
|
||||
$configuredPaths = GeneralUtility::removeDotsFromTS($configuredPaths);
|
||||
} elseif ($this->isFrontendMode() && isset($typoScript['plugin.']['tx_' . $signature . '.']['view.'])) {
|
||||
$configuredPaths = (array)$typoScript['plugin.']['tx_' . $signature . '.']['view.'];
|
||||
$configuredPaths = GeneralUtility::removeDotsFromTS($configuredPaths);
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($configuredPaths)) {
|
||||
return $paths;
|
||||
}
|
||||
|
||||
foreach ($paths as $name => $defaultPaths) {
|
||||
if (!empty($configuredPaths[$name])) {
|
||||
$paths[$name] = array_merge($defaultPaths, ArrayUtility::sortArrayWithIntegerKeys((array)$configuredPaths[$name]));
|
||||
}
|
||||
}
|
||||
|
||||
return $paths;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fills the path arrays with defaults, by package name.
|
||||
* Reads those defaults from TypoScript if possible and
|
||||
* if not defined, uses fallback paths by convention.
|
||||
*
|
||||
* @param string $packageName
|
||||
*/
|
||||
public function fillDefaultsByPackageName($packageName)
|
||||
{
|
||||
$this->fillFromConfigurationArray($this->getContextSpecificViewConfiguration($packageName));
|
||||
}
|
||||
|
||||
/**
|
||||
* Overridden setter with enforced sorting behavior
|
||||
*
|
||||
* @param array $templateRootPaths
|
||||
*/
|
||||
public function setTemplateRootPaths(array $templateRootPaths)
|
||||
{
|
||||
parent::setTemplateRootPaths(
|
||||
ArrayUtility::sortArrayWithIntegerKeys($templateRootPaths)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Overridden setter with enforced sorting behavior
|
||||
*
|
||||
* @param array $layoutRootPaths
|
||||
*/
|
||||
public function setLayoutRootPaths(array $layoutRootPaths)
|
||||
{
|
||||
parent::setLayoutRootPaths(
|
||||
ArrayUtility::sortArrayWithIntegerKeys($layoutRootPaths)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Overridden setter with enforced sorting behavior
|
||||
*
|
||||
* @param array $partialRootPaths
|
||||
*/
|
||||
public function setPartialRootPaths(array $partialRootPaths)
|
||||
{
|
||||
parent::setPartialRootPaths(
|
||||
ArrayUtility::sortArrayWithIntegerKeys($partialRootPaths)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Public API for currently protected method. Can be dropped when switching to
|
||||
* Fluid 1.1.0 or above.
|
||||
*
|
||||
* @param string $partialName
|
||||
* @return string
|
||||
*/
|
||||
public function getPartialPathAndFilename($partialName)
|
||||
{
|
||||
return parent::getPartialPathAndFilename($partialName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get absolute path to template file
|
||||
*
|
||||
* @return string Returns the absolute path to a Fluid template file
|
||||
*/
|
||||
public function getTemplatePathAndFilename()
|
||||
{
|
||||
return $this->templatePathAndFilename;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @param mixed $reference
|
||||
* @return string
|
||||
*/
|
||||
protected function ensureAbsolutePath($reference)
|
||||
{
|
||||
if (!is_array($reference)) {
|
||||
return PathUtility::isAbsolutePath($reference) ? $reference : GeneralUtility::getFileAbsFileName($reference);
|
||||
}
|
||||
foreach ($reference as &$subValue) {
|
||||
$subValue = $this->ensureAbsolutePath($subValue);
|
||||
}
|
||||
return $reference;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function isBackendMode()
|
||||
{
|
||||
return TYPO3_MODE === 'BE';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function isFrontendMode()
|
||||
{
|
||||
return TYPO3_MODE === 'FE';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
namespace TYPO3\CMS\Fluid\View;
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
use TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext;
|
||||
use TYPO3Fluid\Fluid\View\Exception\InvalidTemplateResourceException;
|
||||
|
||||
/**
|
||||
* The main template view. Should be used as view if you want Fluid Templating
|
||||
*/
|
||||
class TemplateView extends AbstractTemplateView
|
||||
{
|
||||
/**
|
||||
* Sets the path and name of the layout file. Overrides the dynamic resolving of the layout file.
|
||||
*
|
||||
* @param string $layoutPathAndFilename Path and filename of the layout file
|
||||
*/
|
||||
public function setLayoutPathAndFilename($layoutPathAndFilename)
|
||||
{
|
||||
$this->baseRenderingContext->getTemplatePaths()->setLayoutPathAndFilename($layoutPathAndFilename);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether a template can be resolved for the current request context.
|
||||
*
|
||||
* @param ControllerContext $controllerContext Controller context which is available inside the view
|
||||
* @return bool
|
||||
*/
|
||||
public function canRender(ControllerContext $controllerContext)
|
||||
{
|
||||
try {
|
||||
$request = $controllerContext->getRequest();
|
||||
$this->setControllerContext($controllerContext);
|
||||
$this->baseRenderingContext->getTemplatePaths()->setFormat($request->getFormat());
|
||||
$this->baseRenderingContext->getTemplatePaths()->getTemplateSource($request->getControllerName(), $request->getControllerActionName());
|
||||
return true;
|
||||
} catch (InvalidTemplateResourceException $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user