From a84c4aa92406b48f70ff3dd255940dc4c20f1a9c Mon Sep 17 00:00:00 2001 From: Carsten Walther Date: Mon, 15 Jun 2020 10:03:10 +0200 Subject: [PATCH] fix typo3 v9 compatibility; localisation initialize --- Classes/Configuration/Configuration.php | 31 +++++++--------------- Classes/Controller/Html2pdfController.php | 32 ++++++----------------- Classes/Converter/Converter.php | 32 +++++++---------------- Classes/Report/ExtensionStatus.php | 30 ++++++--------------- 4 files changed, 35 insertions(+), 90 deletions(-) diff --git a/Classes/Configuration/Configuration.php b/Classes/Configuration/Configuration.php index 33cde0d..088b472 100644 --- a/Classes/Configuration/Configuration.php +++ b/Classes/Configuration/Configuration.php @@ -4,6 +4,7 @@ use TYPO3\CMS\Core\Localization\LanguageService; use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; +use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Install\FolderStructure\Exception\InvalidArgumentException; /** @@ -33,28 +34,14 @@ class Configuration * * @param \TYPO3\CMS\Core\Localization\LanguageService $languageService */ - public function __construct(LanguageService $languageService = NULL) - { - self::$languageService = $languageService; - if (self::$languageService) { - self::$languageService->includeLLFile('EXT:html2pdf/Resources/Private/Language/locallang.xlf'); - } - } - - /** - * @param \TYPO3\CMS\Core\Localization\LanguageService $languageService - * - * @return void - */ - public function injectLanguageService(LanguageService $languageService) : void - { - if (!self::$languageService) { - self::$languageService = $languageService; - if (self::$languageService) { - self::$languageService->includeLLFile('EXT:html2pdf/Resources/Private/Language/locallang.xlf'); - } - } - } + public function __construct(LanguageService $languageService = NULL) + { + self::$languageService = $languageService; + if (!self::$languageService) { + self::$languageService = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Localization\LanguageService::class); + } + self::$languageService->includeLLFile('EXT:html2pdf/Resources/Private/Language/locallang.xlf'); + } /** * set diff --git a/Classes/Controller/Html2pdfController.php b/Classes/Controller/Html2pdfController.php index d459bd1..3e2f9d0 100644 --- a/Classes/Controller/Html2pdfController.php +++ b/Classes/Controller/Html2pdfController.php @@ -27,31 +27,15 @@ class Html2pdfController /** * Html2pdfController constructor. - * - * @param \TYPO3\CMS\Core\Localization\LanguageService $languageService */ - public function __construct(LanguageService $languageService = NULL) - { - $this->languageService = $languageService; - if ($this->languageService) { - $this->languageService->includeLLFile('EXT:html2pdf/Resources/Private/Language/locallang.xlf'); - } - } - - /** - * @param \TYPO3\CMS\Core\Localization\LanguageService $languageService - * - * @return void - */ - public function injectLanguageService(LanguageService $languageService) : void - { - if (!$this->languageService) { - $this->languageService = $languageService; - if ($this->languageService) { - $this->languageService->includeLLFile('EXT:html2pdf/Resources/Private/Language/locallang.xlf'); - } - } - } + public function __construct(LanguageService $languageService = NULL) + { + $this->languageService = $languageService; + if (!$this->languageService) { + $this->languageService = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Localization\LanguageService::class); + } + $this->languageService->includeLLFile('EXT:html2pdf/Resources/Private/Language/locallang.xlf'); + } /** * hookOutput diff --git a/Classes/Converter/Converter.php b/Classes/Converter/Converter.php index 1219221..59f7e68 100644 --- a/Classes/Converter/Converter.php +++ b/Classes/Converter/Converter.php @@ -8,6 +8,8 @@ use Psr\Log\LoggerAwareTrait; use RuntimeException; use TYPO3\CMS\Core\Localization\LanguageService; +use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Extbase\Utility\DebuggerUtility; use TYPO3\CMS\Install\FolderStructure\Exception\InvalidArgumentException; use Walther\Html2pdf\Configuration\Configuration; @@ -30,28 +32,14 @@ class Converter implements LoggerAwareInterface * * @param \TYPO3\CMS\Core\Localization\LanguageService $languageService */ - public function __construct(LanguageService $languageService = NULL) - { - $this->languageService = $languageService; - if ($this->languageService) { - $this->languageService->includeLLFile('EXT:html2pdf/Resources/Private/Language/locallang.xlf'); - } - } - - /** - * @param \TYPO3\CMS\Core\Localization\LanguageService $languageService - * - * @return void - */ - public function injectLanguageService(LanguageService $languageService) : void - { - if (!$this->languageService) { - $this->languageService = $languageService; - if ($this->languageService) { - $this->languageService->includeLLFile('EXT:html2pdf/Resources/Private/Language/locallang.xlf'); - } - } - } + public function __construct(LanguageService $languageService = NULL) + { + $this->languageService = $languageService; + if (!$this->languageService) { + $this->languageService = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Localization\LanguageService::class); + } + $this->languageService->includeLLFile('EXT:html2pdf/Resources/Private/Language/locallang.xlf'); + } /** * convert diff --git a/Classes/Report/ExtensionStatus.php b/Classes/Report/ExtensionStatus.php index a1b6b5e..4fb7589 100644 --- a/Classes/Report/ExtensionStatus.php +++ b/Classes/Report/ExtensionStatus.php @@ -31,28 +31,14 @@ class ExtensionStatus implements StatusProviderInterface * * @param \TYPO3\CMS\Core\Localization\LanguageService $languageService */ - public function __construct(LanguageService $languageService = NULL) - { - $this->languageService = $languageService; - if ($this->languageService) { - $this->languageService->includeLLFile('EXT:html2pdf/Resources/Private/Language/locallang.xlf'); - } - } - - /** - * @param \TYPO3\CMS\Core\Localization\LanguageService $languageService - * - * @return void - */ - public function injectLanguageService(LanguageService $languageService) : void - { - if (!$this->languageService) { - $this->languageService = $languageService; - if ($this->languageService) { - $this->languageService->includeLLFile('EXT:html2pdf/Resources/Private/Language/locallang.xlf'); - } - } - } + public function __construct(LanguageService $languageService = NULL) + { + $this->languageService = $languageService; + if (!$this->languageService) { + $this->languageService = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Localization\LanguageService::class); + } + $this->languageService->includeLLFile('EXT:html2pdf/Resources/Private/Language/locallang.xlf'); + } /** * getStatus