/** * Renders a content object by taking exception and cache handling * into consideration * * @param AbstractContentObject $contentObject Content object instance * @param array $configuration Array of TypoScript properties * * @throws ContentRenderingException * @throws \Exception * @return string */ public function render(AbstractContentObject $contentObject, $configuration = array()) { $content = ''; // Evaluate possible cache and return $cacheConfiguration = isset($configuration['cache.']) ? $configuration['cache.'] : null; if ($cacheConfiguration !== null) { unset($configuration['cache.']); $cache = $this->getFromCache($cacheConfiguration); if ($cache !== false) { return $cache; } } // Render content try { $content .= $contentObject->render($configuration); } catch (ContentRenderingException $exception) { // Content rendering Exceptions indicate a critical problem which should not be // caught e.g. when something went wrong with Exception handling itself throw $exception; } catch (\Exception $exception) { $exceptionHandler = $this->createExceptionHandler($configuration); if ($exceptionHandler === null) { throw $exception; } else { $content = $exceptionHandler->handle($exception, $contentObject, $configuration); } } // Store cache if ($cacheConfiguration !== null) { $key = $this->calculateCacheKey($cacheConfiguration); if (!empty($key)) { /** @var $cacheFrontend \TYPO3\CMS\Core\Cache\Frontend\VariableFrontend */ $cacheFrontend = GeneralUtility::makeInstance(CacheManager::class)->getCache('cache_hash'); $tags = $this->calculateCacheTags($cacheConfiguration); $lifetime = $this->calculateCacheLifetime($cacheConfiguration); $cacheFrontend->set($key, $content, $tags, $lifetime); } } return $content; }
public function __construct(\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer $contentObjectRenderer) { parent::__construct($contentObjectRenderer); $this->view = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Fluid\\View\\StandaloneView'); }
/** * @param ContentObjectRenderer $cObj */ public function __construct(ContentObjectRenderer $cObj) { parent::__construct($cObj); $this->contentDataProcessor = GeneralUtility::makeInstance(ContentDataProcessor::class); }
/** * Constructor */ public function __construct(\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer $contentObjectRenderer) { parent::__construct($contentObjectRenderer); }