[TASK] Streamline phpdoc annotations in EXT:fluid
[Packages/TYPO3.CMS.git] / typo3 / sysext / fluid / Classes / View / TemplateView.php
1 <?php
2 namespace TYPO3\CMS\Fluid\View;
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
17 use TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext;
18 use TYPO3Fluid\Fluid\View\Exception\InvalidTemplateResourceException;
19
20 /**
21 * The main template view. Should be used as view if you want Fluid Templating
22 */
23 class TemplateView extends AbstractTemplateView
24 {
25 /**
26 * Sets the path and name of the layout file. Overrides the dynamic resolving of the layout file.
27 *
28 * @param string $layoutPathAndFilename Path and filename of the layout file
29 */
30 public function setLayoutPathAndFilename($layoutPathAndFilename)
31 {
32 $this->baseRenderingContext->getTemplatePaths()->setLayoutPathAndFilename($layoutPathAndFilename);
33 }
34
35 /**
36 * Checks whether a template can be resolved for the current request context.
37 *
38 * @param ControllerContext $controllerContext Controller context which is available inside the view
39 * @return bool
40 */
41 public function canRender(ControllerContext $controllerContext)
42 {
43 try {
44 $request = $controllerContext->getRequest();
45 $this->setControllerContext($controllerContext);
46 $this->baseRenderingContext->getTemplatePaths()->setFormat($request->getFormat());
47 $this->baseRenderingContext->getTemplatePaths()->getTemplateSource($request->getControllerName(), $request->getControllerActionName());
48 return true;
49 } catch (InvalidTemplateResourceException $e) {
50 return false;
51 }
52 }
53 }