Exemplo n.º 1
0
 /**
  * Initialize configuration manager and content object
  *
  * @return void
  */
 protected static function initialize()
 {
     // Get configuration manager
     $objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Tx_Extbase_Object_ObjectManager');
     self::$configurationManager = $objectManager->get('Tx_Extbase_Configuration_ConfigurationManager');
     // Simulate Frontend
     if (TYPO3_MODE == 'BE') {
         \TYPO3\CMS\Extbase\Utility\FrontendSimulatorUtility::simulateFrontendEnvironment();
         if (empty($GLOBALS['TSFE']->sys_page)) {
             $GLOBALS['TSFE']->sys_page = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('t3lib_pageSelect');
         }
         if (empty($GLOBALS['TT'])) {
             $GLOBALS['TT'] = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('t3lib_TimeTrackNull');
         }
         self::$configurationManager->setContentObject($GLOBALS['TSFE']->cObj);
     }
     // Get content object
     self::$contentObject = self::$configurationManager->getContentObject();
     if (empty(self::$contentObject)) {
         self::$contentObject = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tslib_cObj');
     }
     // Reset Frontend if modified
     if (TYPO3_MODE == 'BE') {
         \TYPO3\CMS\Extbase\Utility\FrontendSimulatorUtility::resetFrontendEnvironment();
     }
 }
 /**
  * Loads the Extbase Framework configuration.
  *
  * The Extbase framework configuration HAS TO be retrieved using this method, as they are come from different places than the normal settings.
  * Framework configuration is, in contrast to normal settings, needed for the Extbase framework to operate correctly.
  *
  * @param string $extensionName if specified, the configuration for the given extension will be returned (plugin.tx_extensionname)
  * @param string $pluginName if specified, the configuration for the given plugin will be returned (plugin.tx_extensionname_pluginname)
  * @return array the Extbase framework configuration
  */
 public function getConfiguration($extensionName = null, $pluginName = null)
 {
     // 1st level cache
     $configurationCacheKey = strtolower(($extensionName ?: $this->extensionName) . '_' . ($pluginName ?: $this->pluginName));
     if (isset($this->configurationCache[$configurationCacheKey])) {
         return $this->configurationCache[$configurationCacheKey];
     }
     $frameworkConfiguration = $this->getExtbaseConfiguration();
     if (!isset($frameworkConfiguration['persistence']['storagePid'])) {
         $frameworkConfiguration['persistence']['storagePid'] = $this->getDefaultBackendStoragePid();
     }
     // only merge $this->configuration and override switchableControllerActions when retrieving configuration of the current plugin
     if ($extensionName === null || $extensionName === $this->extensionName && $pluginName === $this->pluginName) {
         $pluginConfiguration = $this->getPluginConfiguration($this->extensionName, $this->pluginName);
         \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($pluginConfiguration, $this->configuration);
         $pluginConfiguration['controllerConfiguration'] = $this->getSwitchableControllerActions($this->extensionName, $this->pluginName);
         if (isset($this->configuration['switchableControllerActions'])) {
             $this->overrideSwitchableControllerActions($pluginConfiguration, $this->configuration['switchableControllerActions']);
         }
     } else {
         $pluginConfiguration = $this->getPluginConfiguration($extensionName, $pluginName);
         $pluginConfiguration['controllerConfiguration'] = $this->getSwitchableControllerActions($extensionName, $pluginName);
     }
     \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($frameworkConfiguration, $pluginConfiguration);
     // only load context specific configuration when retrieving configuration of the current plugin
     if ($extensionName === null || $extensionName === $this->extensionName && $pluginName === $this->pluginName) {
         $frameworkConfiguration = $this->getContextSpecificFrameworkConfiguration($frameworkConfiguration);
     }
     if (!empty($frameworkConfiguration['persistence']['storagePid'])) {
         if (is_array($frameworkConfiguration['persistence']['storagePid'])) {
             /**
              * We simulate the frontend to enable the use of cObjects in
              * stdWrap. Than we convert the configuration to normal TypoScript
              * and apply the stdWrap to the storagePid
              */
             if (!$this->environmentService->isEnvironmentInFrontendMode()) {
                 \TYPO3\CMS\Extbase\Utility\FrontendSimulatorUtility::simulateFrontendEnvironment($this->getContentObject());
             }
             $conf = $this->typoScriptService->convertPlainArrayToTypoScriptArray($frameworkConfiguration['persistence']);
             $frameworkConfiguration['persistence']['storagePid'] = $GLOBALS['TSFE']->cObj->stdWrap($conf['storagePid'], $conf['storagePid.']);
             if (!$this->environmentService->isEnvironmentInFrontendMode()) {
                 \TYPO3\CMS\Extbase\Utility\FrontendSimulatorUtility::resetFrontendEnvironment();
             }
         }
         if (!empty($frameworkConfiguration['persistence']['recursive'])) {
             // All implementations of getTreeList allow to pass the ids negative to include them into the result
             // otherwise only childpages are returned
             $storagePids = \TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',', $frameworkConfiguration['persistence']['storagePid']);
             array_walk($storagePids, function (&$storagePid) {
                 if ($storagePid > 0) {
                     $storagePid = -$storagePid;
                 }
             });
             $frameworkConfiguration['persistence']['storagePid'] = $this->getRecursiveStoragePids(implode(',', $storagePids), (int) $frameworkConfiguration['persistence']['recursive']);
         }
     }
     // 1st level cache
     $this->configurationCache[$configurationCacheKey] = $frameworkConfiguration;
     return $frameworkConfiguration;
 }