‪TYPO3CMS  ‪main
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 
88  public function ‪__construct(int ‪$id = 0, ?int ‪$contentId = null, string ‪$overlayType = self::OVERLAYS_ON_WITH_FLOATING, array ‪$fallbackChain = [])
89  {
90  $this->overlayType = ‪$overlayType;
91  $this->id = ‪$id;
92  $this->contentId = ‪$contentId ?? ‪$this->id;
93  $this->fallbackChain = ‪$fallbackChain;
94  }
95 
99  public function ‪getOverlayType(): string
100  {
101  return ‪$this->overlayType;
102  }
103 
108  public function ‪getId(): int
109  {
110  return ‪$this->id;
111  }
112 
118  public function ‪getContentId(): int
119  {
120  return ‪$this->contentId;
121  }
122 
123  public function ‪getFallbackChain(): array
124  {
126  }
127 
131  public function ‪doOverlays(): bool
132  {
133  return $this->contentId > 0 && $this->overlayType !== ‪self::OVERLAYS_OFF;
134  }
135 
139  public function ‪getLegacyLanguageMode(): string
140  {
141  if ($this->fallbackChain === ['off']) {
142  return '';
143  }
144  if (empty($this->fallbackChain)) {
145  return 'strict';
146  }
147  return 'content_fallback';
148  }
149 
153  public function ‪getLegacyOverlayType(): string
154  {
155  switch ($this->overlayType) {
158  return 'hideNonTranslated';
160  return '1';
162  default:
163  return '0';
164  }
165  }
166 
173  public function get(string ‪$name)
174  {
175  switch (‪$name) {
176  case 'id':
177  return ‪$this->id;
178  case 'contentId':
179  return ‪$this->contentId;
180  case 'fallbackChain':
182  case 'overlayType':
183  return ‪$this->overlayType;
184  case 'legacyLanguageMode':
185  return $this->‪getLegacyLanguageMode();
186  case 'legacyOverlayType':
187  return $this->‪getLegacyOverlayType();
188  }
189  throw new AspectPropertyNotFoundException('Property "' . ‪$name . '" not found in Aspect "' . __CLASS__ . '".', 1530448504);
190  }
191 }
‪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:84
‪TYPO3\CMS\Core\Context\LanguageAspect\$overlayType
‪string $overlayType
Definition: LanguageAspect.php:72
‪TYPO3\CMS\Core\Context\LanguageAspect\getOverlayType
‪getOverlayType()
Definition: LanguageAspect.php:95
‪TYPO3\CMS\Core\Context\LanguageAspect\OVERLAYS_MIXED
‪const OVERLAYS_MIXED
Definition: LanguageAspect.php:75
‪TYPO3\CMS\Core\Context\LanguageAspect\getId
‪getId()
Definition: LanguageAspect.php:104
‪TYPO3\CMS\Core\Context\LanguageAspect\getLegacyOverlayType
‪getLegacyOverlayType()
Definition: LanguageAspect.php:149
‪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\getContentId
‪getContentId()
Definition: LanguageAspect.php:114
‪TYPO3\CMS\Core\Context\LanguageAspect\$id
‪int $id
Definition: LanguageAspect.php:60
‪TYPO3\CMS\Core\Context\LanguageAspect\getFallbackChain
‪getFallbackChain()
Definition: LanguageAspect.php:119
‪TYPO3\CMS\Core\Context\AspectInterface
Definition: AspectInterface.php:27
‪$name
‪$name
Definition: phpIntegrityChecker.php:235
‪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\doOverlays
‪doOverlays()
Definition: LanguageAspect.php:127
‪TYPO3\CMS\Core\Context\LanguageAspect\$fallbackChain
‪array $fallbackChain
Definition: LanguageAspect.php:68
‪TYPO3\CMS\Core\Context\LanguageAspect\getLegacyLanguageMode
‪getLegacyLanguageMode()
Definition: LanguageAspect.php:135
‪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\Exception\AspectPropertyNotFoundException
Definition: AspectPropertyNotFoundException.php:25