‪TYPO3CMS  9.5
SiteRouteResult.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types = 1);
3 
5 
6 /*
7  * This file is part of the TYPO3 CMS project.
8  *
9  * It is free software; you can redistribute it and/or modify it under
10  * the terms of the GNU General Public License, either version 2
11  * of the License, or any later version.
12  *
13  * For the full copyright and license information, please read the
14  * LICENSE.txt file that was distributed with this source code.
15  *
16  * The TYPO3 project - inspiring people to share!
17  */
18 
19 use Psr\Http\Message\UriInterface;
22 
29 {
33  protected ‪$validProperties = ['uri', 'site', 'language', 'tail'];
34 
39  protected ‪$uri;
40 
44  protected ‪$site;
45 
49  protected ‪$language;
50 
55  protected ‪$data;
56 
61  protected ‪$tail;
62 
63  public function ‪__construct(UriInterface ‪$uri, ‪SiteInterface ‪$site, ‪SiteLanguage ‪$language = null, string ‪$tail = '', array ‪$data = [])
64  {
65  $this->uri = ‪$uri;
66  $this->site = ‪$site;
67  $this->language = ‪$language;
68  $this->tail = ‪$tail;
69  $this->data = ‪$data;
70  }
71 
72  public function ‪getUri(): UriInterface
73  {
74  return ‪$this->uri;
75  }
76 
77  public function ‪getSite(): ‪SiteInterface
78  {
79  return ‪$this->site;
80  }
81 
82  public function ‪getLanguage(): ?‪SiteLanguage
83  {
84  return ‪$this->language;
85  }
86 
87  public function ‪getTail(): string
88  {
89  return ‪$this->tail;
90  }
91 
92  public function ‪offsetExists($offset): bool
93  {
94  return in_array($offset, $this->validProperties, true) || isset($this->data[$offset]);
95  }
96 
101  public function ‪offsetGet($offset)
102  {
103  switch ($offset) {
104  case 'uri':
105  return ‪$this->uri;
106  case 'site':
107  return ‪$this->site;
108  case 'language':
109  return ‪$this->language;
110  case 'tail':
112  default:
113  return $this->data[$offset];
114  }
115  }
116 
117  public function ‪offsetSet($offset, $value)
118  {
119  switch ($offset) {
120  case 'uri':
121  throw new \InvalidArgumentException('You can never replace the URI in a route result', 1535462423);
122  case 'site':
123  throw new \InvalidArgumentException('You can never replace the Site object in a route result', 1535462454);
124  case 'language':
125  throw new \InvalidArgumentException('You can never replace the Language object in a route result', 1535462452);
126  case 'tail':
127  $this->tail = $value;
128  break;
129  default:
130  $this->data[$offset] = $value;
131  }
132  }
133 
134  public function ‪offsetUnset($offset)
135  {
136  switch ($offset) {
137  case 'uri':
138  throw new \InvalidArgumentException('You can never replace the URI in a route result', 1535462429);
139  case 'site':
140  throw new \InvalidArgumentException('You can never replace the Site object in a route result', 1535462458);
141  case 'language':
142  $this->language = null;
143  break;
144  case 'tail':
145  $this->tail = '';
146  break;
147  default:
148  unset($this->data[$offset]);
149  }
150  }
151 }
‪TYPO3\CMS\Core\Site\Entity\SiteInterface
Definition: SiteInterface.php:25
‪TYPO3\CMS\Core\Routing\SiteRouteResult\getSite
‪getSite()
Definition: SiteRouteResult.php:71
‪TYPO3\CMS\Core\Routing\SiteRouteResult\getUri
‪getUri()
Definition: SiteRouteResult.php:66
‪TYPO3\CMS\Core\Routing\SiteRouteResult\$tail
‪string $tail
Definition: SiteRouteResult.php:55
‪TYPO3\CMS\Core\Routing\SiteRouteResult\getLanguage
‪getLanguage()
Definition: SiteRouteResult.php:76
‪TYPO3\CMS\Core\Routing\RouteResultInterface
Definition: RouteResultInterface.php:23
‪TYPO3\CMS\Core\Routing\SiteRouteResult\$validProperties
‪array $validProperties
Definition: SiteRouteResult.php:32
‪TYPO3\CMS\Core\Routing
‪TYPO3\CMS\Core\Routing\SiteRouteResult\$uri
‪UriInterface $uri
Definition: SiteRouteResult.php:37
‪TYPO3\CMS\Core\Routing\SiteRouteResult\$language
‪SiteLanguage $language
Definition: SiteRouteResult.php:45
‪TYPO3\CMS\Core\Routing\SiteRouteResult\__construct
‪__construct(UriInterface $uri, SiteInterface $site, SiteLanguage $language=null, string $tail='', array $data=[])
Definition: SiteRouteResult.php:57
‪TYPO3\CMS\Core\Site\Entity\SiteLanguage
Definition: SiteLanguage.php:25
‪TYPO3\CMS\Core\Routing\SiteRouteResult\offsetGet
‪mixed UriInterface string SiteInterface SiteLanguage offsetGet($offset)
Definition: SiteRouteResult.php:95
‪TYPO3\CMS\Core\Routing\SiteRouteResult
Definition: SiteRouteResult.php:29
‪TYPO3\CMS\Core\Routing\SiteRouteResult\getTail
‪getTail()
Definition: SiteRouteResult.php:81
‪TYPO3\CMS\Core\Routing\SiteRouteResult\offsetUnset
‪offsetUnset($offset)
Definition: SiteRouteResult.php:128
‪TYPO3\CMS\Core\Routing\SiteRouteResult\offsetExists
‪offsetExists($offset)
Definition: SiteRouteResult.php:86
‪TYPO3\CMS\Core\Routing\SiteRouteResult\$data
‪array $data
Definition: SiteRouteResult.php:50
‪TYPO3\CMS\Core\Routing\SiteRouteResult\$site
‪SiteInterface $site
Definition: SiteRouteResult.php:41
‪TYPO3\CMS\Core\Routing\SiteRouteResult\offsetSet
‪offsetSet($offset, $value)
Definition: SiteRouteResult.php:111