示例#1
0
 /**
  * Constructor
  *
  * @param ContentObjectRenderer $contentObject The current cObject. If NULL a new instance will be created
  * @throws \InvalidArgumentException
  * @throws \UnexpectedValueException
  */
 public function __construct(ContentObjectRenderer $contentObject = NULL)
 {
     $this->objectManager = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
     /** @var \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface $configurationManager */
     $configurationManager = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManagerInterface');
     if ($contentObject === NULL) {
         /** @var ContentObjectRenderer $contentObject */
         $contentObject = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer');
     }
     $configurationManager->setContentObject($contentObject);
     $this->templateParser = $this->objectManager->get('TYPO3\\CMS\\Fluid\\Core\\Parser\\TemplateParser');
     $this->setRenderingContext($this->objectManager->get('TYPO3\\CMS\\Fluid\\Core\\Rendering\\RenderingContext'));
     /** @var \TYPO3\CMS\Extbase\Mvc\Web\Request $request */
     $request = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Mvc\\Web\\Request');
     $request->setRequestURI(GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'));
     $request->setBaseURI(GeneralUtility::getIndpEnv('TYPO3_SITE_URL'));
     /** @var \TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder $uriBuilder */
     $uriBuilder = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Mvc\\Web\\Routing\\UriBuilder');
     $uriBuilder->setRequest($request);
     /** @var \TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext $controllerContext */
     $controllerContext = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Mvc\\Controller\\ControllerContext');
     $controllerContext->setRequest($request);
     $controllerContext->setUriBuilder($uriBuilder);
     $this->setControllerContext($controllerContext);
     $this->templateCompiler = $this->objectManager->get('TYPO3\\CMS\\Fluid\\Core\\Compiler\\TemplateCompiler');
     // singleton
     $this->templateCompiler->setTemplateCache(GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Cache\\CacheManager')->getCache('fluid_template'));
 }
 /**
  * @param \TYPO3\CMS\Fluid\Core\Compiler\TemplateCompiler $templateCompiler
  * @return void
  */
 public function injectTemplateCompiler(\TYPO3\CMS\Fluid\Core\Compiler\TemplateCompiler $templateCompiler)
 {
     $this->templateCompiler = $templateCompiler;
     $this->templateCompiler->setTemplateCache(\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Cache\\CacheManager')->getCache('fluid_template'));
 }