‪TYPO3CMS  ‪main
StandaloneView.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
18 namespace ‪TYPO3\CMS\Fluid\View;
19 
20 use Psr\Http\Message\ServerRequestInterface;
23 use TYPO3Fluid\Fluid\View\Exception\InvalidTemplateResourceException;
24 
30 {
36  public function ‪setFormat(string $format): void
37  {
38  if (!$this->baseRenderingContext instanceof ‪RenderingContext) {
39  throw new \RuntimeException('The rendering context must be of type ' . RenderingContext::class, 1482251886);
40  }
41  $request = $this->baseRenderingContext->getRequest();
42  if ($request instanceof ‪RequestInterface) {
43  $request = $request->withFormat($format);
44  $this->baseRenderingContext->setRequest($request);
45  }
46  $this->baseRenderingContext->getTemplatePaths()->setFormat($format);
47  }
48 
52  public function ‪setRequest(?ServerRequestInterface $request = null): void
53  {
54  if ($this->baseRenderingContext instanceof ‪RenderingContext) {
55  $this->baseRenderingContext->setRequest($request);
56  }
57  }
58 
63  public function ‪setTemplateSource(string $templateSource): void
64  {
65  $this->baseRenderingContext->getTemplatePaths()->setTemplateSource($templateSource);
66  }
67 
71  public function ‪hasTemplate(): bool
72  {
73  try {
74  $this->baseRenderingContext->getTemplatePaths()->getTemplateSource(
75  $this->baseRenderingContext->getControllerName(),
76  $this->baseRenderingContext->getControllerAction()
77  );
78  return true;
79  } catch (InvalidTemplateResourceException) {
80  return false;
81  }
82  }
83 }
‪TYPO3\CMS\Fluid\View\StandaloneView\setRequest
‪setRequest(?ServerRequestInterface $request=null)
Definition: StandaloneView.php:52
‪TYPO3\CMS\Fluid\View\AbstractTemplateView
Definition: AbstractTemplateView.php:30
‪TYPO3\CMS\Fluid\View\StandaloneView\setFormat
‪setFormat(string $format)
Definition: StandaloneView.php:36
‪TYPO3\CMS\Extbase\Mvc\RequestInterface
Definition: RequestInterface.php:24
‪TYPO3\CMS\Fluid\View\StandaloneView
Definition: StandaloneView.php:30
‪TYPO3\CMS\Fluid\View\StandaloneView\setTemplateSource
‪setTemplateSource(string $templateSource)
Definition: StandaloneView.php:63
‪TYPO3\CMS\Fluid\Core\Rendering\RenderingContext
Definition: RenderingContext.php:35
‪TYPO3\CMS\Fluid\View
Definition: AbstractTemplateView.php:16
‪TYPO3\CMS\Fluid\View\StandaloneView\hasTemplate
‪hasTemplate()
Definition: StandaloneView.php:71