e59cb61b58814519c2ea4400488ab1bd225d1e90
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Classes / ExpressionLanguage / RequestWrapper.php
1 <?php
2 declare(strict_types = 1);
3 namespace TYPO3\CMS\Core\ExpressionLanguage;
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
18 use Psr\Http\Message\ServerRequestInterface;
19 use TYPO3\CMS\Core\Http\NormalizedParams;
20 use TYPO3\CMS\Core\Site\Entity\Site;
21 use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
22
23 /**
24 * Class RequestWrapper
25 * This class provides access to some methods of the ServerRequest object.
26 * To prevent access to all methods of the ServerRequest object within conditions,
27 * this class was introduced to control which methods are exposed.
28 * @internal
29 */
30 class RequestWrapper
31 {
32 /**
33 * @var ServerRequestInterface
34 */
35 protected $request;
36
37 public function __construct()
38 {
39 $this->request = $GLOBALS['TYPO3_REQUEST'];
40 }
41
42 public function getQueryParams(): array
43 {
44 return $this->request->getQueryParams();
45 }
46
47 public function getParsedBody()
48 {
49 return $this->request->getParsedBody();
50 }
51
52 public function getHeaders(): array
53 {
54 return $this->request->getHeaders();
55 }
56
57 public function getCookieParams(): array
58 {
59 return $this->request->getCookieParams();
60 }
61
62 public function getSite(): ?Site
63 {
64 return $this->request->getAttribute('site');
65 }
66
67 public function getSiteLanguage(): ?SiteLanguage
68 {
69 return $this->request->getAttribute('language');
70 }
71
72 public function getNormalizedParams(): ?NormalizedParams
73 {
74 return $this->request->getAttribute('normalizedParams');
75 }
76 }