TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
StandaloneView.php
Go to the documentation of this file.
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 
20 use TYPO3\CMS\Extbase\Mvc\Web\Request as WebRequest;
26 
34 {
42  public function __construct(ContentObjectRenderer $contentObject = null)
43  {
44  $this->objectManager = GeneralUtility::makeInstance(ObjectManager::class);
45 
47  $configurationManager = $this->objectManager->get(ConfigurationManagerInterface::class);
48  if ($contentObject === null) {
50  $contentObject = GeneralUtility::makeInstance(ContentObjectRenderer::class);
51  }
52  $configurationManager->setContentObject($contentObject);
53 
55  $request = $this->objectManager->get(WebRequest::class);
56  $request->setRequestUri(GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'));
57  $request->setBaseUri(GeneralUtility::getIndpEnv('TYPO3_SITE_URL'));
59  $uriBuilder = $this->objectManager->get(UriBuilder::class);
60  $uriBuilder->setRequest($request);
62  $controllerContext = $this->objectManager->get(ControllerContext::class);
63  $controllerContext->setRequest($request);
64  $controllerContext->setUriBuilder($uriBuilder);
65  $renderingContext = $this->objectManager->get(RenderingContext::class, $this);
66  $renderingContext->setControllerContext($controllerContext);
67  $this->setRenderingContext($renderingContext);
68  }
69 
73  public function setTemplate($templateName)
74  {
75  $this->baseRenderingContext->setControllerAction($templateName);
76  }
77 
85  public function setFormat($format)
86  {
87  $this->baseRenderingContext->getControllerContext()->getRequest()->setFormat($format);
88  }
89 
96  public function getFormat()
97  {
98  return $this->baseRenderingContext->getControllerContext()->getRequest()->getFormat();
99  }
100 
106  public function getRequest()
107  {
108  return $this->baseRenderingContext->getControllerContext()->getRequest();
109  }
110 
118  public function setTemplatePathAndFilename($templatePathAndFilename)
119  {
120  $this->baseRenderingContext->getTemplatePaths()->setTemplatePathAndFilename($templatePathAndFilename);
121  }
122 
129  public function getTemplatePathAndFilename()
130  {
131  return $this->baseRenderingContext->getTemplatePaths()->getTemplatePathAndFilename();
132  }
133 
142  public function setTemplateSource($templateSource)
143  {
144  $this->baseRenderingContext->getTemplatePaths()->setTemplateSource($templateSource);
145  }
146 
154  public function setTemplateRootPaths(array $templateRootPaths)
155  {
156  $this->baseRenderingContext->getTemplatePaths()->setTemplateRootPaths($templateRootPaths);
157  }
158 
166  public function setLayoutRootPaths(array $layoutRootPaths)
167  {
168  $this->baseRenderingContext->getTemplatePaths()->setLayoutRootPaths($layoutRootPaths);
169  }
170 
178  public function getLayoutRootPaths()
179  {
180  return $this->baseRenderingContext->getTemplatePaths()->getLayoutRootPaths();
181  }
182 
191  public function setPartialRootPaths(array $partialRootPaths)
192  {
193  $this->baseRenderingContext->getTemplatePaths()->setPartialRootPaths($partialRootPaths);
194  }
195 
203  public function getPartialRootPaths()
204  {
205  return $this->baseRenderingContext->getTemplatePaths()->getPartialRootPaths();
206  }
207 
214  public function hasTemplate()
215  {
216  try {
217  $this->baseRenderingContext->getTemplatePaths()->getTemplateSource(
218  $this->baseRenderingContext->getControllerName(),
219  $this->baseRenderingContext->getControllerAction()
220  );
221  return true;
222  } catch (InvalidTemplateResourceException $e) {
223  return false;
224  }
225  }
226 }
setTemplateRootPaths(array $templateRootPaths)
setPartialRootPaths(array $partialRootPaths)
setLayoutRootPaths(array $layoutRootPaths)
__construct(RenderingContextInterface $context=null)
static makeInstance($className,...$constructorArguments)
setTemplatePathAndFilename($templatePathAndFilename)