Skip to content

Commit

Permalink
Add workaround to support new Site Handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Carsten Windler authored and cundd committed Apr 29, 2019
1 parent 5771444 commit 61eb3fd
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions Classes/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@

use TYPO3\CMS\Core\TimeTracker\TimeTracker;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Routing\SiteMatcher;
use TYPO3\CMS\Core\Routing\SiteRouteResult;
use TYPO3\CMS\Extbase\Object\ObjectManager;
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
use TYPO3\CMS\Frontend\Utility\EidUtility;
use TYPO3\CMS\Lang\LanguageService;


/**
* Class to bootstrap TYPO3 frontend controller
*/
Expand Down Expand Up @@ -143,10 +146,31 @@ private function configureFrontendController($frontendController)
*/
private function setRequestedLanguage(TypoScriptFrontendController $frontendController)
{
// Set language if defined
$requestedLanguageUid = GeneralUtility::_GP('L') !== null
? intval(GeneralUtility::_GP('L'))
: $this->getRequestedLanguageUid($frontendController);
// support new Typo3 v9.2 Site Handling until middleware concept is implemented
// see https://github.com/cundd/rest/issues/59
if (isset($GLOBALS['TYPO3_REQUEST']) && class_exists(SiteMatcher::class)) {
$request = $GLOBALS['TYPO3_REQUEST'];

/** @var SiteRouteResult $routeResult */
$routeResult = GeneralUtility::makeInstance(SiteMatcher::class)->matchRequest($request);

$language = $routeResult->getLanguage();

$request = $request->withAttribute('site', $routeResult->getSite());
$request = $request->withAttribute('language', $language);
$request = $request->withAttribute('routing', $routeResult);

$GLOBALS['TYPO3_REQUEST'] = $request;

// Set language if defined
$requestedLanguageUid = ($language && $language->getLanguageId() !== null)
? $language->getLanguageId()
: $this->getRequestedLanguageUid($frontendController);
} else {
$requestedLanguageUid = GeneralUtility::_GP('L') !== null
? intval(GeneralUtility::_GP('L'))
: $this->getRequestedLanguageUid($frontendController);
}

if (null !== $requestedLanguageUid) {
$frontendController->config['config']['sys_language_uid'] = $requestedLanguageUid;
Expand Down

0 comments on commit 61eb3fd

Please sign in to comment.