示例#1
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');
     }
 }
 /**
  * @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');
     }
 }
 /**
  * @test
  * @dataProvider prefixIsCorrectlyAppliedToGetImageUriDataProvider
  */
 public function prefixIsCorrectlyAppliedToGetImageUri($imageUri, $expected)
 {
     $this->environmentService->expects($this->any())->method('isEnvironmentInFrontendMode')->willReturn(TRUE);
     $GLOBALS['TSFE'] = new \stdClass();
     $GLOBALS['TSFE']->absRefPrefix = '/prefix/';
     $file = $this->getMock('TYPO3\\CMS\\Core\\Resource\\File', array(), array(), '', FALSE);
     $file->expects($this->once())->method('getPublicUrl')->willReturn($imageUri);
     $this->assertSame($expected, $this->subject->getImageUri($file));
 }
示例#4
0
 /**
  * @return void
  */
 protected function injectDependencies()
 {
     $this->mockConfigurationManager->expects($this->any())->method('getConfiguration')->will($this->returnValue($this->configuration));
     $this->requestBuilder->_set('configurationManager', $this->mockConfigurationManager);
     $this->mockObjectManager->expects($this->any())->method('get')->with(\TYPO3\CMS\Extbase\Mvc\Web\Request::class)->will($this->returnValue($this->mockRequest));
     $this->requestBuilder->_set('objectManager', $this->mockObjectManager);
     $pluginNamespace = 'tx_' . strtolower($this->configuration['extensionName'] . '_' . $this->configuration['pluginName']);
     $this->mockExtensionService->expects($this->any())->method('getPluginNamespace')->will($this->returnValue($pluginNamespace));
     $this->requestBuilder->_set('extensionService', $this->mockExtensionService);
     $this->mockEnvironmentService->expects($this->any())->method('getServerRequestMethod')->will($this->returnValue('GET'));
     $this->requestBuilder->_set('environmentService', $this->mockEnvironmentService);
 }
 /**
  * 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;
 }
示例#6
0
 /**
  * Builds a web request object from the raw HTTP information and the configuration
  *
  * @return \TYPO3\CMS\Extbase\Mvc\Web\Request The web request as an object
  */
 public function build()
 {
     $this->loadDefaultValues();
     $pluginNamespace = $this->extensionService->getPluginNamespace($this->extensionName, $this->pluginName);
     $parameters = \TYPO3\CMS\Core\Utility\GeneralUtility::_GPmerged($pluginNamespace);
     $files = $this->untangleFilesArray($_FILES);
     if (isset($files[$pluginNamespace]) && is_array($files[$pluginNamespace])) {
         $parameters = array_replace_recursive($parameters, $files[$pluginNamespace]);
     }
     $controllerName = $this->resolveControllerName($parameters);
     $actionName = $this->resolveActionName($controllerName, $parameters);
     /** @var $request \TYPO3\CMS\Extbase\Mvc\Web\Request */
     $request = $this->objectManager->get(\TYPO3\CMS\Extbase\Mvc\Web\Request::class);
     if ($this->vendorName !== null) {
         $request->setControllerVendorName($this->vendorName);
     }
     $request->setPluginName($this->pluginName);
     $request->setControllerExtensionName($this->extensionName);
     $request->setControllerName($controllerName);
     $request->setControllerActionName($actionName);
     $request->setRequestUri(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'));
     $request->setBaseUri(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL'));
     $request->setMethod($this->environmentService->getServerRequestMethod());
     if (is_string($parameters['format']) && $parameters['format'] !== '') {
         $request->setFormat(filter_var($parameters['format'], FILTER_SANITIZE_STRING));
     } else {
         $request->setFormat($this->defaultFormat);
     }
     foreach ($parameters as $argumentName => $argumentValue) {
         $request->setArgument($argumentName, $argumentValue);
     }
     return $request;
 }
示例#7
0
	/**
	 * Returns the base URI
	 *
	 * @return string Base URI of this web request
	 * @api
	 */
	public function getBaseUri() {
		if ($this->environmentService->isEnvironmentInBackendMode()) {
			return $this->baseUri . TYPO3_mainDir;
		} else {
			return $this->baseUri;
		}
	}
示例#8
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];
		}
	}
示例#9
0
 /**
  * @param \TYPO3\CMS\Core\Resource\ResourceStorage $resourceStorage
  * @param \TYPO3\CMS\Core\Resource\Driver\DriverInterface $driver
  * @param \TYPO3\CMS\Core\Resource\ResourceInterface $resourceObject
  * @param boolean $relativeToCurrentScript
  * @param string $urlData
  */
 public function getCdnPublicUrl($resourceStorage, $driver, $resourceObject, $relativeToCurrentScript, $urlData)
 {
     if (!$driver instanceof LocalDriver || $this->environmentService->isEnvironmentInBackendMode()) {
         return;
     }
     if (($resourceObject instanceof File || $resourceObject instanceof ProcessedFile) && ($resourceStorage->getCapabilities() & ResourceStorageInterface::CAPABILITY_PUBLIC) == ResourceStorageInterface::CAPABILITY_PUBLIC) {
         $publicUrl = $driver->getPublicUrl($resourceObject->getIdentifier());
         $urlData['publicUrl'] = $GLOBALS['TSFE']->config['config']['cdnBaseUrl'] . $publicUrl;
         if ($resourceObject instanceof File) {
             $urlData['publicUrl'] .= '?' . $resourceObject->getModificationTime();
         } else {
             if ($resourceObject instanceof ProcessedFile) {
                 $urlData['publicUrl'] .= '?' . $resourceObject->getProperty('tstamp');
             }
         }
     }
 }
 /**
  * @test
  * @dataProvider prefixIsCorrectlyAppliedToGetImageUriWithAbsolutePathDataProvider
  */
 public function prefixIsCorrectlyAppliedToGetImageUriWithForcedAbsoluteUrl($imageUri, $expected)
 {
     $this->environmentService->expects($this->any())->method('isEnvironmentInFrontendMode')->willReturn(true);
     $GLOBALS['TSFE'] = new \stdClass();
     $GLOBALS['TSFE']->absRefPrefix = '/prefix/';
     $file = $this->getMock(File::class, array(), array(), '', false);
     $file->expects($this->once())->method('getPublicUrl')->willReturn($imageUri);
     $this->assertSame($expected, $this->subject->getImageUri($file, true));
 }
示例#11
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;
 }
示例#12
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;
     }
 }
示例#13
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;
     }
 }
示例#14
0
 /**
  * This request handler can handle any command line request.
  *
  * @return boolean If the request is a command line request, TRUE otherwise FALSE
  */
 public function canHandleRequest()
 {
     return $this->environmentService->isEnvironmentInCliMode();
 }
示例#15
0
 /**
  * Builds the URI
  * Depending on the current context this calls buildBackendUri() or buildFrontendUri()
  *
  * @return string The URI
  * @api
  * @see buildBackendUri()
  * @see buildFrontendUri()
  */
 public function build()
 {
     if ($this->environmentService->isEnvironmentInBackendMode()) {
         return $this->buildBackendUri();
     } else {
         return $this->buildFrontendUri();
     }
 }