‪TYPO3CMS  10.4
LanguageAspectFactory.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 
22 
27 {
34  public static function ‪createFromSiteLanguage(‪SiteLanguage $language): ‪LanguageAspect
35  {
36  $languageId = $language->‪getLanguageId();
37  $fallbackType = $language->‪getFallbackType();
38  $fallbackOrder = $language->‪getFallbackLanguageIds();
39  $fallbackOrder[] = 'pageNotFound';
40  switch ($fallbackType) {
41  // Fall back to other language, if the page does not exist in the requested language
42  // But always fetch only records of this specific (available) language
43  case 'free':
44  $overlayType = ‪LanguageAspect::OVERLAYS_OFF;
45  break;
46 
47  // Fall back to other language, if the page does not exist in the requested language
48  // Do overlays, and keep the ones that are not translated
49  case 'fallback':
50  $overlayType = ‪LanguageAspect::OVERLAYS_MIXED;
51  break;
52 
53  // Same as "fallback" but remove the records that are not translated
54  case 'strict':
56  break;
57 
58  // Ignore, fallback to default language
59  default:
60  $fallbackOrder = [0];
61  $overlayType = ‪LanguageAspect::OVERLAYS_OFF;
62  }
63 
64  return GeneralUtility::makeInstance(LanguageAspect::class, $languageId, $languageId, $overlayType, $fallbackOrder);
65  }
66 }
‪TYPO3\CMS\Core\Site\Entity\SiteLanguage\getLanguageId
‪int getLanguageId()
Definition: SiteLanguage.php:198
‪TYPO3\CMS\Core\Context\LanguageAspectFactory
Definition: LanguageAspectFactory.php:27
‪TYPO3\CMS\Core\Context\LanguageAspect\OVERLAYS_MIXED
‪const OVERLAYS_MIXED
Definition: LanguageAspect.php:75
‪TYPO3\CMS\Core\Site\Entity\SiteLanguage\getFallbackLanguageIds
‪array getFallbackLanguageIds()
Definition: SiteLanguage.php:320
‪TYPO3\CMS\Core\Context
Definition: AspectInterface.php:18
‪TYPO3\CMS\Core\Context\LanguageAspectFactory\createFromSiteLanguage
‪static LanguageAspect createFromSiteLanguage(SiteLanguage $language)
Definition: LanguageAspectFactory.php:34
‪TYPO3\CMS\Core\Site\Entity\SiteLanguage
Definition: SiteLanguage.php:26
‪TYPO3\CMS\Core\Site\Entity\SiteLanguage\getFallbackType
‪string getFallbackType()
Definition: SiteLanguage.php:312
‪TYPO3\CMS\Core\Context\LanguageAspect
Definition: LanguageAspect.php:57
‪TYPO3\CMS\Core\Context\LanguageAspect\OVERLAYS_OFF
‪const OVERLAYS_OFF
Definition: LanguageAspect.php:74
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Core\Context\LanguageAspect\OVERLAYS_ON_WITH_FLOATING
‪const OVERLAYS_ON_WITH_FLOATING
Definition: LanguageAspect.php:77