‪TYPO3CMS  ‪main
SiteRouteResult.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\UriInterface;
23 
30 {
34  protected ‪$validProperties = ['uri', 'site', 'language', 'tail'];
35 
40  protected ‪$uri;
41 
45  protected ‪$site;
46 
50  protected ‪$language;
51 
56  protected ‪$data;
57 
62  protected ‪$tail;
63 
64  public function ‪__construct(UriInterface ‪$uri, ‪SiteInterface ‪$site, ‪SiteLanguage ‪$language = null, string ‪$tail = '', array ‪$data = [])
65  {
66  $this->uri = ‪$uri;
67  $this->site = ‪$site;
68  $this->language = ‪$language;
69  $this->tail = ‪$tail;
70  $this->data = ‪$data;
71  }
72 
73  public function ‪getUri(): UriInterface
74  {
75  return ‪$this->uri;
76  }
77 
78  public function ‪getSite(): ‪SiteInterface
79  {
80  return ‪$this->site;
81  }
82 
83  public function ‪getLanguage(): ?‪SiteLanguage
84  {
85  return ‪$this->language;
86  }
87 
88  public function ‪getTail(): string
89  {
90  return ‪$this->tail;
91  }
92 
93  public function ‪offsetExists($offset): bool
94  {
95  return in_array($offset, $this->validProperties, true) || isset($this->data[$offset]);
96  }
97 
101  public function ‪withLanguage(‪SiteLanguage ‪$language): self
102  {
103  $clone = clone $this;
104  $clone->language = ‪$language;
105 
106  return $clone;
107  }
108 
112  public function ‪offsetGet($offset): mixed
113  {
114  switch ($offset) {
115  case 'uri':
116  return ‪$this->uri;
117  case 'site':
118  return ‪$this->site;
119  case 'language':
120  return ‪$this->language;
121  case 'tail':
122  return ‪$this->tail;
123  default:
124  return $this->data[$offset];
125  }
126  }
127 
132  public function ‪offsetSet($offset, $value): void
133  {
134  switch ($offset) {
135  case 'uri':
136  throw new \InvalidArgumentException('You can never replace the URI in a route result', 1535462423);
137  case 'site':
138  throw new \InvalidArgumentException('You can never replace the Site object in a route result', 1535462454);
139  case 'language':
140  throw new \InvalidArgumentException('You can never replace the Language object in a route result', 1535462452);
141  case 'tail':
142  $this->tail = $value;
143  break;
144  default:
145  $this->data[$offset] = $value;
146  }
147  }
148 
152  public function ‪offsetUnset($offset): void
153  {
154  switch ($offset) {
155  case 'uri':
156  throw new \InvalidArgumentException('You can never replace the URI in a route result', 1535462429);
157  case 'site':
158  throw new \InvalidArgumentException('You can never replace the Site object in a route result', 1535462458);
159  case 'language':
160  $this->language = null;
161  break;
162  case 'tail':
163  $this->tail = '';
164  break;
165  default:
166  unset($this->data[$offset]);
167  }
168  }
169 }
‪TYPO3\CMS\Core\Site\Entity\SiteInterface
Definition: SiteInterface.php:26
‪TYPO3\CMS\Core\Routing\SiteRouteResult\withLanguage
‪withLanguage(SiteLanguage $language)
Definition: SiteRouteResult.php:95
‪TYPO3\CMS\Core\Routing\SiteRouteResult\getSite
‪getSite()
Definition: SiteRouteResult.php:72
‪TYPO3\CMS\Core\Routing\SiteRouteResult\getUri
‪getUri()
Definition: SiteRouteResult.php:67
‪TYPO3\CMS\Core\Routing\SiteRouteResult\$tail
‪string $tail
Definition: SiteRouteResult.php:56
‪TYPO3\CMS\Core\Routing\SiteRouteResult\getLanguage
‪getLanguage()
Definition: SiteRouteResult.php:77
‪TYPO3\CMS\Core\Routing\RouteResultInterface
Definition: RouteResultInterface.php:23
‪TYPO3\CMS\Core\Routing\SiteRouteResult\$validProperties
‪array $validProperties
Definition: SiteRouteResult.php:33
‪TYPO3\CMS\Core\Routing
‪TYPO3\CMS\Core\Routing\SiteRouteResult\offsetGet
‪offsetGet($offset)
Definition: SiteRouteResult.php:106
‪TYPO3\CMS\Core\Routing\SiteRouteResult\$uri
‪UriInterface $uri
Definition: SiteRouteResult.php:38
‪TYPO3\CMS\Core\Routing\SiteRouteResult\__construct
‪__construct(UriInterface $uri, SiteInterface $site, SiteLanguage $language=null, string $tail='', array $data=[])
Definition: SiteRouteResult.php:58
‪TYPO3\CMS\Core\Site\Entity\SiteLanguage
Definition: SiteLanguage.php:27
‪TYPO3\CMS\Core\Routing\SiteRouteResult
Definition: SiteRouteResult.php:30
‪TYPO3\CMS\Core\Routing\SiteRouteResult\getTail
‪getTail()
Definition: SiteRouteResult.php:82
‪TYPO3\CMS\Core\Routing\SiteRouteResult\offsetUnset
‪offsetUnset($offset)
Definition: SiteRouteResult.php:146
‪TYPO3\CMS\Core\Routing\SiteRouteResult\offsetExists
‪offsetExists($offset)
Definition: SiteRouteResult.php:87
‪TYPO3\CMS\Core\Routing\SiteRouteResult\$data
‪array $data
Definition: SiteRouteResult.php:51
‪TYPO3\CMS\Core\Routing\SiteRouteResult\$site
‪SiteInterface $site
Definition: SiteRouteResult.php:42
‪TYPO3\CMS\Core\Routing\SiteRouteResult\$language
‪SiteLanguage null $language
Definition: SiteRouteResult.php:46
‪TYPO3\CMS\Core\Routing\SiteRouteResult\offsetSet
‪offsetSet($offset, $value)
Definition: SiteRouteResult.php:126