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