diff --git a/typo3/sysext/backend/Classes/Middleware/BackendUserAuthenticator.php b/typo3/sysext/backend/Classes/Middleware/BackendUserAuthenticator.php index 0a9e0caf10f011a27f4c0514295dee62815bcfc9..6bf503b81ee26c612e976fa264237cea0fcbaf5f 100644 --- a/typo3/sysext/backend/Classes/Middleware/BackendUserAuthenticator.php +++ b/typo3/sysext/backend/Classes/Middleware/BackendUserAuthenticator.php @@ -25,10 +25,11 @@ use TYPO3\CMS\Backend\Routing\UriBuilder; use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; use TYPO3\CMS\Core\Authentication\Mfa\MfaProviderManifestInterface; use TYPO3\CMS\Core\Authentication\Mfa\MfaRequiredException; +use TYPO3\CMS\Core\Context\Context; use TYPO3\CMS\Core\Controller\ErrorPageController; use TYPO3\CMS\Core\Http\HtmlResponse; use TYPO3\CMS\Core\Http\RedirectResponse; -use TYPO3\CMS\Core\Localization\LanguageService; +use TYPO3\CMS\Core\Localization\LanguageServiceFactory; use TYPO3\CMS\Core\Messaging\AbstractMessage; use TYPO3\CMS\Core\Session\UserSessionManager; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -60,6 +61,16 @@ class BackendUserAuthenticator extends \TYPO3\CMS\Core\Middleware\BackendUserAut '/ajax/core/requirejs', ]; + private LanguageServiceFactory $languageServiceFactory; + + public function __construct( + Context $context, + LanguageServiceFactory $languageServiceFactory + ) { + parent::__construct($context); + $this->languageServiceFactory = $languageServiceFactory; + } + /** * Calls the bootstrap process to set up $GLOBALS['BE_USER'] AND $GLOBALS['LANG'] * @@ -112,7 +123,7 @@ class BackendUserAuthenticator extends \TYPO3\CMS\Core\Middleware\BackendUserAut if ($this->context->getAspect('backend.user')->isLoggedIn()) { $GLOBALS['BE_USER']->initializeBackendLogin(); } - $GLOBALS['LANG'] = LanguageService::createFromUserPreferences($GLOBALS['BE_USER']); + $GLOBALS['LANG'] = $this->languageServiceFactory->createFromUserPreferences($GLOBALS['BE_USER']); // Re-setting the user and take the workspace from the user object now $this->setBackendUserAspect($GLOBALS['BE_USER']); $response = $handler->handle($request); @@ -171,7 +182,7 @@ class BackendUserAuthenticator extends \TYPO3\CMS\Core\Middleware\BackendUserAut ): ResponseInterface { // GLOBALS[LANG] needs to be set up, because the UriBuilder is generating a token, which in turn // needs the FormProtectionFactory, which then builds a Message Closure with GLOBALS[LANG] (hacky, yes!) - $GLOBALS['LANG'] = LanguageService::createFromUserPreferences($user); + $GLOBALS['LANG'] = $this->languageServiceFactory->createFromUserPreferences($user); $uri = GeneralUtility::makeInstance(UriBuilder::class) ->buildUriWithRedirectFromRequest( 'auth_mfa', diff --git a/typo3/sysext/core/Classes/Console/CommandApplication.php b/typo3/sysext/core/Classes/Console/CommandApplication.php index 7103b823db287ae03948a7813f1911158a48d809..61218e5f99416ff6901ba3d1e6d6af078def009c 100644 --- a/typo3/sysext/core/Classes/Console/CommandApplication.php +++ b/typo3/sysext/core/Classes/Console/CommandApplication.php @@ -32,7 +32,7 @@ use TYPO3\CMS\Core\Core\BootService; use TYPO3\CMS\Core\Core\Bootstrap; use TYPO3\CMS\Core\Core\Environment; use TYPO3\CMS\Core\Information\Typo3Version; -use TYPO3\CMS\Core\Localization\LanguageService; +use TYPO3\CMS\Core\Localization\LanguageServiceFactory; /** * Entry point for the TYPO3 Command Line for Commands @@ -48,18 +48,22 @@ class CommandApplication implements ApplicationInterface protected BootService $bootService; + protected LanguageServiceFactory $languageServiceFactory; + protected Application $application; public function __construct( Context $context, CommandRegistry $commandRegistry, ConfigurationManager $configurationMananger, - BootService $bootService + BootService $bootService, + LanguageServiceFactory $languageServiceFactory ) { $this->context = $context; $this->commandRegistry = $commandRegistry; $this->configurationManager = $configurationMananger; $this->bootService = $bootService; + $this->languageServiceFactory = $languageServiceFactory; $this->checkEnvironmentOrDie(); $this->application = new Application('TYPO3 CMS', sprintf( @@ -103,7 +107,7 @@ class CommandApplication implements ApplicationInterface $this->initializeContext(); // create the BE_USER object (not logged in yet) Bootstrap::initializeBackendUser(CommandLineUserAuthentication::class); - $GLOBALS['LANG'] = LanguageService::createFromUserPreferences($GLOBALS['BE_USER']); + $GLOBALS['LANG'] = $this->languageServiceFactory->createFromUserPreferences($GLOBALS['BE_USER']); // Make sure output is not buffered, so command-line output and interaction can take place ob_clean(); diff --git a/typo3/sysext/core/Classes/Core/Bootstrap.php b/typo3/sysext/core/Classes/Core/Bootstrap.php index cf38dbdb50017941f74d75bc73c37560653823ca..bcb53c88a06c08c538bae2902bdace1400784035 100644 --- a/typo3/sysext/core/Classes/Core/Bootstrap.php +++ b/typo3/sysext/core/Classes/Core/Bootstrap.php @@ -35,7 +35,7 @@ use TYPO3\CMS\Core\Database\TableConfigurationPostProcessingHookInterface; use TYPO3\CMS\Core\DependencyInjection\Cache\ContainerBackend; use TYPO3\CMS\Core\DependencyInjection\ContainerBuilder; use TYPO3\CMS\Core\IO\PharStreamWrapperInterceptor; -use TYPO3\CMS\Core\Localization\LanguageService; +use TYPO3\CMS\Core\Localization\LanguageServiceFactory; use TYPO3\CMS\Core\Log\LogManager; use TYPO3\CMS\Core\Package\FailsafePackageManager; use TYPO3\CMS\Core\Package\PackageManager; @@ -592,6 +592,6 @@ class Bootstrap public static function initializeLanguageObject() { /** @var \TYPO3\CMS\Core\Localization\LanguageService $GLOBALS['LANG'] */ - $GLOBALS['LANG'] = LanguageService::createFromUserPreferences($GLOBALS['BE_USER']); + $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageServiceFactory::class)->createFromUserPreferences($GLOBALS['BE_USER']); } } diff --git a/typo3/sysext/core/Classes/Information/Typo3Information.php b/typo3/sysext/core/Classes/Information/Typo3Information.php index f1c461fd7d072a55dcd37372550a42e6b7710483..9dd2aac0dd69f3a20e69a9732d1f253c609388f1 100644 --- a/typo3/sysext/core/Classes/Information/Typo3Information.php +++ b/typo3/sysext/core/Classes/Information/Typo3Information.php @@ -18,6 +18,8 @@ declare(strict_types=1); namespace TYPO3\CMS\Core\Information; use TYPO3\CMS\Core\Localization\LanguageService; +use TYPO3\CMS\Core\Localization\LanguageServiceFactory; +use TYPO3\CMS\Core\Utility\GeneralUtility; /** * Contains information and links, or copyright information for the project. @@ -42,7 +44,7 @@ class Typo3Information } elseif (($GLOBALS['LANG'] ?? null) instanceof LanguageService) { $this->languageService = $GLOBALS['LANG']; } else { - $this->languageService = LanguageService::create('default'); + $this->languageService = GeneralUtility::makeInstance(LanguageServiceFactory::class)->create('default'); } } diff --git a/typo3/sysext/core/Classes/Localization/LanguageService.php b/typo3/sysext/core/Classes/Localization/LanguageService.php index c93a6cd4e378de50257e8ab8cc1d2b18e94eed5f..a13dbb4f349e31f9531f1604dfd984c9c949471e 100644 --- a/typo3/sysext/core/Classes/Localization/LanguageService.php +++ b/typo3/sysext/core/Classes/Localization/LanguageService.php @@ -104,8 +104,7 @@ class LanguageService /** * Initializes the language to fetch XLF labels for. - * $languageService = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Localization\LanguageService::class); - * $languageService->init($GLOBALS['BE_USER']->user['lang']); + * $languageService = GeneralUtility::makeInstance(LanguageServiceFactory::class)->createFromUserPreferences($GLOBALS['BE_USER']); * * @throws \RuntimeException * @param string $languageKey The language key (two character string from backend users profile) @@ -356,22 +355,29 @@ class LanguageService * * @param string $locale the locale (= the TYPO3-internal locale given) * @return static + * @deprecated since TYPO3 v11.3, will be removed in v12.0 */ public static function create(string $locale): self { + trigger_error('Method ' . __METHOD__ . ' is deprecated and will be removed in TYPO3 12.0 Use LanguageServiceFactory instead.', E_USER_DEPRECATED); return GeneralUtility::makeInstance(LanguageServiceFactory::class)->create($locale); } + /** + * @deprecated since TYPO3 v11.3, will be removed in v12.0 + */ public static function createFromUserPreferences(?AbstractUserAuthentication $user): self { - if ($user->user['lang'] ?? false) { - return static::create($user->user['lang']); - } - return static::create('default'); + trigger_error('Method ' . __METHOD__ . ' is deprecated and will be removed in TYPO3 12.0 Use LanguageServiceFactory instead.', E_USER_DEPRECATED); + return GeneralUtility::makeInstance(LanguageServiceFactory::class)->createFromUserPreferences($user); } + /** + * @deprecated since TYPO3 v11.3, will be removed in v12.0 + */ public static function createFromSiteLanguage(SiteLanguage $language): self { - return static::create($language->getTypo3Language()); + trigger_error('Method ' . __METHOD__ . ' is deprecated and will be removed in TYPO3 12.0 Use LanguageServiceFactory instead.', E_USER_DEPRECATED); + return GeneralUtility::makeInstance(LanguageServiceFactory::class)->createFromSiteLanguage($language); } } diff --git a/typo3/sysext/core/Classes/Localization/LanguageServiceFactory.php b/typo3/sysext/core/Classes/Localization/LanguageServiceFactory.php index 3768d42bf592c49ab91bbc0a681c8baa38bf8b1e..d4065621f1daab80ebf45c1ce09ee2234c14ab2b 100644 --- a/typo3/sysext/core/Classes/Localization/LanguageServiceFactory.php +++ b/typo3/sysext/core/Classes/Localization/LanguageServiceFactory.php @@ -17,9 +17,9 @@ declare(strict_types=1); namespace TYPO3\CMS\Core\Localization; -/** - * @internal - */ +use TYPO3\CMS\Core\Authentication\AbstractUserAuthentication; +use TYPO3\CMS\Core\Site\Entity\SiteLanguage; + class LanguageServiceFactory { /** @@ -50,4 +50,17 @@ class LanguageServiceFactory $obj->init($locale); return $obj; } + + public function createFromUserPreferences(?AbstractUserAuthentication $user): LanguageService + { + if ($user->user['lang'] ?? false) { + return $this->create($user->user['lang']); + } + return $this->create('default'); + } + + public function createFromSiteLanguage(SiteLanguage $language): LanguageService + { + return $this->create($language->getTypo3Language()); + } } diff --git a/typo3/sysext/core/Classes/ServiceProvider.php b/typo3/sysext/core/Classes/ServiceProvider.php index 954a8c361020445e56cf12321364aa31f8456764..37e1f1a5fa5560c5731678dec54176e1c18dfd78 100644 --- a/typo3/sysext/core/Classes/ServiceProvider.php +++ b/typo3/sysext/core/Classes/ServiceProvider.php @@ -161,7 +161,8 @@ class ServiceProvider extends AbstractServiceProvider $container->get(Context\Context::class), $container->get(Console\CommandRegistry::class), $container->get(Configuration\ConfigurationManager::class), - $container->get(Core\BootService::class) + $container->get(Core\BootService::class), + $container->get(Localization\LanguageServiceFactory::class) ); } diff --git a/typo3/sysext/core/Configuration/Services.yaml b/typo3/sysext/core/Configuration/Services.yaml index c070b3634e1f74e9757c4d95caa01c4e115bcfbe..5dc6ba4f572b683f0b893d26983608641d88ee15 100644 --- a/typo3/sysext/core/Configuration/Services.yaml +++ b/typo3/sysext/core/Configuration/Services.yaml @@ -134,13 +134,16 @@ services: method: 'addCategoryDatabaseSchema' # @internal - # @todo: deprecate makeInstance(LanguageService::class) # This service entry is provided for legacy code that instantiates LanguageService # using GeneralUtility::makeInstance instead of the factory methods which itself # use LanguageServiceFactory (for install tool compatibility). TYPO3\CMS\Core\Localization\LanguageService: shared: false public: true + deprecated: + package: 'typo3/cms-core' + version: '11.3' + message: 'Injection/Instantiation of "%service_id%" is deprecated. Please use TYPO3\CMS\Core\Localization\LanguageServiceFactory->create().' TYPO3\CMS\Core\ExpressionLanguage\ProviderConfigurationLoader: public: true diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-94414-DeprecateLanguageServiceContainerEntry.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-94414-DeprecateLanguageServiceContainerEntry.rst new file mode 100644 index 0000000000000000000000000000000000000000..d8c6af242bded042dfd65d36316c4ad601d5711d --- /dev/null +++ b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-94414-DeprecateLanguageServiceContainerEntry.rst @@ -0,0 +1,53 @@ +.. include:: ../../Includes.txt + +=============================================================== +Deprecation: #94414 - Deprecate LanguageService Container Entry +=============================================================== + +See :issue:`94414` + +Description +=========== + +Instances of :php:`TYPO3\CMS\Core\Localization\LanguageService` require +custom initialization with a language key and additionally depend on core services. +:php:`TYPO3\CMS\Core\Localization\LanguageServiceFactory` has therefore +previously been introduced in order to manage this initialization. +This replaced prior used instantiation via +:php:`TYPO3\CMS\Core\Localization\LanguageService::create()` or +:php:`GeneralUtility::makeInstance(LanguageService::class)`. + + +Impact +====== + +Injecting :php:`TYPO3\CMS\Core\Localization\LanguageService` or creating +instances via :php:`GeneralUtility::makeInstance(LanguageService::class)`, +:php:`LanguageService::create()`, :php:`LanguageService::createFromUserPreferences()` +or :php:`LanguageService::createFromSiteLanguage()` will trigger a +PHP :php:`E_USER_DEPRECATED` error. + + +Affected Installations +====================== + +Extensions injecting :php:`TYPO3\CMS\Core\Localization\LanguageService` +or creating custom instances via :php:`GeneralUtility::makeInstance(LanguageService::class)` +or :php:`TYPO3\CMS\Core\Localization\LanguageService::create()`. + +This is relatively unlikely since most usages are bootstrap related and +extensions usually access the prepared LanguageService via :php:`GLOBALS['LANG']` +in normal cases. + +Usages of :php:`LanguageService::create()`, :php:`LanguageService::createFromUserPreferences()` +and :php:`LanguageService::createFromSiteLanguage()` are be found by the extension scanner +as strong match. + + +Migration +========= + +The factory :php:`TYPO3\CMS\Core\Localization\LanguageServiceFactory` +should be injected and used instead. + +.. index:: Backend, PHP-API, PartiallyScanned, ext:core diff --git a/typo3/sysext/core/Tests/Functional/Authentication/Mfa/Provider/RecoveryCodesProviderTest.php b/typo3/sysext/core/Tests/Functional/Authentication/Mfa/Provider/RecoveryCodesProviderTest.php index 6bb7ae0d0e27f8afb307196f86c356735bbfaf84..85a31fd5cac6b1e504dc80fe9615c554b6549554 100644 --- a/typo3/sysext/core/Tests/Functional/Authentication/Mfa/Provider/RecoveryCodesProviderTest.php +++ b/typo3/sysext/core/Tests/Functional/Authentication/Mfa/Provider/RecoveryCodesProviderTest.php @@ -27,7 +27,7 @@ use TYPO3\CMS\Core\Crypto\PasswordHashing\Argon2iPasswordHash; use TYPO3\CMS\Core\Crypto\PasswordHashing\PasswordHashFactory; use TYPO3\CMS\Core\Http\PropagateResponseException; use TYPO3\CMS\Core\Http\ServerRequest; -use TYPO3\CMS\Core\Localization\LanguageService; +use TYPO3\CMS\Core\Localization\LanguageServiceFactory; use TYPO3\CMS\Core\Messaging\FlashMessageService; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase; @@ -56,7 +56,7 @@ class RecoveryCodesProviderTest extends FunctionalTestCase parent::setUp(); $this->importDataSet(ORIGINAL_ROOT . 'typo3/sysext/core/Tests/Functional/Fixtures/be_users.xml'); $this->user = $this->setUpBackendUser(1); - $GLOBALS['LANG'] = LanguageService::createFromUserPreferences($this->user); + $GLOBALS['LANG'] = $this->getContainer()->get(LanguageServiceFactory::class)->createFromUserPreferences($this->user); $this->subject = $this->getContainer()->get(MfaProviderRegistry::class)->getProvider('recovery-codes'); } diff --git a/typo3/sysext/core/Tests/Functional/Authentication/Mfa/Provider/TotpProviderTest.php b/typo3/sysext/core/Tests/Functional/Authentication/Mfa/Provider/TotpProviderTest.php index cbab86ec8351af112269b36ced3d3495e4216983..9465e19fd27503bed226e937554192c38656001c 100644 --- a/typo3/sysext/core/Tests/Functional/Authentication/Mfa/Provider/TotpProviderTest.php +++ b/typo3/sysext/core/Tests/Functional/Authentication/Mfa/Provider/TotpProviderTest.php @@ -25,7 +25,7 @@ use TYPO3\CMS\Core\Authentication\Mfa\MfaViewType; use TYPO3\CMS\Core\Authentication\Mfa\Provider\Totp; use TYPO3\CMS\Core\Context\Context; use TYPO3\CMS\Core\Http\ServerRequest; -use TYPO3\CMS\Core\Localization\LanguageService; +use TYPO3\CMS\Core\Localization\LanguageServiceFactory; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase; @@ -39,7 +39,7 @@ class TotpProviderTest extends FunctionalTestCase parent::setUp(); $this->importDataSet(ORIGINAL_ROOT . 'typo3/sysext/core/Tests/Functional/Fixtures/be_users.xml'); $this->user = $this->setUpBackendUser(1); - $GLOBALS['LANG'] = LanguageService::createFromUserPreferences($this->user); + $GLOBALS['LANG'] = $this->getContainer()->get(LanguageServiceFactory::class)->createFromUserPreferences($this->user); $this->subject = $this->getContainer()->get(MfaProviderRegistry::class)->getProvider('totp'); } diff --git a/typo3/sysext/core/Tests/Functional/Database/QueryGeneratorTest.php b/typo3/sysext/core/Tests/Functional/Database/QueryGeneratorTest.php index 8c556ad73dfc4cda382424b51d9e92181395a3fb..5f97cdcabe62e1293ee1df292d03ca25249f49b4 100644 --- a/typo3/sysext/core/Tests/Functional/Database/QueryGeneratorTest.php +++ b/typo3/sysext/core/Tests/Functional/Database/QueryGeneratorTest.php @@ -19,7 +19,7 @@ namespace TYPO3\CMS\Core\Tests\Functional\Database; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Database\QueryGenerator; -use TYPO3\CMS\Core\Localization\LanguageService; +use TYPO3\CMS\Core\Localization\LanguageServiceFactory; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase; @@ -32,7 +32,7 @@ class QueryGeneratorTest extends FunctionalTestCase { parent::setUp(); $this->setUpBackendUserFromFixture(1); - $GLOBALS['LANG'] = LanguageService::create('default'); + $GLOBALS['LANG'] = $this->getContainer()->get(LanguageServiceFactory::class)->create('default'); } /** diff --git a/typo3/sysext/core/Tests/Functional/Localization/LanguageServiceTest.php b/typo3/sysext/core/Tests/Functional/Localization/LanguageServiceTest.php index 2689b83c833bea1ab86dd38c191c793f8f28948e..50c668d950cee983db3bb8c194158ca188335fe5 100644 --- a/typo3/sysext/core/Tests/Functional/Localization/LanguageServiceTest.php +++ b/typo3/sysext/core/Tests/Functional/Localization/LanguageServiceTest.php @@ -18,19 +18,17 @@ declare(strict_types=1); namespace TYPO3\CMS\Core\Tests\Functional\Localization; use TYPO3\CMS\Core\Localization\LanguageService; +use TYPO3\CMS\Core\Localization\LanguageServiceFactory; use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase; class LanguageServiceTest extends FunctionalTestCase { - /** - * @var LanguageService - */ - protected $subject; + protected LanguageService $subject; protected function setUp(): void { parent::setUp(); - $this->subject = LanguageService::create('default'); + $this->subject = $this->getContainer()->get(LanguageServiceFactory::class)->create('default'); } /** diff --git a/typo3/sysext/core/Tests/Functional/Page/PageRendererTest.php b/typo3/sysext/core/Tests/Functional/Page/PageRendererTest.php index dfc447d50969a0d2403521b4fd6c98fa1beaeb4c..4225dea0d46e116ce50c14f072033d769a58faff 100644 --- a/typo3/sysext/core/Tests/Functional/Page/PageRendererTest.php +++ b/typo3/sysext/core/Tests/Functional/Page/PageRendererTest.php @@ -21,7 +21,7 @@ use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; use TYPO3\CMS\Core\Authentication\IpLocker; use TYPO3\CMS\Core\Core\SystemEnvironmentBuilder; use TYPO3\CMS\Core\Http\ServerRequest; -use TYPO3\CMS\Core\Localization\LanguageService; +use TYPO3\CMS\Core\Localization\LanguageServiceFactory; use TYPO3\CMS\Core\Page\PageRenderer; use TYPO3\CMS\Core\Session\Backend\SessionBackendInterface; use TYPO3\CMS\Core\Session\UserSessionManager; @@ -323,7 +323,7 @@ class PageRendererTest extends FunctionalTestCase $GLOBALS['BE_USER']->user = ['uid' => 1]; $GLOBALS['BE_USER']->setLogger(new NullLogger()); - $GLOBALS['LANG'] = LanguageService::createFromUserPreferences($GLOBALS['BE_USER']); + $GLOBALS['LANG'] = $this->getContainer()->get(LanguageServiceFactory::class)->createFromUserPreferences($GLOBALS['BE_USER']); $GLOBALS['TYPO3_REQUEST'] = (new ServerRequest()) ->withAttribute('applicationType', SystemEnvironmentBuilder::REQUESTTYPE_BE); diff --git a/typo3/sysext/core/Tests/Functional/Tca/BackendGroupsVisibleFieldsTest.php b/typo3/sysext/core/Tests/Functional/Tca/BackendGroupsVisibleFieldsTest.php index 310b2161d72b9915fca3499e20367d5631a0fbeb..f2628bf4410258fa29958fdff3c56bba1f50451e 100644 --- a/typo3/sysext/core/Tests/Functional/Tca/BackendGroupsVisibleFieldsTest.php +++ b/typo3/sysext/core/Tests/Functional/Tca/BackendGroupsVisibleFieldsTest.php @@ -16,7 +16,7 @@ namespace TYPO3\CMS\Core\Tests\Functional\Tca; use TYPO3\CMS\Backend\Tests\Functional\Form\FormTestService; -use TYPO3\CMS\Core\Localization\LanguageService; +use TYPO3\CMS\Core\Localization\LanguageServiceFactory; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase; @@ -48,7 +48,7 @@ class BackendGroupsVisibleFieldsTest extends FunctionalTestCase public function backendGroupsFormContainsExpectedFields() { $this->setUpBackendUserFromFixture(1); - $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageService::class); + $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageServiceFactory::class)->create('default'); $formEngineTestService = GeneralUtility::makeInstance(FormTestService::class); $formResult = $formEngineTestService->createNewRecordForm('be_groups'); diff --git a/typo3/sysext/core/Tests/Functional/Tca/BackendUsersVisibleFieldsTest.php b/typo3/sysext/core/Tests/Functional/Tca/BackendUsersVisibleFieldsTest.php index 53413cab13b2b5815b79bdb9d8f2ea1d10de41fe..25eae0b0c56a09a09b910cb68c4117a69d723d17 100644 --- a/typo3/sysext/core/Tests/Functional/Tca/BackendUsersVisibleFieldsTest.php +++ b/typo3/sysext/core/Tests/Functional/Tca/BackendUsersVisibleFieldsTest.php @@ -16,7 +16,7 @@ namespace TYPO3\CMS\Core\Tests\Functional\Tca; use TYPO3\CMS\Backend\Tests\Functional\Form\FormTestService; -use TYPO3\CMS\Core\Localization\LanguageService; +use TYPO3\CMS\Core\Localization\LanguageServiceFactory; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase; @@ -64,7 +64,7 @@ class BackendUsersVisibleFieldsTest extends FunctionalTestCase public function backendUsersFormContainsExpectedFields() { $this->setUpBackendUserFromFixture(1); - $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageService::class); + $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageServiceFactory::class)->create('default'); $formEngineTestService = GeneralUtility::makeInstance(FormTestService::class); $formResult = $formEngineTestService->createNewRecordForm('be_users'); @@ -90,7 +90,7 @@ class BackendUsersVisibleFieldsTest extends FunctionalTestCase public function backendUsersFormContainsExpectedFieldsForAdmins() { $this->setUpBackendUserFromFixture(1); - $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageService::class); + $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageServiceFactory::class)->create('default'); $formEngineTestService = GeneralUtility::makeInstance(FormTestService::class); $formResult = $formEngineTestService->createNewRecordForm('be_users', ['admin' => true]); diff --git a/typo3/sysext/core/Tests/Functional/Tca/CategoryVisibleFieldsTest.php b/typo3/sysext/core/Tests/Functional/Tca/CategoryVisibleFieldsTest.php index bd2ebe9181d458b8704e402ee4ea61bfe2152ab5..829cb2ae3cf469dde900b6a8ad7d02382aeb1e62 100644 --- a/typo3/sysext/core/Tests/Functional/Tca/CategoryVisibleFieldsTest.php +++ b/typo3/sysext/core/Tests/Functional/Tca/CategoryVisibleFieldsTest.php @@ -16,7 +16,7 @@ namespace TYPO3\CMS\Core\Tests\Functional\Tca; use TYPO3\CMS\Backend\Tests\Functional\Form\FormTestService; -use TYPO3\CMS\Core\Localization\LanguageService; +use TYPO3\CMS\Core\Localization\LanguageServiceFactory; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase; @@ -39,7 +39,7 @@ class CategoryVisibleFieldsTest extends FunctionalTestCase public function categoryFormContainsExpectedFields() { $this->setUpBackendUserFromFixture(1); - $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageService::class); + $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageServiceFactory::class)->create('default'); $formEngineTestService = GeneralUtility::makeInstance(FormTestService::class); $formResult = $formEngineTestService->createNewRecordForm('sys_category'); diff --git a/typo3/sysext/core/Tests/Functional/Tca/FileCollectionVisibleFieldsTest.php b/typo3/sysext/core/Tests/Functional/Tca/FileCollectionVisibleFieldsTest.php index d3a5c34b3dd3f1f0e947af85e9eddf08db056cf9..26a946ea7760c976636aab30ed709a9d037dff53 100644 --- a/typo3/sysext/core/Tests/Functional/Tca/FileCollectionVisibleFieldsTest.php +++ b/typo3/sysext/core/Tests/Functional/Tca/FileCollectionVisibleFieldsTest.php @@ -16,7 +16,7 @@ namespace TYPO3\CMS\Core\Tests\Functional\Tca; use TYPO3\CMS\Backend\Tests\Functional\Form\FormTestService; -use TYPO3\CMS\Core\Localization\LanguageService; +use TYPO3\CMS\Core\Localization\LanguageServiceFactory; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase; @@ -47,7 +47,7 @@ class FileCollectionVisibleFieldsTest extends FunctionalTestCase public function fileCollectionFormContainsExpectedFields() { $this->setUpBackendUserFromFixture(1); - $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageService::class); + $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageServiceFactory::class)->create('default'); $formEngineTestService = GeneralUtility::makeInstance(FormTestService::class); diff --git a/typo3/sysext/core/Tests/Functional/Tca/FileMetadataVisibleFieldsTest.php b/typo3/sysext/core/Tests/Functional/Tca/FileMetadataVisibleFieldsTest.php index d9a62eeeae6a0ff62fb2ae15fa1fb9cb8fabbcd4..2d831aeab9d4b775bf5caced38017189574f35a0 100644 --- a/typo3/sysext/core/Tests/Functional/Tca/FileMetadataVisibleFieldsTest.php +++ b/typo3/sysext/core/Tests/Functional/Tca/FileMetadataVisibleFieldsTest.php @@ -16,7 +16,7 @@ namespace TYPO3\CMS\Core\Tests\Functional\Tca; use TYPO3\CMS\Backend\Tests\Functional\Form\FormTestService; -use TYPO3\CMS\Core\Localization\LanguageService; +use TYPO3\CMS\Core\Localization\LanguageServiceFactory; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase; @@ -35,7 +35,7 @@ class FileMetadataVisibleFieldsTest extends FunctionalTestCase public function fileMetadataFormContainsExpectedFields() { $this->setUpBackendUserFromFixture(1); - $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageService::class); + $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageServiceFactory::class)->create('default'); $formEngineTestService = GeneralUtility::makeInstance(FormTestService::class); $formResult = $formEngineTestService->createNewRecordForm('sys_file_metadata'); diff --git a/typo3/sysext/core/Tests/Functional/Tca/FileStorageVisibleFieldsTest.php b/typo3/sysext/core/Tests/Functional/Tca/FileStorageVisibleFieldsTest.php index b32a79a3abe71132d135f066fc6a6dbe35eb6bd4..0b02dd2a56cc01306c8d57bd52dd3f478b827018 100644 --- a/typo3/sysext/core/Tests/Functional/Tca/FileStorageVisibleFieldsTest.php +++ b/typo3/sysext/core/Tests/Functional/Tca/FileStorageVisibleFieldsTest.php @@ -16,7 +16,7 @@ namespace TYPO3\CMS\Core\Tests\Functional\Tca; use TYPO3\CMS\Backend\Tests\Functional\Form\FormTestService; -use TYPO3\CMS\Core\Localization\LanguageService; +use TYPO3\CMS\Core\Localization\LanguageServiceFactory; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase; @@ -41,7 +41,7 @@ class FileStorageVisibleFieldsTest extends FunctionalTestCase public function fileStorageFormContainsExpectedFields() { $this->setUpBackendUserFromFixture(1); - $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageService::class); + $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageServiceFactory::class)->create('default'); $formEngineTestService = GeneralUtility::makeInstance(FormTestService::class); $formResult = $formEngineTestService->createNewRecordForm('sys_file_storage'); diff --git a/typo3/sysext/core/Tests/Functional/Tca/FilemountsVisibleFieldsTest.php b/typo3/sysext/core/Tests/Functional/Tca/FilemountsVisibleFieldsTest.php index 5292db66906687071502fd5427fbec2400936325..a7afc425ca4db58deb7d751d3ce7ed6579496be7 100644 --- a/typo3/sysext/core/Tests/Functional/Tca/FilemountsVisibleFieldsTest.php +++ b/typo3/sysext/core/Tests/Functional/Tca/FilemountsVisibleFieldsTest.php @@ -16,7 +16,7 @@ namespace TYPO3\CMS\Core\Tests\Functional\Tca; use TYPO3\CMS\Backend\Tests\Functional\Form\FormTestService; -use TYPO3\CMS\Core\Localization\LanguageService; +use TYPO3\CMS\Core\Localization\LanguageServiceFactory; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase; @@ -37,7 +37,7 @@ class FilemountsVisibleFieldsTest extends FunctionalTestCase public function filemountsFormContainsExpectedFields() { $this->setUpBackendUserFromFixture(1); - $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageService::class); + $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageServiceFactory::class)->create('default'); $formEngineTestService = GeneralUtility::makeInstance(FormTestService::class); $formResult = $formEngineTestService->createNewRecordForm('sys_filemounts', ['base' => 1]); diff --git a/typo3/sysext/core/Tests/Functional/Tca/LanguageVisibleFieldsTest.php b/typo3/sysext/core/Tests/Functional/Tca/LanguageVisibleFieldsTest.php index 8c20dd795907b352b97d8756bb63e0d3675610e2..944c7e35737e95d95e0b060f2893cf312d9ab024 100644 --- a/typo3/sysext/core/Tests/Functional/Tca/LanguageVisibleFieldsTest.php +++ b/typo3/sysext/core/Tests/Functional/Tca/LanguageVisibleFieldsTest.php @@ -16,7 +16,7 @@ namespace TYPO3\CMS\Core\Tests\Functional\Tca; use TYPO3\CMS\Backend\Tests\Functional\Form\FormTestService; -use TYPO3\CMS\Core\Localization\LanguageService; +use TYPO3\CMS\Core\Localization\LanguageServiceFactory; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase; @@ -35,7 +35,7 @@ class LanguageVisibleFieldsTest extends FunctionalTestCase public function languageFormContainsExpectedFields() { $this->setUpBackendUserFromFixture(1); - $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageService::class); + $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageServiceFactory::class)->create('default'); $formEngineTestService = GeneralUtility::makeInstance(FormTestService::class); $formResult = $formEngineTestService->createNewRecordForm('sys_language', ['base' => 1]); diff --git a/typo3/sysext/core/Tests/Functional/Tca/NewsVisibleFieldsTest.php b/typo3/sysext/core/Tests/Functional/Tca/NewsVisibleFieldsTest.php index 6af887e17d0a925f176ceb9f9a364ecd62373322..fa34b1e04ab45a8ec9b39ab9e7c1c96b5c5fc394 100644 --- a/typo3/sysext/core/Tests/Functional/Tca/NewsVisibleFieldsTest.php +++ b/typo3/sysext/core/Tests/Functional/Tca/NewsVisibleFieldsTest.php @@ -16,7 +16,7 @@ namespace TYPO3\CMS\Core\Tests\Functional\Tca; use TYPO3\CMS\Backend\Tests\Functional\Form\FormTestService; -use TYPO3\CMS\Core\Localization\LanguageService; +use TYPO3\CMS\Core\Localization\LanguageServiceFactory; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase; @@ -36,7 +36,7 @@ class NewsVisibleFieldsTest extends FunctionalTestCase public function newsFormContainsExpectedFields() { $this->setUpBackendUserFromFixture(1); - $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageService::class); + $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageServiceFactory::class)->create('default'); $formEngineTestService = GeneralUtility::makeInstance(FormTestService::class); $formResult = $formEngineTestService->createNewRecordForm('sys_news'); diff --git a/typo3/sysext/core/Tests/Functional/Tca/PagesVisibleFieldsTest.php b/typo3/sysext/core/Tests/Functional/Tca/PagesVisibleFieldsTest.php index dbd8ad3515a5aad739a020c506739c49fef481cb..536ac1f85d24b2299482de904da8a9903f689cab 100644 --- a/typo3/sysext/core/Tests/Functional/Tca/PagesVisibleFieldsTest.php +++ b/typo3/sysext/core/Tests/Functional/Tca/PagesVisibleFieldsTest.php @@ -17,7 +17,7 @@ namespace TYPO3\CMS\Core\Tests\Functional\Tca; use TYPO3\CMS\Backend\Tests\Functional\Form\FormTestService; use TYPO3\CMS\Core\Domain\Repository\PageRepository; -use TYPO3\CMS\Core\Localization\LanguageService; +use TYPO3\CMS\Core\Localization\LanguageServiceFactory; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase; @@ -240,7 +240,7 @@ class PagesVisibleFieldsTest extends FunctionalTestCase public function pagesFormContainsExpectedFields(int $doktype, array $expectedFields, array $hiddenFields) { $this->setUpBackendUserFromFixture(1); - $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageService::class); + $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageServiceFactory::class)->create('default'); $formEngineTestService = GeneralUtility::makeInstance(FormTestService::class); $formResult = $formEngineTestService->createNewRecordForm('pages', ['doktype' => $doktype]); diff --git a/typo3/sysext/extbase/Tests/Functional/Mvc/Validation/ActionControllerValidationTest.php b/typo3/sysext/extbase/Tests/Functional/Mvc/Validation/ActionControllerValidationTest.php index b0047104a486197fe182d968bcb01d73db588a93..b8de42325da1513a138b7d8f6cbacca69df67d69 100644 --- a/typo3/sysext/extbase/Tests/Functional/Mvc/Validation/ActionControllerValidationTest.php +++ b/typo3/sysext/extbase/Tests/Functional/Mvc/Validation/ActionControllerValidationTest.php @@ -17,7 +17,7 @@ namespace TYPO3\CMS\Extbase\Tests\Functional\Mvc\Validation; use ExtbaseTeam\BlogExample\Controller\BlogController; use TYPO3\CMS\Core\Http\Response; -use TYPO3\CMS\Core\Localization\LanguageService; +use TYPO3\CMS\Core\Localization\LanguageServiceFactory; use TYPO3\CMS\Extbase\Error\Error; use TYPO3\CMS\Extbase\Error\Result; use TYPO3\CMS\Extbase\Http\ForwardResponse; @@ -68,7 +68,7 @@ class ActionControllerValidationTest extends FunctionalTestCase */ public function forwardedActionValidatesPreviouslyIgnoredArgument(array $blogPostArgument, array $trustedProperties, array $expectedErrorCodes) { - $GLOBALS['LANG'] = $this->getContainer()->get(LanguageService::class); + $GLOBALS['LANG'] = $this->getContainer()->get(LanguageServiceFactory::class)->create('default'); $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] = 'testkey'; $this->importDataSet('PACKAGE:typo3/testing-framework/Resources/Core/Functional/Fixtures/pages.xml'); @@ -119,7 +119,7 @@ class ActionControllerValidationTest extends FunctionalTestCase */ public function validationResultsAreProvidedForTheSameObjectInDifferentArguments() { - $GLOBALS['LANG'] = $this->getContainer()->get(LanguageService::class); + $GLOBALS['LANG'] = $this->getContainer()->get(LanguageServiceFactory::class)->create('default'); $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] = 'testkey'; $this->importDataSet('PACKAGE:typo3/testing-framework/Resources/Core/Functional/Fixtures/pages.xml'); diff --git a/typo3/sysext/extbase/Tests/Functional/Validation/Validator/RegularExpressionValidatorTest.php b/typo3/sysext/extbase/Tests/Functional/Validation/Validator/RegularExpressionValidatorTest.php index 1a11f8c1273c236887e812216b37fd14871d9ec5..6db225267e23a7428ac6239a2ca0c0070cfb4407 100644 --- a/typo3/sysext/extbase/Tests/Functional/Validation/Validator/RegularExpressionValidatorTest.php +++ b/typo3/sysext/extbase/Tests/Functional/Validation/Validator/RegularExpressionValidatorTest.php @@ -4,7 +4,7 @@ declare(strict_types=1); namespace TYPO3\CMS\Extbase\Tests\Functional\Validation\Validator; -use TYPO3\CMS\Core\Localization\LanguageService; +use TYPO3\CMS\Core\Localization\LanguageServiceFactory; use TYPO3\CMS\Extbase\Validation\Error; use TYPO3\CMS\Extbase\Validation\Exception\InvalidValidationOptionsException; use TYPO3\CMS\Extbase\Validation\Validator\RegularExpressionValidator; @@ -15,7 +15,7 @@ class RegularExpressionValidatorTest extends FunctionalTestCase protected function setUp(): void { parent::setUp(); - $GLOBALS['LANG'] = LanguageService::create('default'); + $GLOBALS['LANG'] = $this->getContainer()->get(LanguageServiceFactory::class)->create('default'); } public function customErrorMessagesDataProvider(): array diff --git a/typo3/sysext/extensionmanager/Classes/Report/ExtensionStatus.php b/typo3/sysext/extensionmanager/Classes/Report/ExtensionStatus.php index e5e759e01d13e88661ddcb24f18fea673721ea01..faf6c081bafe4143889469595878c9e0f4065812 100644 --- a/typo3/sysext/extensionmanager/Classes/Report/ExtensionStatus.php +++ b/typo3/sysext/extensionmanager/Classes/Report/ExtensionStatus.php @@ -16,6 +16,7 @@ namespace TYPO3\CMS\Extensionmanager\Report; use TYPO3\CMS\Core\Localization\LanguageService; +use TYPO3\CMS\Core\Localization\LanguageServiceFactory; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extensionmanager\Domain\Model\Extension; use TYPO3\CMS\Extensionmanager\Remote\RemoteRegistry; @@ -67,7 +68,8 @@ class ExtensionStatus implements StatusProviderInterface { $this->remoteRegistry = $remoteRegistry ?? GeneralUtility::makeInstance(RemoteRegistry::class); $this->listUtility = GeneralUtility::makeInstance(ListUtility::class); - $this->languageService = $languageService ?? LanguageService::createFromUserPreferences($GLOBALS['BE_USER'] ?? null); + + $this->languageService = $languageService ?? GeneralUtility::makeInstance(LanguageServiceFactory::class)->createFromUserPreferences($GLOBALS['BE_USER'] ?? null); $this->languageService->includeLLFile('EXT:extensionmanager/Resources/Private/Language/locallang.xlf'); } diff --git a/typo3/sysext/felogin/Tests/Functional/Tca/ContentVisibleFieldsTest.php b/typo3/sysext/felogin/Tests/Functional/Tca/ContentVisibleFieldsTest.php index 828eeb71b095e58aea0e45d752ed9c3aa41a4b10..203138e8b67192ec061c0e5c342a74c7488b8248 100644 --- a/typo3/sysext/felogin/Tests/Functional/Tca/ContentVisibleFieldsTest.php +++ b/typo3/sysext/felogin/Tests/Functional/Tca/ContentVisibleFieldsTest.php @@ -18,7 +18,7 @@ declare(strict_types=1); namespace TYPO3\CMS\FrontendLogin\Tests\Functional\Tca; use TYPO3\CMS\Backend\Tests\Functional\Form\FormTestService; -use TYPO3\CMS\Core\Localization\LanguageService; +use TYPO3\CMS\Core\Localization\LanguageServiceFactory; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase; @@ -55,7 +55,7 @@ class ContentVisibleFieldsTest extends FunctionalTestCase public function loginFormContainsExpectedFields(): void { $this->setUpBackendUserFromFixture(1); - $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageService::class); + $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageServiceFactory::class)->create('default'); $formEngineTestService = GeneralUtility::makeInstance(FormTestService::class); $formResult = $formEngineTestService->createNewRecordForm('tt_content', ['CType' => 'felogin_login']); diff --git a/typo3/sysext/filemetadata/Tests/Functional/Tca/FileMetadataVisibleFieldsTest.php b/typo3/sysext/filemetadata/Tests/Functional/Tca/FileMetadataVisibleFieldsTest.php index 3903e1007a0376af98d2943831c864f021e37a2b..623f531574103cc2309b9407dc30b6dfbceb8b86 100644 --- a/typo3/sysext/filemetadata/Tests/Functional/Tca/FileMetadataVisibleFieldsTest.php +++ b/typo3/sysext/filemetadata/Tests/Functional/Tca/FileMetadataVisibleFieldsTest.php @@ -16,7 +16,7 @@ namespace TYPO3\CMS\Filemetadata\Tests\Functional\Tca; use TYPO3\CMS\Backend\Tests\Functional\Form\FormTestService; -use TYPO3\CMS\Core\Localization\LanguageService; +use TYPO3\CMS\Core\Localization\LanguageServiceFactory; use TYPO3\CMS\Core\Resource\File; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase; @@ -149,7 +149,7 @@ class FileMetadataVisibleFieldsTest extends FunctionalTestCase public function fileMetadataFormContainsExpectedFields() { $this->setUpBackendUserFromFixture(1); - $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageService::class); + $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageServiceFactory::class)->create('default'); $GLOBALS['TCA']['sys_file_metadata']['ctrl']['type'] = 'fileype'; $formEngineTestService = GeneralUtility::makeInstance(FormTestService::class); diff --git a/typo3/sysext/fluid/Tests/Functional/ViewHelpers/Be/Labels/CshViewHelperTest.php b/typo3/sysext/fluid/Tests/Functional/ViewHelpers/Be/Labels/CshViewHelperTest.php index 480a4f5298102b5f5f02d4f5836e16df4c1780f7..633fe1e32440d21a69ddc0c69095dd7ece5c4aae 100644 --- a/typo3/sysext/fluid/Tests/Functional/ViewHelpers/Be/Labels/CshViewHelperTest.php +++ b/typo3/sysext/fluid/Tests/Functional/ViewHelpers/Be/Labels/CshViewHelperTest.php @@ -17,7 +17,7 @@ declare(strict_types=1); namespace TYPO3\CMS\Fluid\Tests\Functional\ViewHelpers\Be\Labels; -use TYPO3\CMS\Core\Localization\LanguageService; +use TYPO3\CMS\Core\Localization\LanguageServiceFactory; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Fluid\View\StandaloneView; use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase; @@ -28,7 +28,7 @@ class CshViewHelperTest extends FunctionalTestCase { parent::setUp(); if (!isset($GLOBALS['LANG'])) { - $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageService::class); + $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageServiceFactory::class)->create('default'); } } diff --git a/typo3/sysext/fluid_styled_content/Tests/Functional/Tca/ContentVisibleFieldsTest.php b/typo3/sysext/fluid_styled_content/Tests/Functional/Tca/ContentVisibleFieldsTest.php index 3a8465d5dae7cdadc12238b7d9526a1cb5ad2467..17cd571761219af9fa8e9c471792dd904171afda 100644 --- a/typo3/sysext/fluid_styled_content/Tests/Functional/Tca/ContentVisibleFieldsTest.php +++ b/typo3/sysext/fluid_styled_content/Tests/Functional/Tca/ContentVisibleFieldsTest.php @@ -16,7 +16,7 @@ namespace TYPO3\CMS\FluidStyledContent\Tests\Functional\Tca; use TYPO3\CMS\Backend\Tests\Functional\Form\FormTestService; -use TYPO3\CMS\Core\Localization\LanguageService; +use TYPO3\CMS\Core\Localization\LanguageServiceFactory; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase; @@ -64,7 +64,7 @@ class ContentVisibleFieldsTest extends FunctionalTestCase public function contentFormContainsExpectedFields() { $this->setUpBackendUserFromFixture(1); - $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageService::class); + $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageServiceFactory::class)->create('default'); $formEngineTestService = GeneralUtility::makeInstance(FormTestService::class); diff --git a/typo3/sysext/form/Classes/Domain/Configuration/FlexformConfiguration/Processors/FinisherOptionGenerator.php b/typo3/sysext/form/Classes/Domain/Configuration/FlexformConfiguration/Processors/FinisherOptionGenerator.php index 1f71e5e587582f7f16b8251c22228093d5d4e4d9..54d59dc26c2df79a65a23aef31aae5682ae9b2ce 100644 --- a/typo3/sysext/form/Classes/Domain/Configuration/FlexformConfiguration/Processors/FinisherOptionGenerator.php +++ b/typo3/sysext/form/Classes/Domain/Configuration/FlexformConfiguration/Processors/FinisherOptionGenerator.php @@ -17,7 +17,7 @@ declare(strict_types=1); namespace TYPO3\CMS\Form\Domain\Configuration\FlexformConfiguration\Processors; -use TYPO3\CMS\Core\Localization\LanguageService; +use TYPO3\CMS\Core\Localization\LanguageServiceFactory; use TYPO3\CMS\Core\Utility\ArrayUtility; use TYPO3\CMS\Core\Utility\Exception\MissingArrayPathException; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -30,7 +30,7 @@ use TYPO3\CMS\Core\Utility\GeneralUtility; class FinisherOptionGenerator extends AbstractProcessor { /** - * @var \TYPO3\CMS\Core\Localization\LanguageService + * @var \TYPO3\CMS\Core\Localization\LanguageServiceFactory */ protected $languageService; @@ -41,7 +41,7 @@ class FinisherOptionGenerator extends AbstractProcessor { parent::__construct($converterDto); - $this->languageService = GeneralUtility::makeInstance(LanguageService::class); + $this->languageService = GeneralUtility::makeInstance(LanguageServiceFactory::class); $this->languageService->includeLLFile('EXT:form/Resources/Private/Language/Database.xlf'); } diff --git a/typo3/sysext/form/Tests/Functional/Mvc/Validation/MimeTypeValidatorTest.php b/typo3/sysext/form/Tests/Functional/Mvc/Validation/MimeTypeValidatorTest.php index aeac8ea83cbcd410f9443a187d0d3052ab1c5007..3471c0b6d7e2d21d7d50290ac68a018d66372720 100644 --- a/typo3/sysext/form/Tests/Functional/Mvc/Validation/MimeTypeValidatorTest.php +++ b/typo3/sysext/form/Tests/Functional/Mvc/Validation/MimeTypeValidatorTest.php @@ -19,7 +19,7 @@ namespace TYPO3\CMS\Form\Tests\Functional\Mvc\Validation; use org\bovigo\vfs\vfsStream; use org\bovigo\vfs\vfsStreamDirectory; -use TYPO3\CMS\Core\Localization\LanguageService; +use TYPO3\CMS\Core\Localization\LanguageServiceFactory; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Error\Error; use TYPO3\CMS\Form\Mvc\Property\TypeConverter\PseudoFile; @@ -54,7 +54,7 @@ class MimeTypeValidatorTest extends FunctionalTestCase protected function setUp(): void { parent::setUp(); - $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageService::class); + $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageServiceFactory::class)->create('default'); $this->tmp = vfsStream::setup('tmp', null, $this->files); } diff --git a/typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php b/typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php index 538be356ef254494ad3d79bbc65ec2908fb56883..ae914c1f61f31ac2e766a55b9464a3f1d5a8f37c 100644 --- a/typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php +++ b/typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php @@ -48,6 +48,7 @@ use TYPO3\CMS\Core\Http\NormalizedParams; use TYPO3\CMS\Core\Http\PropagateResponseException; use TYPO3\CMS\Core\Http\ServerRequestFactory; use TYPO3\CMS\Core\Localization\LanguageService; +use TYPO3\CMS\Core\Localization\LanguageServiceFactory; use TYPO3\CMS\Core\Locking\Exception\LockAcquireWouldBlockException; use TYPO3\CMS\Core\Locking\LockFactory; use TYPO3\CMS\Core\Locking\LockingStrategyInterface; @@ -3202,7 +3203,7 @@ class TypoScriptFrontendController implements LoggerAwareInterface */ protected function setOutputLanguage() { - $this->languageService = LanguageService::createFromSiteLanguage($this->language); + $this->languageService = GeneralUtility::makeInstance(LanguageServiceFactory::class)->createFromSiteLanguage($this->language); // Always disable debugging for TSFE $this->languageService->debugKey = false; } diff --git a/typo3/sysext/frontend/Classes/Middleware/BackendUserAuthenticator.php b/typo3/sysext/frontend/Classes/Middleware/BackendUserAuthenticator.php index 6a601f2c0f7cac19aaf37292b6df4d7408a2c018..b00d2ee9f35b725f9ed1aebeb18190b74e30d3cf 100644 --- a/typo3/sysext/frontend/Classes/Middleware/BackendUserAuthenticator.php +++ b/typo3/sysext/frontend/Classes/Middleware/BackendUserAuthenticator.php @@ -23,9 +23,10 @@ use Psr\Http\Server\RequestHandlerInterface; use TYPO3\CMS\Backend\FrontendBackendUserAuthentication; use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; use TYPO3\CMS\Core\Authentication\Mfa\MfaRequiredException; +use TYPO3\CMS\Core\Context\Context; use TYPO3\CMS\Core\Core\Bootstrap; use TYPO3\CMS\Core\Http\NormalizedParams; -use TYPO3\CMS\Core\Localization\LanguageService; +use TYPO3\CMS\Core\Localization\LanguageServiceFactory; use TYPO3\CMS\Core\Utility\GeneralUtility; /** @@ -38,6 +39,16 @@ use TYPO3\CMS\Core\Utility\GeneralUtility; */ class BackendUserAuthenticator extends \TYPO3\CMS\Core\Middleware\BackendUserAuthenticator { + private LanguageServiceFactory $languageServiceFactory; + + public function __construct( + Context $context, + LanguageServiceFactory $languageServiceFactory + ) { + parent::__construct($context); + $this->languageServiceFactory = $languageServiceFactory; + } + /** * Creates a backend user authentication object, tries to authenticate a user * @@ -59,7 +70,7 @@ class BackendUserAuthenticator extends \TYPO3\CMS\Core\Middleware\BackendUserAut // like $GLOBALS['LANG'] for labels in the language of the BE User, the router, and ext_tables.php for all modules // So things like Frontend Editing and Admin Panel can use this for generating links to the TYPO3 Backend. if ($GLOBALS['BE_USER'] instanceof FrontendBackendUserAuthentication) { - $GLOBALS['LANG'] = LanguageService::createFromUserPreferences($GLOBALS['BE_USER']); + $GLOBALS['LANG'] = $this->languageServiceFactory->createFromUserPreferences($GLOBALS['BE_USER']); Bootstrap::loadExtTables(); $this->setBackendUserAspect($GLOBALS['BE_USER']); } diff --git a/typo3/sysext/frontend/Tests/Functional/Tca/BackendLayoutVisibleFieldsTest.php b/typo3/sysext/frontend/Tests/Functional/Tca/BackendLayoutVisibleFieldsTest.php index 6c0a208df4b0973d7a6a3804e63f9433773fb261..44b4d67fa76d72a6e29a93d7df15a4282acc9f14 100644 --- a/typo3/sysext/frontend/Tests/Functional/Tca/BackendLayoutVisibleFieldsTest.php +++ b/typo3/sysext/frontend/Tests/Functional/Tca/BackendLayoutVisibleFieldsTest.php @@ -16,7 +16,7 @@ namespace TYPO3\CMS\Frontend\Tests\Functional\Tca; use TYPO3\CMS\Backend\Tests\Functional\Form\FormTestService; -use TYPO3\CMS\Core\Localization\LanguageService; +use TYPO3\CMS\Core\Localization\LanguageServiceFactory; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase; @@ -36,7 +36,7 @@ class BackendLayoutVisibleFieldsTest extends FunctionalTestCase public function backendLayoutsFormContainsExpectedFields() { $this->setUpBackendUserFromFixture(1); - $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageService::class); + $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageServiceFactory::class)->create('default'); $formEngineTestService = GeneralUtility::makeInstance(FormTestService::class); $formResult = $formEngineTestService->createNewRecordForm('backend_layout'); diff --git a/typo3/sysext/frontend/Tests/Functional/Tca/ContentVisibleFieldsTest.php b/typo3/sysext/frontend/Tests/Functional/Tca/ContentVisibleFieldsTest.php index 85488d1d21c67d524298f838e9beb0c3e8f577b0..769aaa4fd12ccae912054e364ad64597d0a37446 100644 --- a/typo3/sysext/frontend/Tests/Functional/Tca/ContentVisibleFieldsTest.php +++ b/typo3/sysext/frontend/Tests/Functional/Tca/ContentVisibleFieldsTest.php @@ -16,7 +16,7 @@ namespace TYPO3\CMS\Frontend\Tests\Functional\Tca; use TYPO3\CMS\Backend\Tests\Functional\Form\FormTestService; -use TYPO3\CMS\Core\Localization\LanguageService; +use TYPO3\CMS\Core\Localization\LanguageServiceFactory; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase; @@ -116,7 +116,7 @@ class ContentVisibleFieldsTest extends FunctionalTestCase public function contentFormContainsExpectedFields() { $this->setUpBackendUserFromFixture(1); - $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageService::class); + $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageServiceFactory::class)->create('default'); $formEngineTestService = GeneralUtility::makeInstance(FormTestService::class); diff --git a/typo3/sysext/frontend/Tests/Functional/Tca/FrontendGroupsVisibleFieldsTest.php b/typo3/sysext/frontend/Tests/Functional/Tca/FrontendGroupsVisibleFieldsTest.php index 495bcb8fcc6819b8ae8ac425ecd9a4ebaddf8546..1effd2960037eebb73f04ea0aa895a8ab706f76d 100644 --- a/typo3/sysext/frontend/Tests/Functional/Tca/FrontendGroupsVisibleFieldsTest.php +++ b/typo3/sysext/frontend/Tests/Functional/Tca/FrontendGroupsVisibleFieldsTest.php @@ -16,7 +16,7 @@ namespace TYPO3\CMS\Frontend\Tests\Functional\Tca; use TYPO3\CMS\Backend\Tests\Functional\Form\FormTestService; -use TYPO3\CMS\Core\Localization\LanguageService; +use TYPO3\CMS\Core\Localization\LanguageServiceFactory; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase; @@ -37,7 +37,7 @@ class FrontendGroupsVisibleFieldsTest extends FunctionalTestCase public function frontendGroupsFormContainsExpectedFields() { $this->setUpBackendUserFromFixture(1); - $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageService::class); + $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageServiceFactory::class)->create('default'); $formEngineTestService = GeneralUtility::makeInstance(FormTestService::class); $formResult = $formEngineTestService->createNewRecordForm('fe_groups'); diff --git a/typo3/sysext/frontend/Tests/Functional/Tca/FrontendUsersVisibleFieldsTest.php b/typo3/sysext/frontend/Tests/Functional/Tca/FrontendUsersVisibleFieldsTest.php index 742f632c39f4e23d7ea9a1b99f0e743079a5d663..130ebad4d24ff87918c0d99d85e986fe58c0d037 100644 --- a/typo3/sysext/frontend/Tests/Functional/Tca/FrontendUsersVisibleFieldsTest.php +++ b/typo3/sysext/frontend/Tests/Functional/Tca/FrontendUsersVisibleFieldsTest.php @@ -16,7 +16,7 @@ namespace TYPO3\CMS\Frontend\Tests\Functional\Tca; use TYPO3\CMS\Backend\Tests\Functional\Form\FormTestService; -use TYPO3\CMS\Core\Localization\LanguageService; +use TYPO3\CMS\Core\Localization\LanguageServiceFactory; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase; @@ -54,7 +54,7 @@ class FrontendUsersVisibleFieldsTest extends FunctionalTestCase public function frontendUsersFormContainsExpectedFields() { $this->setUpBackendUserFromFixture(1); - $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageService::class); + $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageServiceFactory::class)->create('default'); $formEngineTestService = GeneralUtility::makeInstance(FormTestService::class); $formResult = $formEngineTestService->createNewRecordForm('fe_users'); diff --git a/typo3/sysext/frontend/Tests/Functional/Tca/PagesLanguageOverlayVisibleFieldsTest.php b/typo3/sysext/frontend/Tests/Functional/Tca/PagesLanguageOverlayVisibleFieldsTest.php index ce76a1fb77819ac7d1d4c916b8d21934c8321142..5df9f06d770fd94ea57912aee79a615b099b1bb2 100644 --- a/typo3/sysext/frontend/Tests/Functional/Tca/PagesLanguageOverlayVisibleFieldsTest.php +++ b/typo3/sysext/frontend/Tests/Functional/Tca/PagesLanguageOverlayVisibleFieldsTest.php @@ -17,7 +17,7 @@ namespace TYPO3\CMS\Frontend\Tests\Functional\Tca; use TYPO3\CMS\Backend\Tests\Functional\Form\FormTestService; use TYPO3\CMS\Core\Domain\Repository\PageRepository; -use TYPO3\CMS\Core\Localization\LanguageService; +use TYPO3\CMS\Core\Localization\LanguageServiceFactory; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase; @@ -165,7 +165,7 @@ class PagesLanguageOverlayVisibleFieldsTest extends FunctionalTestCase array $hiddenFields ) { $this->setUpBackendUserFromFixture(1); - $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageService::class); + $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageServiceFactory::class)->create('default'); $formEngineTestService = GeneralUtility::makeInstance(FormTestService::class); $formResult = $formEngineTestService->createNewRecordForm('pages', ['doktype' => $doktype]); diff --git a/typo3/sysext/frontend/Tests/Functional/Tca/TemplateVisibleFieldsTest.php b/typo3/sysext/frontend/Tests/Functional/Tca/TemplateVisibleFieldsTest.php index cf9157d1b416b12161f5b057f1bf9ec613be8ed3..4493316a8fa91722b8f6654c2090b1958b9e512a 100644 --- a/typo3/sysext/frontend/Tests/Functional/Tca/TemplateVisibleFieldsTest.php +++ b/typo3/sysext/frontend/Tests/Functional/Tca/TemplateVisibleFieldsTest.php @@ -16,7 +16,7 @@ namespace TYPO3\CMS\Frontend\Tests\Functional\Tca; use TYPO3\CMS\Backend\Tests\Functional\Form\FormTestService; -use TYPO3\CMS\Core\Localization\LanguageService; +use TYPO3\CMS\Core\Localization\LanguageServiceFactory; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase; @@ -44,7 +44,7 @@ class TemplateVisibleFieldsTest extends FunctionalTestCase public function templateFormContainsExpectedFields() { $this->setUpBackendUserFromFixture(1); - $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageService::class); + $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageServiceFactory::class)->create('default'); $formEngineTestService = GeneralUtility::makeInstance(FormTestService::class); $formResult = $formEngineTestService->createNewRecordForm('sys_template'); diff --git a/typo3/sysext/frontend/Tests/Unit/ContentObject/Menu/AbstractMenuContentObjectTest.php b/typo3/sysext/frontend/Tests/Unit/ContentObject/Menu/AbstractMenuContentObjectTest.php index fe2fa637019dd80b9c1c89cf9d5765c47256612f..826e0a1d327017a66fd3b6c3f6bb31d05f08d200 100644 --- a/typo3/sysext/frontend/Tests/Unit/ContentObject/Menu/AbstractMenuContentObjectTest.php +++ b/typo3/sysext/frontend/Tests/Unit/ContentObject/Menu/AbstractMenuContentObjectTest.php @@ -82,7 +82,7 @@ class AbstractMenuContentObjectTest extends UnitTestCase $cacheFrontendProphecy->set(Argument::cetera())->willReturn(null); $languageService = new LanguageService(new Locales(), new LocalizationFactory(new LanguageStore(), $cacheManagerProphecy->reveal())); $languageServiceFactoryProphecy = $this->prophesize(LanguageServiceFactory::class); - $languageServiceFactoryProphecy->create(Argument::any())->willReturn($languageService); + $languageServiceFactoryProphecy->createFromSiteLanguage(Argument::any())->willReturn($languageService); GeneralUtility::addInstance(LanguageServiceFactory::class, $languageServiceFactoryProphecy->reveal()); $frontendUserProphecy = $this->prophesize(FrontendUserAuthentication::class); $GLOBALS['TSFE'] = $this->getMockBuilder(TypoScriptFrontendController::class) diff --git a/typo3/sysext/frontend/Tests/Unit/Controller/TypoScriptFrontendControllerTest.php b/typo3/sysext/frontend/Tests/Unit/Controller/TypoScriptFrontendControllerTest.php index bcb675a9e2933e85b304dc1f1c6b8ec7d024b7fa..22dbacd4e35482cca6f40456e82d9228ef21784f 100644 --- a/typo3/sysext/frontend/Tests/Unit/Controller/TypoScriptFrontendControllerTest.php +++ b/typo3/sysext/frontend/Tests/Unit/Controller/TypoScriptFrontendControllerTest.php @@ -38,6 +38,7 @@ use TYPO3\CMS\Core\Page\PageRenderer; use TYPO3\CMS\Core\PageTitle\PageTitleProviderManager; use TYPO3\CMS\Core\Routing\PageArguments; use TYPO3\CMS\Core\Site\Entity\Site; +use TYPO3\CMS\Core\Site\Entity\SiteLanguage; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\StringUtility; use TYPO3\CMS\Frontend\Authentication\FrontendUserAuthentication; @@ -161,8 +162,8 @@ class TypoScriptFrontendControllerTest extends UnitTestCase $cacheManager->getCache('l10n')->willReturn($nullCacheBackend); $languageService = new LanguageService(new Locales(), new LocalizationFactory(new LanguageStore(), $cacheManager->reveal())); $languageServiceFactoryProphecy = $this->prophesize(LanguageServiceFactory::class); - $languageServiceFactoryProphecy->create(Argument::any())->will(function ($args) use ($languageService) { - $languageService->init($args[0]); + $languageServiceFactoryProphecy->createFromSiteLanguage(Argument::type(SiteLanguage::class))->will(function ($args) use ($languageService) { + $languageService->init($args[0]->getTypo3Language()); return $languageService; }); GeneralUtility::addInstance(LanguageServiceFactory::class, $languageServiceFactoryProphecy->reveal()); @@ -571,8 +572,8 @@ class TypoScriptFrontendControllerTest extends UnitTestCase ]); $languageService = new LanguageService(new Locales(), new LocalizationFactory(new LanguageStore(), $cacheManager->reveal())); $languageServiceFactoryProphecy = $this->prophesize(LanguageServiceFactory::class); - $languageServiceFactoryProphecy->create(Argument::any())->will(function ($args) use ($languageService) { - $languageService->init($args[0]); + $languageServiceFactoryProphecy->createFromSiteLanguage(Argument::type(SiteLanguage::class))->will(function ($args) use ($languageService) { + $languageService->init($args[0]->getTypo3Language()); return $languageService; }); GeneralUtility::addInstance(LanguageServiceFactory::class, $languageServiceFactoryProphecy->reveal()); @@ -607,8 +608,8 @@ class TypoScriptFrontendControllerTest extends UnitTestCase ]); $languageService = new LanguageService(new Locales(), new LocalizationFactory(new LanguageStore(), $cacheManager->reveal())); $languageServiceFactoryProphecy = $this->prophesize(LanguageServiceFactory::class); - $languageServiceFactoryProphecy->create(Argument::any())->will(function ($args) use ($languageService) { - $languageService->init($args[0]); + $languageServiceFactoryProphecy->createFromSiteLanguage(Argument::type(SiteLanguage::class))->will(function ($args) use ($languageService) { + $languageService->init($args[0]->getTypo3Language()); return $languageService; }); GeneralUtility::addInstance(LanguageServiceFactory::class, $languageServiceFactoryProphecy->reveal()); @@ -642,8 +643,8 @@ class TypoScriptFrontendControllerTest extends UnitTestCase GeneralUtility::setSingletonInstance(CacheManager::class, $cacheManager->reveal()); $languageService = new LanguageService(new Locales(), new LocalizationFactory(new LanguageStore(), $cacheManager->reveal())); $languageServiceFactoryProphecy = $this->prophesize(LanguageServiceFactory::class); - $languageServiceFactoryProphecy->create(Argument::any())->will(function ($args) use ($languageService) { - $languageService->init($args[0]); + $languageServiceFactoryProphecy->createFromSiteLanguage(Argument::type(SiteLanguage::class))->will(function ($args) use ($languageService) { + $languageService->init($args[0]->getTypo3Language()); return $languageService; }); GeneralUtility::addInstance(LanguageServiceFactory::class, $languageServiceFactoryProphecy->reveal()); diff --git a/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallStaticMatcher.php b/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallStaticMatcher.php index 646ecfb71e842fb506bcd0ae549543d53c68e678..c98cbc8b05c90d5b486142433cca4e35ee647472 100644 --- a/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallStaticMatcher.php +++ b/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallStaticMatcher.php @@ -1114,4 +1114,25 @@ return [ 'Deprecation-94316-DeprecatedHTTPHeaderManipulatingMethodsFromHttpUtility.rst' ], ], + 'TYPO3\CMS\Core\Localization\LanguageService::create' => [ + 'numberOfMandatoryArguments' => 1, + 'maximumNumberOfArguments' => 1, + 'restFiles' => [ + 'Deprecation-94414-DeprecateLanguageServiceContainerEntry.rst' + ], + ], + 'TYPO3\CMS\Core\Localization\LanguageService::createFromUserPreferences' => [ + 'numberOfMandatoryArguments' => 1, + 'maximumNumberOfArguments' => 1, + 'restFiles' => [ + 'Deprecation-94414-DeprecateLanguageServiceContainerEntry.rst' + ], + ], + 'TYPO3\CMS\Core\Localization\LanguageService::createFromSiteLanguage' => [ + 'numberOfMandatoryArguments' => 1, + 'maximumNumberOfArguments' => 1, + 'restFiles' => [ + 'Deprecation-94414-DeprecateLanguageServiceContainerEntry.rst' + ], + ], ]; diff --git a/typo3/sysext/linkvalidator/Tests/Functional/LinkAnalyzerTest.php b/typo3/sysext/linkvalidator/Tests/Functional/LinkAnalyzerTest.php index 81ea622a61c328ca137bcdf81dcd541533814fb0..6feed7121eef375491b3661652670d59a58c2632 100644 --- a/typo3/sysext/linkvalidator/Tests/Functional/LinkAnalyzerTest.php +++ b/typo3/sysext/linkvalidator/Tests/Functional/LinkAnalyzerTest.php @@ -18,7 +18,7 @@ declare(strict_types=1); namespace TYPO3\CMS\Linkvalidator\Tests\Functional; use Psr\EventDispatcher\EventDispatcherInterface; -use TYPO3\CMS\Core\Localization\LanguageService; +use TYPO3\CMS\Core\Localization\LanguageServiceFactory; use TYPO3\CMS\Linkvalidator\LinkAnalyzer; use TYPO3\CMS\Linkvalidator\Repository\BrokenLinkRepository; use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase; @@ -37,7 +37,7 @@ class LinkAnalyzerTest extends FunctionalTestCase protected function setUp(): void { parent::setUp(); - $GLOBALS['LANG'] = LanguageService::create('default'); + $GLOBALS['LANG'] = $this->getContainer()->get(LanguageServiceFactory::class)->create('default'); } public function findAllBrokenLinksDataProvider(): array diff --git a/typo3/sysext/recordlist/Tests/Functional/RecordList/CsvExportRecordListTest.php b/typo3/sysext/recordlist/Tests/Functional/RecordList/CsvExportRecordListTest.php index 46d34e9ec0cb6e08995079b32605068edd6e30de..25f8a14e8b0bddb80d6cffe68fec9eca08a7a95e 100644 --- a/typo3/sysext/recordlist/Tests/Functional/RecordList/CsvExportRecordListTest.php +++ b/typo3/sysext/recordlist/Tests/Functional/RecordList/CsvExportRecordListTest.php @@ -19,7 +19,7 @@ namespace TYPO3\CMS\Recordlist\Tests\Functional\RecordList; use TYPO3\CMS\Backend\Configuration\TranslationConfigurationProvider; use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; -use TYPO3\CMS\Core\Localization\LanguageService; +use TYPO3\CMS\Core\Localization\LanguageServiceFactory; use TYPO3\CMS\Recordlist\RecordList\CsvExportRecordList; use TYPO3\CMS\Recordlist\RecordList\DatabaseRecordList; use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase; @@ -32,7 +32,7 @@ class CsvExportRecordListTest extends FunctionalTestCase { parent::setUp(); $this->user = parent::setUpBackendUserFromFixture(1); - $GLOBALS['LANG'] = LanguageService::createFromUserPreferences($this->user); + $GLOBALS['LANG'] = $this->getContainer()->get(LanguageServiceFactory::class)->createFromUserPreferences($this->user); } /** diff --git a/typo3/sysext/redirects/Tests/Functional/Service/SlugServiceTest.php b/typo3/sysext/redirects/Tests/Functional/Service/SlugServiceTest.php index 9c9527c25ddd04f438ca84c932c86797a3647489..b8ea6a028c6798b0f3e30a3949e6e686c8dde9c0 100644 --- a/typo3/sysext/redirects/Tests/Functional/Service/SlugServiceTest.php +++ b/typo3/sysext/redirects/Tests/Functional/Service/SlugServiceTest.php @@ -22,7 +22,7 @@ use TYPO3\CMS\Core\Configuration\SiteConfiguration; use TYPO3\CMS\Core\Context\Context; use TYPO3\CMS\Core\DataHandling\Model\CorrelationId; use TYPO3\CMS\Core\Domain\Repository\PageRepository; -use TYPO3\CMS\Core\Localization\LanguageService; +use TYPO3\CMS\Core\Localization\LanguageServiceFactory; use TYPO3\CMS\Core\Routing\SiteMatcher; use TYPO3\CMS\Core\Site\SiteFinder; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -374,7 +374,7 @@ class SlugServiceTest extends FunctionalTestCase GeneralUtility::makeInstance(SiteMatcher::class)->refresh(); $this->subject = new SlugService( GeneralUtility::makeInstance(Context::class), - GeneralUtility::makeInstance(LanguageService::class), + GeneralUtility::makeInstance(LanguageServiceFactory::class)->create('default'), GeneralUtility::makeInstance(SiteFinder::class), GeneralUtility::makeInstance(PageRepository::class) ); diff --git a/typo3/sysext/rte_ckeditor/Classes/Controller/BrowseLinksController.php b/typo3/sysext/rte_ckeditor/Classes/Controller/BrowseLinksController.php index 83171f04da2822f56217c0e1fd0cbd7ceb73a74f..eeca738c350a5cf87d7a1fcd5e699c9ccf709a4a 100644 --- a/typo3/sysext/rte_ckeditor/Classes/Controller/BrowseLinksController.php +++ b/typo3/sysext/rte_ckeditor/Classes/Controller/BrowseLinksController.php @@ -20,6 +20,7 @@ namespace TYPO3\CMS\RteCKEditor\Controller; use Psr\Http\Message\ServerRequestInterface; use TYPO3\CMS\Core\Configuration\Richtext; use TYPO3\CMS\Core\Localization\LanguageService; +use TYPO3\CMS\Core\Localization\LanguageServiceFactory; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Recordlist\Controller\AbstractLinkBrowserController; @@ -104,7 +105,7 @@ class BrowseLinksController extends AbstractLinkBrowserController protected function init() { parent::init(); - $this->contentLanguageService = GeneralUtility::makeInstance(LanguageService::class); + $this->contentLanguageService = GeneralUtility::makeInstance(LanguageServiceFactory::class)->create('default'); } /** @@ -122,7 +123,7 @@ class BrowseLinksController extends AbstractLinkBrowserController $this->editorId = $queryParameters['editorId']; $this->contentsLanguage = $queryParameters['contentsLanguage']; - $this->contentLanguageService = LanguageService::create($this->contentsLanguage); + $this->contentLanguageService = GeneralUtility::makeInstance(LanguageServiceFactory::class)->create($this->contentsLanguage); $tcaFieldConf = ['enableRichtext' => true]; if (!empty($queryParameters['P']['richtextConfigurationName'])) { diff --git a/typo3/sysext/scheduler/Tests/Functional/Tca/TaskGroupVisibleFieldsTest.php b/typo3/sysext/scheduler/Tests/Functional/Tca/TaskGroupVisibleFieldsTest.php index 329ab373a8b5c75798f6d64c3e4938cdabf35593..3d776b84d16ba701809f74b79d5c4d6fa7a874d0 100644 --- a/typo3/sysext/scheduler/Tests/Functional/Tca/TaskGroupVisibleFieldsTest.php +++ b/typo3/sysext/scheduler/Tests/Functional/Tca/TaskGroupVisibleFieldsTest.php @@ -16,7 +16,7 @@ namespace TYPO3\CMS\Scheduler\Tests\Functional\Tca; use TYPO3\CMS\Backend\Tests\Functional\Form\FormTestService; -use TYPO3\CMS\Core\Localization\LanguageService; +use TYPO3\CMS\Core\Localization\LanguageServiceFactory; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase; @@ -42,7 +42,7 @@ class TaskGroupVisibleFieldsTest extends FunctionalTestCase public function taskGroupFormContainsExpectedFields() { $this->setUpBackendUserFromFixture(1); - $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageService::class); + $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageServiceFactory::class)->create('default'); $formEngineTestService = GeneralUtility::makeInstance(FormTestService::class); $formResult = $formEngineTestService->createNewRecordForm('tx_scheduler_task_group'); diff --git a/typo3/sysext/setup/Classes/Controller/SetupModuleController.php b/typo3/sysext/setup/Classes/Controller/SetupModuleController.php index dcfe5a3041dbb22b81422d243dee6820ffb293c1..07a5af6ccad757c568bbccb772fccdff9647aa70 100644 --- a/typo3/sysext/setup/Classes/Controller/SetupModuleController.php +++ b/typo3/sysext/setup/Classes/Controller/SetupModuleController.php @@ -36,6 +36,7 @@ use TYPO3\CMS\Core\Http\HtmlResponse; use TYPO3\CMS\Core\Imaging\Icon; use TYPO3\CMS\Core\Imaging\IconFactory; use TYPO3\CMS\Core\Localization\LanguageService; +use TYPO3\CMS\Core\Localization\LanguageServiceFactory; use TYPO3\CMS\Core\Messaging\FlashMessage; use TYPO3\CMS\Core\Messaging\FlashMessageService; use TYPO3\CMS\Core\Page\PageRenderer; @@ -152,19 +153,22 @@ class SetupModuleController protected IconFactory $iconFactory; protected PageRenderer $pageRenderer; protected ModuleTemplateFactory $moduleTemplateFactory; + protected LanguageServiceFactory $languageServiceFactory; public function __construct( EventDispatcherInterface $eventDispatcher, MfaProviderRegistry $mfaProviderRegistry, IconFactory $iconFactory, PageRenderer $pageRenderer, - ModuleTemplateFactory $moduleTemplateFactory + ModuleTemplateFactory $moduleTemplateFactory, + LanguageServiceFactory $languageServiceFactory ) { $this->eventDispatcher = $eventDispatcher; $this->mfaProviderRegistry = $mfaProviderRegistry; $this->iconFactory = $iconFactory; $this->pageRenderer = $pageRenderer; $this->moduleTemplateFactory = $moduleTemplateFactory; + $this->languageServiceFactory = $languageServiceFactory; // Instantiate the form protection before a simulated user is initialized $this->formProtection = FormProtectionFactory::get(); } @@ -702,7 +706,7 @@ class SetupModuleController $languageService = $this->getLanguageService(); $content = ''; // get all labels in default language as well - $defaultLanguageLabelService = LanguageService::create('default'); + $defaultLanguageLabelService = $this->languageServiceFactory->create('default'); $defaultLanguageLabelService->includeLLFile('EXT:setup/Resources/Private/Language/locallang.xlf'); foreach ($items as $item) { $languageCode = $item[1]; @@ -1011,10 +1015,7 @@ class SetupModuleController return $GLOBALS['BE_USER']; } - /** - * @return LanguageService - */ - protected function getLanguageService() + protected function getLanguageService(): LanguageService { return $GLOBALS['LANG']; } diff --git a/typo3/sysext/sys_note/Tests/Functional/Tca/NoteVisibleFieldsTest.php b/typo3/sysext/sys_note/Tests/Functional/Tca/NoteVisibleFieldsTest.php index 58affda4b389ba00546db58c0e9b6e64b2a8ef5a..720b030d64eda6f53024dec603eac58ff3d5499d 100644 --- a/typo3/sysext/sys_note/Tests/Functional/Tca/NoteVisibleFieldsTest.php +++ b/typo3/sysext/sys_note/Tests/Functional/Tca/NoteVisibleFieldsTest.php @@ -16,7 +16,7 @@ namespace TYPO3\CMS\SysNote\Tests\Functional\Tca; use TYPO3\CMS\Backend\Tests\Functional\Form\FormTestService; -use TYPO3\CMS\Core\Localization\LanguageService; +use TYPO3\CMS\Core\Localization\LanguageServiceFactory; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase; @@ -43,7 +43,7 @@ class NoteVisibleFieldsTest extends FunctionalTestCase public function noteFormContainsExpectedFields() { $this->setUpBackendUserFromFixture(1); - $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageService::class); + $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageServiceFactory::class)->create('default'); $formEngineTestService = GeneralUtility::makeInstance(FormTestService::class); $formResult = $formEngineTestService->createNewRecordForm('sys_note'); diff --git a/typo3/sysext/workspaces/Classes/Middleware/WorkspacePreview.php b/typo3/sysext/workspaces/Classes/Middleware/WorkspacePreview.php index 2c62db5f64ade931db9ab04763bf611914f6c670..02953faeebe1316021f247b0b93839f8860e6b49 100644 --- a/typo3/sysext/workspaces/Classes/Middleware/WorkspacePreview.php +++ b/typo3/sysext/workspaces/Classes/Middleware/WorkspacePreview.php @@ -34,6 +34,7 @@ use TYPO3\CMS\Core\Http\HtmlResponse; use TYPO3\CMS\Core\Http\NormalizedParams; use TYPO3\CMS\Core\Http\Stream; use TYPO3\CMS\Core\Localization\LanguageService; +use TYPO3\CMS\Core\Localization\LanguageServiceFactory; use TYPO3\CMS\Core\Routing\RouteResultInterface; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController; @@ -413,7 +414,7 @@ class WorkspacePreview implements MiddlewareInterface */ protected function getLanguageService(): LanguageService { - return $GLOBALS['LANG'] ?: LanguageService::create('default'); + return $GLOBALS['LANG'] ?: GeneralUtility::makeInstance(LanguageServiceFactory::class)->create('default'); } /** diff --git a/typo3/sysext/workspaces/Tests/Functional/Tca/WorkspaceStageVisibleFieldsTest.php b/typo3/sysext/workspaces/Tests/Functional/Tca/WorkspaceStageVisibleFieldsTest.php index 51306ed380e660f509c6cea87c23e4b8d16524ee..58ce6397227989a99937be6a322df47f6bb64254 100644 --- a/typo3/sysext/workspaces/Tests/Functional/Tca/WorkspaceStageVisibleFieldsTest.php +++ b/typo3/sysext/workspaces/Tests/Functional/Tca/WorkspaceStageVisibleFieldsTest.php @@ -16,7 +16,7 @@ namespace TYPO3\CMS\Workspaces\Tests\Functional\Tca; use TYPO3\CMS\Backend\Tests\Functional\Form\FormTestService; -use TYPO3\CMS\Core\Localization\LanguageService; +use TYPO3\CMS\Core\Localization\LanguageServiceFactory; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase; @@ -47,7 +47,7 @@ class WorkspaceStageVisibleFieldsTest extends FunctionalTestCase parent::setUp(); $this->setUpBackendUserFromFixture(1); - $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageService::class); + $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageServiceFactory::class)->create('default'); } /** diff --git a/typo3/sysext/workspaces/Tests/Functional/Tca/WorkspaceVisibleFieldsTest.php b/typo3/sysext/workspaces/Tests/Functional/Tca/WorkspaceVisibleFieldsTest.php index 3fe8dba2c3aab6a42aad2b51be3b809ecac4ae91..9e8439854664a434e8b527fd95a6fc5ed693ed65 100644 --- a/typo3/sysext/workspaces/Tests/Functional/Tca/WorkspaceVisibleFieldsTest.php +++ b/typo3/sysext/workspaces/Tests/Functional/Tca/WorkspaceVisibleFieldsTest.php @@ -16,7 +16,7 @@ namespace TYPO3\CMS\Workspaces\Tests\Functional\Tca; use TYPO3\CMS\Backend\Tests\Functional\Form\FormTestService; -use TYPO3\CMS\Core\Localization\LanguageService; +use TYPO3\CMS\Core\Localization\LanguageServiceFactory; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase; @@ -62,7 +62,7 @@ class WorkspaceVisibleFieldsTest extends FunctionalTestCase parent::setUp(); $this->setUpBackendUserFromFixture(1); - $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageService::class); + $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageServiceFactory::class)->create('default'); $this->importDataSet(ORIGINAL_ROOT . 'typo3/sysext/workspaces/Tests/Functional/Fixtures/sys_filemounts.xml'); }