/**
  * Sets the $TSFE->cObjectDepthCounter in Backend mode
  * This somewhat hacky work around is currently needed because the cObjGetSingle() function of tslib_cObj relies on this setting
  *
  * @param tslib_cObj $addCObj
  * @return void
  * @author Bastian Waidelich <*****@*****.**>
  */
 public static function simulateFrontendEnvironment(tslib_cObj $cObj = NULL)
 {
     self::$tsfeBackup = isset($GLOBALS['TSFE']) ? $GLOBALS['TSFE'] : NULL;
     $GLOBALS['TSFE'] = new stdClass();
     $GLOBALS['TSFE']->cObjectDepthCounter = 100;
     $GLOBALS['TSFE']->cObj = $cObj !== NULL ? $cObj : t3lib_div::makeInstance('tslib_cObj');
 }
 /**
  * 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
     if ($extensionName !== NULL) {
         if ($pluginName === NULL) {
             throw new Tx_Extbase_Configuration_Exception('You\'ll have to specify either both, extensionName and pluginName, or neither.', 1289852422);
         }
         $configurationCacheKey = strtolower($extensionName . '_' . $pluginName);
     } else {
         $configurationCacheKey = strtolower($this->extensionName . '_' . $this->pluginName);
     }
     if (isset($this->configurationCache[$configurationCacheKey])) {
         return $this->configurationCache[$configurationCacheKey];
     }
     $frameworkConfiguration = $this->getExtbaseConfiguration();
     if (!isset($frameworkConfiguration['persistence']['storagePid'])) {
         $frameworkConfiguration['persistence']['storagePid'] = self::DEFAULT_BACKEND_STORAGE_PID;
     }
     // 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);
         $pluginConfiguration = t3lib_div::array_merge_recursive_overrule($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);
     }
     $frameworkConfiguration = t3lib_div::array_merge_recursive_overrule($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']) && 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
          */
         Tx_Extbase_Utility_FrontendSimulator::simulateFrontendEnvironment($this->getContentObject());
         $conf = Tx_Extbase_Utility_TypoScript::convertPlainArrayToTypoScriptArray($frameworkConfiguration['persistence']);
         $frameworkConfiguration['persistence']['storagePid'] = $GLOBALS['TSFE']->cObj->stdWrap($conf['storagePid'], $conf['storagePid.']);
         Tx_Extbase_Utility_FrontendSimulator::resetFrontendEnvironment();
     }
     // 1st level cache
     $this->configurationCache[$configurationCacheKey] = $frameworkConfiguration;
     return $frameworkConfiguration;
 }