From f0d038e49f7f86c5c6ccf9d56949a12d085a6c71 Mon Sep 17 00:00:00 2001 From: Christian Kuhn Date: Tue, 29 Jun 2021 11:54:14 +0200 Subject: [PATCH] [BUGFIX] Fatal in ext:form using LanguageServiceFactory Patch #94414 broke a case in ext:form leading to a fatal, easily reproducible when opening a content element having a form. The class is internal and only used in backend through a hook and can thus rely on GLOBALS['LANG'] like so many other backend classes do. Resolves: #94429 Related: #94414 Releases: master Change-Id: I578d3b1d61894c210bb0fb20cddf44307cb40ae2 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/69653 Tested-by: Benni Mack Tested-by: core-ci Tested-by: Jochen Tested-by: Christian Kuhn Reviewed-by: Benni Mack Reviewed-by: Jochen Reviewed-by: Christian Kuhn --- .../Processors/FinisherOptionGenerator.php | 29 ++++++------------- 1 file changed, 9 insertions(+), 20 deletions(-) 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 54d59dc26c2d..ec9ef4fc3ac0 100644 --- a/typo3/sysext/form/Classes/Domain/Configuration/FlexformConfiguration/Processors/FinisherOptionGenerator.php +++ b/typo3/sysext/form/Classes/Domain/Configuration/FlexformConfiguration/Processors/FinisherOptionGenerator.php @@ -17,10 +17,9 @@ namespace TYPO3\CMS\Form\Domain\Configuration\FlexformConfiguration\Processors; -use TYPO3\CMS\Core\Localization\LanguageServiceFactory; +use TYPO3\CMS\Core\Localization\LanguageService; use TYPO3\CMS\Core\Utility\ArrayUtility; use TYPO3\CMS\Core\Utility\Exception\MissingArrayPathException; -use TYPO3\CMS\Core\Utility\GeneralUtility; /** * Generate a FlexForm element for a finisher option @@ -29,22 +28,6 @@ */ class FinisherOptionGenerator extends AbstractProcessor { - /** - * @var \TYPO3\CMS\Core\Localization\LanguageServiceFactory - */ - protected $languageService; - - /** - * @param ProcessorDto $converterDto - */ - public function __construct(ProcessorDto $converterDto) - { - parent::__construct($converterDto); - - $this->languageService = GeneralUtility::makeInstance(LanguageServiceFactory::class); - $this->languageService->includeLLFile('EXT:form/Resources/Private/Language/Database.xlf'); - } - /** * @param string $_ unused in this context * @param mixed $__ unused in this context @@ -89,10 +72,11 @@ public function __invoke(string $_, $__, array $matches) } catch (MissingArrayPathException $exception) { } + $languageService = $this->getLanguageService(); if (empty($optionValue)) { - $elementConfiguration['label'] .= sprintf(' (%s: "%s")', $this->languageService->getLL('default'), $this->languageService->getLL('empty')); + $elementConfiguration['label'] .= sprintf(' (%s: "%s")', $languageService->getLL('default'), $languageService->getLL('empty')); } else { - $elementConfiguration['label'] .= sprintf(' (%s: "' . $optionValue . '")', $this->languageService->getLL('default')); + $elementConfiguration['label'] .= sprintf(' (%s: "' . $optionValue . '")', $languageService->getLL('default')); } if (isset($elementConfiguration['config'])) { @@ -104,4 +88,9 @@ public function __invoke(string $_, $__, array $matches) $this->converterDto->setResult($sheetElements); } + + protected function getLanguageService(): LanguageService + { + return $GLOBALS['LANG']; + } }