‪TYPO3CMS  10.4
LanguageServiceFactory.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 
26 {
30  protected ‪$locales;
31 
36 
38  {
39  $this->locales = ‪$locales;
40  $this->localizationFactory = ‪$localizationFactory;
41  }
42 
49  public function ‪create(string $locale): ‪LanguageService
50  {
51  $obj = new ‪LanguageService($this->locales, $this->localizationFactory);
52  $obj->init($locale);
53  return $obj;
54  }
55 
57  {
58  if ($user && ($user->user['lang'] ?? false)) {
59  return $this->‪create($user->user['lang']);
60  }
61  return $this->‪create('default');
62  }
63 }
‪TYPO3\CMS\Core\Localization\LanguageServiceFactory
Definition: LanguageServiceFactory.php:26
‪TYPO3\CMS\Core\Localization\LanguageServiceFactory\create
‪LanguageService create(string $locale)
Definition: LanguageServiceFactory.php:47
‪TYPO3\CMS\Core\Localization\LocalizationFactory
Definition: LocalizationFactory.php:28
‪TYPO3\CMS\Core\Localization\Locales
Definition: Locales.php:30
‪TYPO3\CMS\Core\Localization
‪TYPO3\CMS\Core\Localization\LanguageServiceFactory\__construct
‪__construct(Locales $locales, LocalizationFactory $localizationFactory)
Definition: LanguageServiceFactory.php:35
‪TYPO3\CMS\Core\Localization\LanguageServiceFactory\$localizationFactory
‪LocalizationFactory $localizationFactory
Definition: LanguageServiceFactory.php:33
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:42
‪TYPO3\CMS\Core\Localization\LanguageServiceFactory\$locales
‪Locales $locales
Definition: LanguageServiceFactory.php:29
‪TYPO3\CMS\Core\Localization\LanguageServiceFactory\createFromUserPreferences
‪createFromUserPreferences(?AbstractUserAuthentication $user)
Definition: LanguageServiceFactory.php:54
‪TYPO3\CMS\Core\Authentication\AbstractUserAuthentication
Definition: AbstractUserAuthentication.php:51