‪TYPO3CMS  9.5
SiteLanguage.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;
20 
25 {
31  protected ‪$languageId;
32 
38  protected ‪$locale;
39 
45  protected ‪$base;
46 
51  protected ‪$title = 'Default';
52 
57  protected ‪$navigationTitle = '';
58 
63  protected ‪$flagIdentifier = '';
64 
69  protected ‪$twoLetterIsoCode = 'en';
70 
77  protected ‪$hreflang = 'en-US';
78 
83  protected ‪$direction = '';
84 
92  protected ‪$typo3Language = 'default';
93 
97  protected ‪$fallbackType = 'strict';
98 
102  protected ‪$fallbackLanguageIds = [];
103 
107  protected ‪$enabled = true;
108 
113  protected ‪$configuration = [];
114 
123  public function ‪__construct(int ‪$languageId, string ‪$locale, UriInterface ‪$base, array ‪$configuration)
124  {
125  $this->languageId = ‪$languageId;
126  $this->locale = ‪$locale;
127  $this->base = ‪$base;
128  $this->configuration = ‪$configuration;
129 
130  if (!empty(‪$configuration['title'])) {
131  $this->title = ‪$configuration['title'];
132  }
133  if (!empty(‪$configuration['navigationTitle'])) {
134  $this->navigationTitle = ‪$configuration['navigationTitle'];
135  }
136  if (!empty(‪$configuration['flag'])) {
137  $this->flagIdentifier = ‪$configuration['flag'];
138  }
139  if (!empty(‪$configuration['typo3Language'])) {
140  $this->typo3Language = ‪$configuration['typo3Language'];
141  }
142  if (!empty(‪$configuration['iso-639-1'])) {
143  $this->twoLetterIsoCode = ‪$configuration['iso-639-1'];
144  }
145  if (!empty(‪$configuration['hreflang'])) {
146  $this->hreflang = ‪$configuration['hreflang'];
147  }
148  if (!empty(‪$configuration['direction'])) {
149  $this->direction = ‪$configuration['direction'];
150  }
151  if (!empty(‪$configuration['fallbackType'])) {
152  $this->fallbackType = ‪$configuration['fallbackType'];
153  }
154  if (isset(‪$configuration['fallbacks'])) {
156 
157  // It is important to distinct between "0" and "" so, empty() should not be used here
158  if (is_string(‪$fallbackLanguageIds)) {
159  if (‪$fallbackLanguageIds !== '') {
161  } else {
163  }
164  } elseif (is_scalar(‪$fallbackLanguageIds)) {
166  }
167  $this->fallbackLanguageIds = array_map('intval', ‪$fallbackLanguageIds);
168  }
169  if (isset(‪$configuration['enabled'])) {
170  $this->‪enabled = (bool)‪$configuration['enabled'];
171  }
172  }
173 
180  public function ‪toArray(): array
181  {
182  return array_merge($this->configuration, [
183  'languageId' => $this->‪getLanguageId(),
184  'locale' => $this->‪getLocale(),
185  'base' => (string)$this->‪getBase(),
186  'title' => $this->‪getTitle(),
187  'navigationTitle' => $this->‪getNavigationTitle(),
188  'twoLetterIsoCode' => $this->‪getTwoLetterIsoCode(),
189  'hreflang' => $this->‪getHreflang(),
190  'direction' => $this->‪getDirection(),
191  'typo3Language' => $this->‪getTypo3Language(),
192  'flagIdentifier' => $this->‪getFlagIdentifier(),
193  'fallbackType' => $this->‪getFallbackType(),
194  'enabled' => $this->‪enabled(),
195  'fallbackLanguageIds' => $this->‪getFallbackLanguageIds(),
196  ]);
197  }
198 
202  public function ‪getLanguageId(): int
203  {
205  }
206 
210  public function ‪getLocale(): string
211  {
213  }
214 
218  public function ‪getBase(): UriInterface
219  {
221  }
222 
226  public function ‪getTitle(): string
227  {
229  }
230 
234  public function ‪getNavigationTitle(): string
235  {
236  return $this->navigationTitle ?: ‪$this->title;
237  }
238 
242  public function ‪getFlagIdentifier(): string
243  {
245  }
246 
250  public function ‪getTypo3Language(): string
251  {
253  }
254 
260  public function ‪getTwoLetterIsoCode(): string
261  {
263  }
264 
270  public function ‪getHreflang(): string
271  {
272  return ‪$this->hreflang;
273  }
274 
280  public function ‪getDirection(): string
281  {
282  return ‪$this->direction;
283  }
284 
290  public function ‪enabled(): bool
291  {
292  return ‪$this->enabled;
293  }
294 
300  public function ‪isEnabled(): bool
301  {
303  }
304 
308  public function ‪getFallbackType(): string
309  {
310  return ‪$this->fallbackType;
311  }
312 
316  public function ‪getFallbackLanguageIds(): array
317  {
319  }
320 }
‪TYPO3\CMS\Core\Site\Entity\SiteLanguage\__construct
‪__construct(int $languageId, string $locale, UriInterface $base, array $configuration)
Definition: SiteLanguage.php:109
‪TYPO3\CMS\Core\Site\Entity\SiteLanguage\getLanguageId
‪int getLanguageId()
Definition: SiteLanguage.php:188
‪TYPO3\CMS\Core\Site\Entity\SiteLanguage\$base
‪UriInterface $base
Definition: SiteLanguage.php:42
‪TYPO3\CMS\Core\Site\Entity\SiteLanguage\$locale
‪string $locale
Definition: SiteLanguage.php:36
‪TYPO3\CMS\Core\Site\Entity\SiteLanguage\getFallbackLanguageIds
‪array getFallbackLanguageIds()
Definition: SiteLanguage.php:302
‪TYPO3\CMS\Core\Site\Entity\SiteLanguage\$twoLetterIsoCode
‪string $twoLetterIsoCode
Definition: SiteLanguage.php:62
‪TYPO3\CMS\Core\Site\Entity\SiteLanguage\getTitle
‪string getTitle()
Definition: SiteLanguage.php:212
‪TYPO3\CMS\Core\Site\Entity\SiteLanguage\getTwoLetterIsoCode
‪string getTwoLetterIsoCode()
Definition: SiteLanguage.php:246
‪TYPO3\CMS\Core\Site\Entity\SiteLanguage\$enabled
‪bool $enabled
Definition: SiteLanguage.php:94
‪TYPO3\CMS\Core\Site\Entity\SiteLanguage\$typo3Language
‪string $typo3Language
Definition: SiteLanguage.php:82
‪TYPO3\CMS\Core\Site\Entity\SiteLanguage\getDirection
‪string getDirection()
Definition: SiteLanguage.php:266
‪TYPO3\CMS\Core\Site\Entity\SiteLanguage\$hreflang
‪string $hreflang
Definition: SiteLanguage.php:69
‪TYPO3\CMS\Core\Site\Entity\SiteLanguage
Definition: SiteLanguage.php:25
‪TYPO3\CMS\Core\Site\Entity\SiteLanguage\getLocale
‪string getLocale()
Definition: SiteLanguage.php:196
‪TYPO3\CMS\Core\Site\Entity\SiteLanguage\$flagIdentifier
‪string $flagIdentifier
Definition: SiteLanguage.php:57
‪TYPO3\CMS\Core\Site\Entity\SiteLanguage\$configuration
‪array $configuration
Definition: SiteLanguage.php:99
‪TYPO3\CMS\Core\Site\Entity\SiteLanguage\getFlagIdentifier
‪string getFlagIdentifier()
Definition: SiteLanguage.php:228
‪TYPO3\CMS\Core\Site\Entity\SiteLanguage\$fallbackType
‪string $fallbackType
Definition: SiteLanguage.php:86
‪TYPO3\CMS\Core\Site\Entity\SiteLanguage\$direction
‪string $direction
Definition: SiteLanguage.php:74
‪TYPO3\CMS\Core\Site\Entity\SiteLanguage\getFallbackType
‪string getFallbackType()
Definition: SiteLanguage.php:294
‪TYPO3\CMS\Core\Site\Entity\SiteLanguage\isEnabled
‪bool isEnabled()
Definition: SiteLanguage.php:286
‪TYPO3\CMS\Core\Site\Entity\SiteLanguage\$languageId
‪int $languageId
Definition: SiteLanguage.php:30
‪TYPO3\CMS\Core\Site\Entity\SiteLanguage\getHreflang
‪string getHreflang()
Definition: SiteLanguage.php:256
‪TYPO3\CMS\Core\Site\Entity\SiteLanguage\$navigationTitle
‪string $navigationTitle
Definition: SiteLanguage.php:52
‪TYPO3\CMS\Core\Site\Entity\SiteLanguage\$title
‪string $title
Definition: SiteLanguage.php:47
‪TYPO3\CMS\Core\Site\Entity
Definition: NullSite.php:4
‪TYPO3\CMS\Core\Site\Entity\SiteLanguage\getBase
‪UriInterface getBase()
Definition: SiteLanguage.php:204
‪TYPO3\CMS\Core\Site\Entity\SiteLanguage\getNavigationTitle
‪string getNavigationTitle()
Definition: SiteLanguage.php:220
‪TYPO3\CMS\Core\Site\Entity\SiteLanguage\toArray
‪array toArray()
Definition: SiteLanguage.php:166
‪TYPO3\CMS\Core\Site\Entity\SiteLanguage\$fallbackLanguageIds
‪array $fallbackLanguageIds
Definition: SiteLanguage.php:90
‪TYPO3\CMS\Core\Site\Entity\SiteLanguage\enabled
‪bool enabled()
Definition: SiteLanguage.php:276
‪TYPO3\CMS\Core\Site\Entity\SiteLanguage\getTypo3Language
‪string getTypo3Language()
Definition: SiteLanguage.php:236