예제 #1
0
 /**
  * @return void
  */
 protected function initializeConcreteConfigurationManager()
 {
     if ($this->environmentService->isEnvironmentInFrontendMode()) {
         $this->concreteConfigurationManager = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Configuration\\FrontendConfigurationManager');
     } else {
         $this->concreteConfigurationManager = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Configuration\\BackendConfigurationManager');
     }
 }
예제 #2
0
 /**
  * @return void
  */
 protected function initializeConcreteSessionManager()
 {
     if ($this->environmentService->isEnvironmentInFrontendMode()) {
         $this->concreteSessionManager = $this->objectManager->get('Aijko\\SessionStorage\\FrontendStorage');
     } else {
         $this->concreteSessionManager = $this->objectManager->get('Aijko\\SessionStorage\\BackendStorage');
     }
 }
 /**
  * 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;
 }
예제 #4
0
	/**
	 * Set compatibility values to frontend controller object
	 * in case we are in frontend environment.
	 *
	 * @param ProcessedFile $processedImage
	 * @return void
	 */
	protected function setCompatibilityValues(ProcessedFile $processedImage) {
		if ($this->environmentService->isEnvironmentInFrontendMode()) {
			$imageInfo = $this->getCompatibilityImageResourceValues($processedImage);
			$GLOBALS['TSFE']->lastImageInfo = $imageInfo;
			$GLOBALS['TSFE']->imagesOnPage[] = $imageInfo[3];
		}
	}
예제 #5
0
 /**
  * @return \TYPO3\CMS\Frontend\Page\PageRepository
  */
 protected function getPageRepository()
 {
     if (!$this->pageRepository instanceof \TYPO3\CMS\Frontend\Page\PageRepository) {
         if ($this->environmentService->isEnvironmentInFrontendMode() && is_object($GLOBALS['TSFE'])) {
             $this->pageRepository = $GLOBALS['TSFE']->sys_page;
         } else {
             $this->pageRepository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\Page\PageRepository::class);
         }
     }
     return $this->pageRepository;
 }
예제 #6
0
 /**
  * Adds an additional header data (something like
  * '<script src="myext/Resources/JavaScript/my.js" type="text/javascript"></script>'
  * )
  *
  * @TODO The workround and the $request member should be removed again, once the PageRender does support non-cached USER_INTs
  * @param string $additionalHeaderData The value additonal header
  * @throws \InvalidArgumentException
  * @return void
  * @api
  */
 public function addAdditionalHeaderData($additionalHeaderData)
 {
     if (!is_string($additionalHeaderData)) {
         throw new \InvalidArgumentException('The additiona header data must be of type String, ' . gettype($additionalHeaderData) . ' given.', 1237370877);
     }
     if ($this->request->isCached()) {
         if ($this->environmentService->isEnvironmentInFrontendMode()) {
             $pageRenderer = $GLOBALS['TSFE']->getPageRenderer();
         } elseif ($this->environmentService->isEnvironmentInBackendMode()) {
             $pageRenderer = $GLOBALS['TBE_TEMPLATE']->getPageRenderer();
         }
         $pageRenderer->addHeaderData($additionalHeaderData);
     } else {
         $this->additionalHeaderData[] = $additionalHeaderData;
     }
 }
예제 #7
0
 /**
  * Adds an additional header data (something like
  * '<script src="myext/Resources/JavaScript/my.js" type="text/javascript"></script>'
  * )
  *
  * @TODO The workround and the $request member should be removed again, once the PageRender does support non-cached USER_INTs
  * @param string $additionalHeaderData The value additonal header
  * @throws \InvalidArgumentException
  * @return void
  * @api
  */
 public function addAdditionalHeaderData($additionalHeaderData)
 {
     if (!is_string($additionalHeaderData)) {
         throw new \InvalidArgumentException('The additiona header data must be of type String, ' . gettype($additionalHeaderData) . ' given.', 1237370877);
     }
     if ($this->request->isCached()) {
         /** @var PageRenderer $pageRenderer */
         $pageRenderer = NULL;
         if ($this->environmentService->isEnvironmentInFrontendMode()) {
             $pageRenderer = $this->getTypoScriptFrontendController()->getPageRenderer();
         } elseif ($this->environmentService->isEnvironmentInBackendMode()) {
             $pageRenderer = $this->getDocumentTemplate()->getPageRenderer();
         }
         if ($pageRenderer !== NULL) {
             $pageRenderer->addHeaderData($additionalHeaderData);
         }
     } else {
         $this->additionalHeaderData[] = $additionalHeaderData;
     }
 }
예제 #8
0
 /**
  * Creates an URI used for linking to an Extbase action.
  * Works in Frontend and Backend mode of TYPO3.
  *
  * @param string $actionName Name of the action to be called
  * @param array $controllerArguments Additional query parameters. Will be "namespaced" and merged with $this->arguments.
  * @param string $controllerName Name of the target controller. If not set, current ControllerName is used.
  * @param string $extensionName Name of the target extension, without underscores. If not set, current ExtensionName is used.
  * @param string $pluginName Name of the target plugin. If not set, current PluginName is used.
  * @return string the rendered URI
  * @api
  * @see build()
  */
 public function uriFor($actionName = null, $controllerArguments = array(), $controllerName = null, $extensionName = null, $pluginName = null)
 {
     if ($actionName !== null) {
         $controllerArguments['action'] = $actionName;
     }
     if ($controllerName !== null) {
         $controllerArguments['controller'] = $controllerName;
     } else {
         $controllerArguments['controller'] = $this->request->getControllerName();
     }
     if ($extensionName === null) {
         $extensionName = $this->request->getControllerExtensionName();
     }
     if ($pluginName === null && $this->environmentService->isEnvironmentInFrontendMode()) {
         $pluginName = $this->extensionService->getPluginNameByAction($extensionName, $controllerArguments['controller'], $controllerArguments['action']);
     }
     if ($pluginName === null) {
         $pluginName = $this->request->getPluginName();
     }
     if ($this->environmentService->isEnvironmentInFrontendMode() && $this->configurationManager->isFeatureEnabled('skipDefaultArguments')) {
         $controllerArguments = $this->removeDefaultControllerAndAction($controllerArguments, $extensionName, $pluginName);
     }
     if ($this->targetPageUid === null && $this->environmentService->isEnvironmentInFrontendMode()) {
         $this->targetPageUid = $this->extensionService->getTargetPidByPlugin($extensionName, $pluginName);
     }
     if ($this->format !== '') {
         $controllerArguments['format'] = $this->format;
     }
     if ($this->argumentPrefix !== null) {
         $prefixedControllerArguments = array($this->argumentPrefix => $controllerArguments);
     } else {
         $pluginNamespace = $this->extensionService->getPluginNamespace($extensionName, $pluginName);
         $prefixedControllerArguments = array($pluginNamespace => $controllerArguments);
     }
     ArrayUtility::mergeRecursiveWithOverrule($this->arguments, $prefixedControllerArguments);
     return $this->build();
 }