‪TYPO3CMS  10.4
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 
102  public function ‪offsetGet($offset)
103  {
104  switch ($offset) {
105  case 'uri':
106  return ‪$this->uri;
107  case 'site':
108  return ‪$this->site;
109  case 'language':
110  return ‪$this->language;
111  case 'tail':
113  default:
114  return $this->data[$offset];
115  }
116  }
117 
118  public function ‪offsetSet($offset, $value)
119  {
120  switch ($offset) {
121  case 'uri':
122  throw new \InvalidArgumentException('You can never replace the URI in a route result', 1535462423);
123  case 'site':
124  throw new \InvalidArgumentException('You can never replace the Site object in a route result', 1535462454);
125  case 'language':
126  throw new \InvalidArgumentException('You can never replace the Language object in a route result', 1535462452);
127  case 'tail':
128  $this->tail = $value;
129  break;
130  default:
131  $this->data[$offset] = $value;
132  }
133  }
134 
135  public function ‪offsetUnset($offset)
136  {
137  switch ($offset) {
138  case 'uri':
139  throw new \InvalidArgumentException('You can never replace the URI in a route result', 1535462429);
140  case 'site':
141  throw new \InvalidArgumentException('You can never replace the Site object in a route result', 1535462458);
142  case 'language':
143  $this->language = null;
144  break;
145  case 'tail':
146  $this->tail = '';
147  break;
148  default:
149  unset($this->data[$offset]);
150  }
151  }
152 }
‪TYPO3\CMS\Core\Site\Entity\SiteInterface
Definition: SiteInterface.php:26
‪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:24
‪TYPO3\CMS\Core\Routing\SiteRouteResult\$validProperties
‪array $validProperties
Definition: SiteRouteResult.php:33
‪TYPO3\CMS\Core\Routing
‪TYPO3\CMS\Core\Routing\SiteRouteResult\$uri
‪UriInterface $uri
Definition: SiteRouteResult.php:38
‪TYPO3\CMS\Core\Routing\SiteRouteResult\$language
‪SiteLanguage $language
Definition: SiteRouteResult.php:46
‪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:26
‪TYPO3\CMS\Core\Routing\SiteRouteResult\offsetGet
‪mixed UriInterface string SiteInterface SiteLanguage offsetGet($offset)
Definition: SiteRouteResult.php:96
‪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:129
‪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\offsetSet
‪offsetSet($offset, $value)
Definition: SiteRouteResult.php:112