TYPO3 CMS  TYPO3_8-7
AbstractTemplateView.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
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.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
22 
29 {
33  protected $controllerContext;
34 
40  public function initializeView()
41  {
42  }
43 
47  public function __construct(RenderingContextInterface $context = null)
48  {
49  if (!$context) {
50  $context = GeneralUtility::makeInstance(ObjectManager::class)->get(RenderingContext::class, $this);
51  }
52  parent::__construct($context);
53  }
54 
65  public function canRender(\TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext $controllerContext)
66  {
67  return true;
68  }
69 
75  public function setControllerContext(\TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext $controllerContext)
76  {
77  $request = $controllerContext->getRequest();
78  $this->controllerContext = $controllerContext;
79  $this->baseRenderingContext->getTemplatePaths()->fillDefaultsByPackageName($request->getControllerExtensionKey());
80  $this->baseRenderingContext->getTemplatePaths()->setFormat($request->getFormat());
81  if ($this->baseRenderingContext instanceof RenderingContext) {
82  $this->baseRenderingContext->setControllerContext($controllerContext);
83  }
84  }
85 }
canRender(\TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext $controllerContext)
static makeInstance($className,... $constructorArguments)
__construct(RenderingContextInterface $context=null)
setControllerContext(\TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext $controllerContext)