2 namespace TYPO3\CMS\Fluid\View
;
5 * This file is part of the TYPO3 CMS project.
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
14 * The TYPO3 project - inspiring people to share!
17 use TYPO3\CMS\Core\Utility\GeneralUtility
;
18 use TYPO3\CMS\Extbase\
Object\ObjectManager
;
19 use TYPO3\CMS\Fluid\Core\Rendering\RenderingContext
;
20 use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface
;
21 use TYPO3Fluid\Fluid\View\TemplateView
;
24 * Abstract Fluid Template View.
26 * Contains the fundamental methods which any Fluid based template view needs.
28 abstract class AbstractTemplateView
extends TemplateView
implements \TYPO3\CMS\Extbase\Mvc\View\ViewInterface
31 * @var \TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext
33 protected $controllerContext;
36 * Initializes this view.
41 public function initializeView()
46 * @param RenderingContextInterface $context
48 public function __construct(RenderingContextInterface
$context = null)
51 $context = GeneralUtility
::makeInstance(ObjectManager
::class)->get(RenderingContext
::class, $this);
53 parent
::__construct($context);
57 * Tells if the view implementation can render the view for the given context.
59 * By default we assume that the view implementation can handle all kinds of
60 * contexts. Override this method if that is not the case.
62 * @param \TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext $controllerContext Controller context which is available inside the view
63 * @return bool TRUE if the view has something useful to display, otherwise FALSE
66 public function canRender(\TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext
$controllerContext)
72 * Sets the current controller context
74 * @param \TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext $controllerContext
77 public function setControllerContext(\TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext
$controllerContext)
79 $request = $controllerContext->getRequest();
80 $this->controllerContext
= $controllerContext;
81 $this->baseRenderingContext
->getTemplatePaths()->fillDefaultsByPackageName($request->getControllerExtensionKey());
82 $this->baseRenderingContext
->getTemplatePaths()->setFormat($request->getFormat());
83 if ($this->baseRenderingContext
instanceof RenderingContext
) {
84 $this->baseRenderingContext
->setControllerContext($controllerContext);