Advertisement
BenjaminS

TYPO3: Generic Function for rendering TypoScriptFrontend

Jun 20th, 2014
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.81 KB | None | 0 0
  1. <?php
  2. namespace Serfhos\MyLibrary\Utility;
  3.  
  4. /**
  5.  * Utility: Initialize objects inside EID usage
  6.  */
  7. class EidUtility
  8. {
  9.  
  10.     /**
  11.      * Initialize TSFE based on given page id
  12.      *
  13.      * @param integer $pageId
  14.      * @return void
  15.      */
  16.     public static function initializeTypoScriptFrontendController($pageId = 0)
  17.     {
  18.         global $TYPO3_CONF_VARS;
  19.  
  20.         // fallback for timetracker
  21.         if (!is_object($GLOBALS['TT'])) {
  22.             $GLOBALS['TT'] = new \TYPO3\CMS\Core\TimeTracker\NullTimeTracker();
  23.         }
  24.  
  25.         $controller = & $GLOBALS['TSFE'];
  26.  
  27.         if (!($controller instanceof \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController)) {
  28.             $controller = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
  29.                 'TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController', $TYPO3_CONF_VARS, $pageId, 0
  30.             );
  31.             \TYPO3\CMS\Core\Core\Bootstrap::getInstance()->loadCachedTca();
  32.         }
  33.  
  34.         if (!($controller->fe_user instanceof \TYPO3\CMS\Frontend\Authentication\FrontendUserAuthentication)) {
  35.             $controller->initFEuser();
  36.         }
  37.  
  38.         if (!($controller->sys_page instanceof \TYPO3\CMS\Frontend\Page\PageRepository)) {
  39.             $controller->determineId();
  40.         }
  41.  
  42.         if (!($controller->tmpl instanceof \TYPO3\CMS\Core\TypoScript\TemplateService)) {
  43.             $controller->initTemplate();
  44.         }
  45.  
  46.         if (!is_array($controller->config)) {
  47.             $controller->getConfigArray();
  48.         }
  49.  
  50.         if (!($controller->cObj instanceof \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer)) {
  51.             $controller->newCObj();
  52.         }
  53.  
  54.         if (empty($controller->indexedDocTitle)) {
  55.             \TYPO3\CMS\Frontend\Page\PageGenerator::pagegenInit();
  56.         }
  57.     }
  58.  
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement