‪TYPO3CMS  10.4
SiteResolver.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use Psr\Http\Message\ResponseInterface;
21 use Psr\Http\Message\ServerRequestInterface;
22 use Psr\Http\Server\MiddlewareInterface;
23 use Psr\Http\Server\RequestHandlerInterface;
28 
36 class ‪SiteResolver implements MiddlewareInterface
37 {
41  protected ‪$matcher;
42 
44  {
45  $this->matcher = ‪$matcher;
46  }
47 
55  public function ‪process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
56  {
58  $routeResult = $this->matcher->matchRequest($request);
59  $request = $request->withAttribute('site', $routeResult->getSite());
60  $request = $request->withAttribute('language', $routeResult->getLanguage());
61  $request = $request->withAttribute('routing', $routeResult);
62  if ($routeResult->getLanguage() instanceof ‪SiteLanguage) {
63  ‪Locales::setSystemLocaleFromSiteLanguage($routeResult->getLanguage());
64  }
65  return $handler->handle($request);
66  }
67 }
‪TYPO3\CMS\Core\Localization\Locales\setSystemLocaleFromSiteLanguage
‪static bool setSystemLocaleFromSiteLanguage(SiteLanguage $siteLanguage)
Definition: Locales.php:270
‪TYPO3\CMS\Core\Localization\Locales
Definition: Locales.php:30
‪TYPO3\CMS\Frontend\Middleware\SiteResolver
Definition: SiteResolver.php:37
‪TYPO3\CMS\Core\Site\Entity\SiteLanguage
Definition: SiteLanguage.php:26
‪TYPO3\CMS\Frontend\Middleware
Definition: BackendUserAuthenticator.php:18
‪TYPO3\CMS\Core\Routing\SiteRouteResult
Definition: SiteRouteResult.php:30
‪TYPO3\CMS\Frontend\Middleware\SiteResolver\__construct
‪__construct(SiteMatcher $matcher)
Definition: SiteResolver.php:42
‪TYPO3\CMS\Frontend\Middleware\SiteResolver\process
‪ResponseInterface process(ServerRequestInterface $request, RequestHandlerInterface $handler)
Definition: SiteResolver.php:54
‪TYPO3\CMS\Frontend\Middleware\SiteResolver\$matcher
‪SiteMatcher $matcher
Definition: SiteResolver.php:40
‪TYPO3\CMS\Core\Routing\SiteMatcher
Definition: SiteMatcher.php:51