‪TYPO3CMS  10.4
LanguageAspect.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 
21 
57 {
61  protected ‪$id = 0;
62 
66  protected ‪$contentId = 0;
67 
71  protected ‪$fallbackChain = [];
72 
76  protected ‪$overlayType;
77 
78  public const ‪OVERLAYS_OFF = 'off'; // config.sys_language_overlay = 0
79  public const ‪OVERLAYS_MIXED = 'mixed'; // config.sys_language_overlay = 1 (keep the ones that are only available in default language)
80  public const ‪OVERLAYS_ON = 'on'; // "hideNonTranslated"
81  public const ‪OVERLAYS_ON_WITH_FLOATING = 'includeFloating'; // "hideNonTranslated" + records that are only available in polish
82 
91  public function ‪__construct(int ‪$id = 0, int ‪$contentId = null, string ‪$overlayType = self::OVERLAYS_ON_WITH_FLOATING, array ‪$fallbackChain = [])
92  {
93  $this->overlayType = ‪$overlayType;
94  $this->id = ‪$id;
95  $this->contentId = ‪$contentId ?? ‪$this->id;
96  $this->fallbackChain = ‪$fallbackChain;
97  }
98 
104  public function ‪getOverlayType(): string
105  {
106  return ‪$this->overlayType;
107  }
108 
115  public function ‪getId(): int
116  {
117  return ‪$this->id;
118  }
119 
127  public function ‪getContentId(): int
128  {
129  return ‪$this->contentId;
130  }
131 
132  public function ‪getFallbackChain(): array
133  {
135  }
136 
142  public function ‪doOverlays(): bool
143  {
144  return $this->contentId > 0 && $this->overlayType !== ‪self::OVERLAYS_OFF;
145  }
146 
152  public function ‪getLegacyLanguageMode(): string
153  {
154  if ($this->fallbackChain === ['off']) {
155  return '';
156  }
157  if (empty($this->fallbackChain)) {
158  return 'strict';
159  }
160  if ($this->fallbackChain === [-1]) {
161  return 'ignore';
162  }
163  return 'content_fallback';
164  }
165 
171  public function ‪getLegacyOverlayType(): string
172  {
173  switch ($this->overlayType) {
176  return 'hideNonTranslated';
178  return '1';
180  default:
181  return '0';
182  }
183  }
184 
192  public function get(string $name)
193  {
194  switch ($name) {
195  case 'id':
196  return ‪$this->id;
197  case 'contentId':
198  return ‪$this->contentId;
199  case 'fallbackChain':
201  case 'overlayType':
202  return ‪$this->overlayType;
203  case 'legacyLanguageMode':
204  return $this->‪getLegacyLanguageMode();
205  case 'legacyOverlayType':
206  return $this->‪getLegacyOverlayType();
207  }
208  throw new AspectPropertyNotFoundException('Property "' . $name . '" not found in Aspect "' . __CLASS__ . '".', 1530448504);
209  }
210 }
‪TYPO3\CMS\Core\Context\LanguageAspect\$overlayType
‪string $overlayType
Definition: LanguageAspect.php:72
‪TYPO3\CMS\Core\Context\LanguageAspect\OVERLAYS_MIXED
‪const OVERLAYS_MIXED
Definition: LanguageAspect.php:75
‪TYPO3\CMS\Core\Context\LanguageAspect\getContentId
‪int getContentId()
Definition: LanguageAspect.php:123
‪TYPO3\CMS\Core\Context\LanguageAspect\getLegacyLanguageMode
‪string getLegacyLanguageMode()
Definition: LanguageAspect.php:148
‪TYPO3\CMS\Core\Context\LanguageAspect\getId
‪int getId()
Definition: LanguageAspect.php:111
‪TYPO3\CMS\Core\Context
Definition: AspectInterface.php:18
‪TYPO3\CMS\Core\Context\LanguageAspect\OVERLAYS_ON
‪const OVERLAYS_ON
Definition: LanguageAspect.php:76
‪TYPO3\CMS\Core\Context\LanguageAspect\$id
‪int $id
Definition: LanguageAspect.php:60
‪TYPO3\CMS\Core\Context\LanguageAspect\getFallbackChain
‪getFallbackChain()
Definition: LanguageAspect.php:128
‪TYPO3\CMS\Core\Context\AspectInterface
Definition: AspectInterface.php:27
‪TYPO3\CMS\Core\Context\LanguageAspect\getOverlayType
‪string getOverlayType()
Definition: LanguageAspect.php:100
‪TYPO3\CMS\Core\Context\LanguageAspect\__construct
‪__construct(int $id=0, int $contentId=null, string $overlayType=self::OVERLAYS_ON_WITH_FLOATING, array $fallbackChain=[])
Definition: LanguageAspect.php:87
‪TYPO3\CMS\Core\Context\LanguageAspect\$contentId
‪int $contentId
Definition: LanguageAspect.php:64
‪TYPO3\CMS\Core\Context\LanguageAspect
Definition: LanguageAspect.php:57
‪TYPO3\CMS\Core\Context\LanguageAspect\$fallbackChain
‪array $fallbackChain
Definition: LanguageAspect.php:68
‪TYPO3\CMS\Core\Context\LanguageAspect\getLegacyOverlayType
‪string getLegacyOverlayType()
Definition: LanguageAspect.php:167
‪TYPO3\CMS\Core\Context\LanguageAspect\OVERLAYS_OFF
‪const OVERLAYS_OFF
Definition: LanguageAspect.php:74
‪TYPO3\CMS\Core\Context\LanguageAspect\OVERLAYS_ON_WITH_FLOATING
‪const OVERLAYS_ON_WITH_FLOATING
Definition: LanguageAspect.php:77
‪TYPO3\CMS\Core\Context\LanguageAspect\doOverlays
‪bool doOverlays()
Definition: LanguageAspect.php:138
‪TYPO3\CMS\Core\Context\Exception\AspectPropertyNotFoundException
Definition: AspectPropertyNotFoundException.php:26