Skip to content

Commit c8c00b7

Browse files
committed
Inject LanguageServiceFactory into ProgrammingLanguages class
1 parent 781d189 commit c8c00b7

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

Classes/Service/ProgrammingLanguages.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,19 @@
1414
use Brotkrueml\CodeHighlight\Extension;
1515
use Symfony\Component\DependencyInjection\Attribute\Autoconfigure;
1616
use TYPO3\CMS\Core\Localization\LanguageService;
17+
use TYPO3\CMS\Core\Localization\LanguageServiceFactory;
1718

1819
/**
1920
* @internal
2021
*/
2122
#[Autoconfigure(public: true)]
22-
final class ProgrammingLanguages
23+
final readonly class ProgrammingLanguages
2324
{
24-
/**
25-
* @var LanguageService
26-
*/
27-
private $languageService;
25+
private LanguageService $languageService;
2826

29-
public function __construct(?LanguageService $languageService = null)
27+
public function __construct(LanguageServiceFactory $languageServiceFactory)
3028
{
31-
$this->languageService = $languageService ?? $GLOBALS['LANG'];
29+
$this->languageService = $languageServiceFactory->createFromUserPreferences($GLOBALS['BE_USER']);
3230
}
3331

3432
public function getTcaItems(array &$config): void

0 commit comments

Comments
 (0)