[TASK] Use shorthand syntax for global variable $LANG consistently 78/59578/3
authorBenni Mack <benni@typo3.org>
Tue, 29 Jan 2019 12:41:58 +0000 (13:41 +0100)
committerAndreas Wolf <andreas.wolf@typo3.org>
Fri, 1 Feb 2019 11:22:14 +0000 (12:22 +0100)
TYPO3 uses $GLOBALS['LANG'] directly in some places, but since
TYPO3 v7, new code started to use a short hand protected method
"getLanguageService" in order to get IDE code completion and better
analysis of code.

This patch replaces all left-over places of $GLOBALS['LANG']
and encapsulates this into a short-hand method to streamline
TYPO3 Core's code base.

Resolves: #87571
Releases: master
Change-Id: Ie15e320713fe65d40552a19e0a517d5739abbb41
Reviewed-on: https://review.typo3.org/59578
Tested-by: TYPO3com <noreply@typo3.com>
Reviewed-by: Mona Muzaffar <mona.muzaffar@gmx.de>
Tested-by: Mona Muzaffar <mona.muzaffar@gmx.de>
Reviewed-by: Andreas Wolf <andreas.wolf@typo3.org>
Reviewed-by: Frank Naegler <frank.naegler@typo3.org>
Tested-by: Frank Naegler <frank.naegler@typo3.org>
Tested-by: Andreas Wolf <andreas.wolf@typo3.org>
31 files changed:
typo3/sysext/backend/Classes/Backend/ToolbarItems/SystemInformationToolbarItem.php
typo3/sysext/backend/Classes/Controller/AbstractFormEngineAjaxController.php
typo3/sysext/backend/Classes/Controller/Page/TreeController.php
typo3/sysext/backend/Classes/Search/LiveSearch/LiveSearch.php
typo3/sysext/backend/Classes/Template/DocumentTemplate.php
typo3/sysext/backend/Classes/Template/ModuleTemplate.php
typo3/sysext/core/Classes/Tree/TableConfiguration/DatabaseTreeDataProvider.php
typo3/sysext/felogin/Classes/Hooks/CmsLayout.php
typo3/sysext/fluid/Classes/ViewHelpers/Be/PagePathViewHelper.php
typo3/sysext/indexed_search/Classes/Hook/CrawlerHook.php
typo3/sysext/info/Classes/Controller/PageInformationController.php
typo3/sysext/install/Classes/Report/EnvironmentStatusReport.php
typo3/sysext/install/Classes/Report/SecurityStatusReport.php
typo3/sysext/linkvalidator/Classes/Task/ValidatorTask.php
typo3/sysext/recycler/Classes/Task/CleanerTask.php
typo3/sysext/reports/Classes/Task/SystemStatusUpdateTask.php
typo3/sysext/scheduler/Classes/Example/SleepTask.php
typo3/sysext/scheduler/Classes/Example/SleepTaskAdditionalFieldProvider.php
typo3/sysext/scheduler/Classes/Example/TestTask.php
typo3/sysext/scheduler/Classes/Example/TestTaskAdditionalFieldProvider.php
typo3/sysext/scheduler/Classes/Task/AbstractTask.php
typo3/sysext/scheduler/Classes/Task/CachingFrameworkGarbageCollectionAdditionalFieldProvider.php
typo3/sysext/scheduler/Classes/Task/ExecuteSchedulableCommandTask.php
typo3/sysext/scheduler/Classes/Task/IpAnonymizationTask.php
typo3/sysext/scheduler/Classes/Task/OptimizeDatabaseTableAdditionalFieldProvider.php
typo3/sysext/scheduler/Classes/Task/RecyclerGarbageCollectionAdditionalFieldProvider.php
typo3/sysext/scheduler/Classes/Task/TableGarbageCollectionAdditionalFieldProvider.php
typo3/sysext/scheduler/Classes/Task/TableGarbageCollectionTask.php
typo3/sysext/workspaces/Classes/Hook/BackendUtilityHook.php
typo3/sysext/workspaces/Classes/Service/StagesService.php
typo3/sysext/workspaces/Classes/Service/WorkspaceService.php

index d0dfa7a..ed85c99 100644 (file)
@@ -20,6 +20,7 @@ use TYPO3\CMS\Backend\Toolbar\ToolbarItemInterface;
 use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Core\SystemEnvironmentBuilder;
 use TYPO3\CMS\Core\Database\ConnectionPool;
+use TYPO3\CMS\Core\Localization\LanguageService;
 use TYPO3\CMS\Core\Page\PageRenderer;
 use TYPO3\CMS\Core\Utility\CommandUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -306,7 +307,7 @@ class SystemInformationToolbarItem implements ToolbarItemInterface
 
         $this->systemInformation[] = [
             'title' => 'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:toolbarItems.sysinfo.composerMode',
-            'value' => $GLOBALS['LANG']->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.enabled'),
+            'value' => $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.enabled'),
             'iconIdentifier' => 'information-composer-mode'
         ];
     }
@@ -408,6 +409,14 @@ class SystemInformationToolbarItem implements ToolbarItemInterface
     }
 
     /**
+     * @return LanguageService|null
+     */
+    protected function getLanguageService(): ?LanguageService
+    {
+        return $GLOBALS['LANG'] ?? null;
+    }
+
+    /**
      * Returns current PageRenderer
      *
      * @return PageRenderer
index a61665e..fc8f054 100644 (file)
@@ -15,6 +15,7 @@ namespace TYPO3\CMS\Backend\Controller;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Localization\LanguageService;
 use TYPO3\CMS\Core\Localization\LocalizationFactory;
 use TYPO3\CMS\Core\Utility\ArrayUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -100,7 +101,7 @@ abstract class AbstractFormEngineAjaxController
     {
         /** @var LocalizationFactory $languageFactory */
         $languageFactory = GeneralUtility::makeInstance(LocalizationFactory::class);
-        $language = $GLOBALS['LANG']->lang;
+        $language = $this->getLanguageService()->lang;
         $localizationArray = $languageFactory->getParsedData($file, $language);
         if (is_array($localizationArray) && !empty($localizationArray)) {
             if (!empty($localizationArray[$language])) {
@@ -122,4 +123,12 @@ abstract class AbstractFormEngineAjaxController
         }
         return $labelArray;
     }
+
+    /**
+     * @return LanguageService|null
+     */
+    protected function getLanguageService(): ?LanguageService
+    {
+        return $GLOBALS['LANG'] ?? null;
+    }
 }
index 8123ea9..8a7b2c8 100644 (file)
@@ -26,6 +26,7 @@ use TYPO3\CMS\Core\Exception\SiteNotFoundException;
 use TYPO3\CMS\Core\Http\JsonResponse;
 use TYPO3\CMS\Core\Imaging\Icon;
 use TYPO3\CMS\Core\Imaging\IconFactory;
+use TYPO3\CMS\Core\Localization\LanguageService;
 use TYPO3\CMS\Core\Site\PseudoSiteFinder;
 use TYPO3\CMS\Core\Site\SiteFinder;
 use TYPO3\CMS\Core\Type\Bitmask\JsConfirmation;
@@ -153,7 +154,7 @@ class TreeController
             if (!$isAdmin && !in_array($doktype, $allowedDoktypes, true)) {
                 continue;
             }
-            $label = htmlspecialchars($GLOBALS['LANG']->sL($doktypeLabelMap[$doktype]));
+            $label = htmlspecialchars($this->getLanguageService()->sL($doktypeLabelMap[$doktype]));
             $output[] = [
                 'nodeType' => $doktype,
                 'icon' => $GLOBALS['TCA']['pages']['ctrl']['typeicon_classes'][$doktype] ?? '',
@@ -263,7 +264,7 @@ class TreeController
             $visibleText = $page['nav_title'];
         }
         if (trim($visibleText) === '') {
-            $visibleText = htmlspecialchars('[' . $GLOBALS['LANG']->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.no_title') . ']');
+            $visibleText = htmlspecialchars('[' . $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.no_title') . ']');
         }
         $visibleText = GeneralUtility::fixed_lgd_cs($visibleText, (int)$this->getBackendUser()->uc['titleLen'] ?: 40);
 
@@ -471,4 +472,12 @@ class TreeController
     {
         return $GLOBALS['BE_USER'];
     }
+
+    /**
+     * @return LanguageService|null
+     */
+    protected function getLanguageService(): ?LanguageService
+    {
+        return $GLOBALS['LANG'] ?? null;
+    }
 }
index e4b2eed..ae0d7b8 100644 (file)
@@ -26,6 +26,7 @@ use TYPO3\CMS\Core\Database\Query\Restriction\HiddenRestriction;
 use TYPO3\CMS\Core\Database\Query\Restriction\StartTimeRestriction;
 use TYPO3\CMS\Core\Imaging\Icon;
 use TYPO3\CMS\Core\Imaging\IconFactory;
+use TYPO3\CMS\Core\Localization\LanguageService;
 use TYPO3\CMS\Core\Type\Bitmask\Permission;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\MathUtility;
@@ -290,7 +291,7 @@ class LiveSearch
      */
     protected function getTitleOfCurrentRecordType($tableName)
     {
-        return $GLOBALS['LANG']->sL($GLOBALS['TCA'][$tableName]['ctrl']['title']);
+        return $this->getLanguageService()->sL($GLOBALS['TCA'][$tableName]['ctrl']['title']);
     }
 
     /**
@@ -492,4 +493,12 @@ class LiveSearch
         $tree->ids[] = -1;
         return implode(',', $tree->ids);
     }
+
+    /**
+     * @return LanguageService|null
+     */
+    protected function getLanguageService(): ?LanguageService
+    {
+        return $GLOBALS['LANG'] ?? null;
+    }
 }
index 93aec4f..69ae017 100644 (file)
@@ -23,6 +23,7 @@ use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
 use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
 use TYPO3\CMS\Core\Imaging\Icon;
 use TYPO3\CMS\Core\Imaging\IconFactory;
+use TYPO3\CMS\Core\Localization\LanguageService;
 use TYPO3\CMS\Core\Page\PageRenderer;
 use TYPO3\CMS\Core\Service\MarkerBasedTemplateService;
 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
@@ -266,7 +267,7 @@ function jumpToUrl(URL) {
     protected function initPageRenderer()
     {
         $this->pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
-        $this->pageRenderer->setLanguage($GLOBALS['LANG']->lang);
+        $this->pageRenderer->setLanguage($this->getLanguageService()->lang);
         $this->pageRenderer->enableConcatenateCss();
         $this->pageRenderer->enableConcatenateJavascript();
         $this->pageRenderer->enableCompressCss();
@@ -305,7 +306,7 @@ function jumpToUrl(URL) {
         } else {
             $motherModule = '\'\'';
         }
-        $confirmationText = GeneralUtility::quoteJSvalue($GLOBALS['LANG']->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.makeBookmark'));
+        $confirmationText = GeneralUtility::quoteJSvalue($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.makeBookmark'));
 
         $shortcutUrl = $pathInfo['path'] . '?' . $storeUrl;
         $shortcutRepository = GeneralUtility::makeInstance(ShortcutRepository::class);
@@ -320,7 +321,7 @@ function jumpToUrl(URL) {
             ', ' . $url . ', ' . $confirmationText . ', ' . $motherModule . ', this);return false;';
 
         return '<a href="#" class="' . htmlspecialchars($classes) . '" onclick="' . htmlspecialchars($onClick) . '" title="' .
-        htmlspecialchars($GLOBALS['LANG']->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.makeBookmark')) . '">' .
+        htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.makeBookmark')) . '">' .
         $this->iconFactory->getIcon('actions-system-shortcut-new', Icon::SIZE_SMALL)->render() . '</a>';
     }
 
@@ -800,7 +801,7 @@ function jumpToUrl(URL) {
             $title = '';
         }
         // Setting the path of the page
-        $pagePath = htmlspecialchars($GLOBALS['LANG']->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.path')) . ': <span class="typo3-docheader-pagePath">';
+        $pagePath = htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.path')) . ': <span class="typo3-docheader-pagePath">';
         // crop the title to title limit (or 50, if not defined)
         $cropLength = empty($GLOBALS['BE_USER']->uc['titleLen']) ? 50 : $GLOBALS['BE_USER']->uc['titleLen'];
         $croppedTitle = GeneralUtility::fixed_lgd_cs($title, -$cropLength);
@@ -896,4 +897,12 @@ function jumpToUrl(URL) {
     {
         return $GLOBALS['BE_USER'] ?? null;
     }
+
+    /**
+     * @return LanguageService|null
+     */
+    protected function getLanguageService(): ?LanguageService
+    {
+        return $GLOBALS['LANG'] ?? null;
+    }
 }
index 5fb7492..3aa95f1 100644 (file)
@@ -293,7 +293,7 @@ class ModuleTemplate
         // Yes, hardcoded on purpose
         $this->pageRenderer->setXmlPrologAndDocType('<!DOCTYPE html>');
         $this->pageRenderer->setCharSet('utf-8');
-        $this->pageRenderer->setLanguage($GLOBALS['LANG']->lang);
+        $this->pageRenderer->setLanguage($this->getLanguageService()->lang);
         $this->pageRenderer->setMetaTag('name', 'viewport', 'width=device-width, initial-scale=1');
     }
 
index ca2464f..e471f32 100644 (file)
@@ -19,6 +19,7 @@ use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Database\Query\Expression\ExpressionBuilder;
 use TYPO3\CMS\Core\Imaging\Icon;
 use TYPO3\CMS\Core\Imaging\IconFactory;
+use TYPO3\CMS\Core\Localization\LanguageService;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Extbase\Object\ObjectManager;
 use TYPO3\CMS\Extbase\SignalSlot\Dispatcher;
@@ -251,7 +252,7 @@ class DatabaseTreeDataProvider extends AbstractTableConfigurationTreeDataProvide
         if ($basicNode->getId() == 0) {
             $node->setSelected(false);
             $node->setExpanded(true);
-            $node->setLabel($GLOBALS['LANG']->sL($GLOBALS['TCA'][$this->tableName]['ctrl']['title']));
+            $node->setLabel($this->getLanguageService()->sL($GLOBALS['TCA'][$this->tableName]['ctrl']['title']));
         } else {
             $row = BackendUtility::getRecordWSOL($this->tableName, $basicNode->getId(), '*', '', false);
             $node->setLabel(BackendUtility::getRecordTitle($this->tableName, $row) ?: $basicNode->getId());
@@ -539,4 +540,12 @@ class DatabaseTreeDataProvider extends AbstractTableConfigurationTreeDataProvide
     {
         return GeneralUtility::makeInstance(ObjectManager::class);
     }
+
+    /**
+     * @return LanguageService|null
+     */
+    protected function getLanguageService(): ?LanguageService
+    {
+        return $GLOBALS['LANG'] ?? null;
+    }
 }
index edbec9f..fc21b6c 100644 (file)
@@ -14,6 +14,8 @@ namespace TYPO3\CMS\Felogin\Hooks;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Localization\LanguageService;
+
 /**
  * Hook to display verbose information about the felogin plugin
  * @internal this is a TYPO3 hook implementation and solely used for EXT:felogin and not part of TYPO3's Core API.
@@ -33,7 +35,15 @@ class CmsLayout implements \TYPO3\CMS\Backend\View\PageLayoutViewDrawItemHookInt
     {
         if ($row['CType'] === 'login') {
             $drawItem = false;
-            $itemContent .= $parentObject->linkEditContent('<strong>' . htmlspecialchars($GLOBALS['LANG']->sL('LLL:EXT:backend/Resources/Private/Language/locallang_db_new_content_el.xlf:forms_login_title')) . '</strong>', $row);
+            $itemContent .= $parentObject->linkEditContent('<strong>' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:backend/Resources/Private/Language/locallang_db_new_content_el.xlf:forms_login_title')) . '</strong>', $row);
         }
     }
+
+    /**
+     * @return LanguageService|null
+     */
+    protected function getLanguageService(): ?LanguageService
+    {
+        return $GLOBALS['LANG'] ?? null;
+    }
 }
index 501d9f4..02a3a04 100644 (file)
@@ -15,6 +15,7 @@ namespace TYPO3\CMS\Fluid\ViewHelpers\Be;
  */
 
 use TYPO3\CMS\Backend\Utility\BackendUtility;
+use TYPO3\CMS\Core\Localization\LanguageService;
 use TYPO3\CMS\Core\Type\Bitmask\Permission;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
@@ -75,7 +76,7 @@ class PagePathViewHelper extends AbstractBackendViewHelper
             $title = $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'];
         }
         // Setting the path of the page
-        $pagePath = htmlspecialchars($GLOBALS['LANG']->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.path')) . ': <span class="typo3-docheader-pagePath">';
+        $pagePath = htmlspecialchars(static::getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.path')) . ': <span class="typo3-docheader-pagePath">';
         // crop the title to title limit (or 50, if not defined)
         $cropLength = empty($GLOBALS['BE_USER']->uc['titleLen']) ? 50 : $GLOBALS['BE_USER']->uc['titleLen'];
         $croppedTitle = GeneralUtility::fixed_lgd_cs($title, -$cropLength);
@@ -87,4 +88,12 @@ class PagePathViewHelper extends AbstractBackendViewHelper
         $pagePath .= '</span>';
         return $pagePath;
     }
+
+    /**
+     * @return LanguageService|null
+     */
+    protected static function getLanguageService(): ?LanguageService
+    {
+        return $GLOBALS['LANG'] ?? null;
+    }
 }
index b4611ed..9d51667 100644 (file)
@@ -15,6 +15,7 @@ namespace TYPO3\CMS\IndexedSearch\Hook;
  */
 
 use TYPO3\CMS\Backend\Utility\BackendUtility;
+use TYPO3\CMS\Core\Core\Bootstrap;
 use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Database\Connection;
 use TYPO3\CMS\Core\Database\ConnectionPool;
@@ -57,8 +58,7 @@ class CrawlerHook
     {
         // To make sure the backend charset is available:
         if (!is_object($GLOBALS['LANG'])) {
-            $GLOBALS['LANG'] = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Localization\LanguageService::class);
-            $GLOBALS['LANG']->init($GLOBALS['BE_USER']->uc['lang']);
+            Bootstrap::initializeLanguageObject();
         }
     }
 
index 7339b2d..09e9a08 100644 (file)
@@ -73,7 +73,7 @@ class PageInformationController
         $dblist->script = (string)$uriBuilder->buildUriFromRoute('web_info');
         $dblist->showIcon = 0;
         $dblist->setLMargin = 0;
-        $dblist->agePrefixes = $GLOBALS['LANG']->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.minutesHoursDaysYears');
+        $dblist->agePrefixes = $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.minutesHoursDaysYears');
         $dblist->pI_showUser = true;
 
         if (isset($this->fieldConfiguration[$this->pObj->MOD_SETTINGS['pages']])) {
@@ -115,12 +115,12 @@ class PageInformationController
         $menu = [
             'pages' => [],
             'depth' => [
-                0 => $GLOBALS['LANG']->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.depth_0'),
-                1 => $GLOBALS['LANG']->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.depth_1'),
-                2 => $GLOBALS['LANG']->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.depth_2'),
-                3 => $GLOBALS['LANG']->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.depth_3'),
-                4 => $GLOBALS['LANG']->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.depth_4'),
-                999 => $GLOBALS['LANG']->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.depth_infi')
+                0 => $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.depth_0'),
+                1 => $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.depth_1'),
+                2 => $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.depth_2'),
+                3 => $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.depth_3'),
+                4 => $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.depth_4'),
+                999 => $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.depth_infi')
             ]
         ];
 
@@ -184,7 +184,7 @@ class PageInformationController
             }
             $key = trim($key, '.');
             $this->fieldConfiguration[$key] = [
-                'label' => $item['label'] ? $GLOBALS['LANG']->sL($item['label']) : $key,
+                'label' => $item['label'] ? $this->getLanguageService()->sL($item['label']) : $key,
                 'fields' => $fields
             ];
         }
@@ -199,10 +199,10 @@ class PageInformationController
     }
 
     /**
-     * @return LanguageService
+     * @return LanguageService|null
      */
-    protected function getLanguageService(): LanguageService
+    protected function getLanguageService(): ?LanguageService
     {
-        return $GLOBALS['LANG'];
+        return $GLOBALS['LANG'] ?? null;
     }
 }
index f445540..2426a34 100644 (file)
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Install\Report;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Localization\LanguageService;
 use TYPO3\CMS\Core\Messaging\FlashMessage;
 use TYPO3\CMS\Core\Messaging\FlashMessageQueue;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -110,13 +111,13 @@ class EnvironmentStatusReport implements StatusProviderInterface, ExtendedStatus
                     $type = 'info';
                 }
                 if (!$verbose) {
-                    $message = $GLOBALS['LANG']->sL($pathToXliff . ':environment.status.message.' . $type);
+                    $message = $this->getLanguageService()->sL($pathToXliff . ':environment.status.message.' . $type);
                 }
                 $severity = constant('\TYPO3\CMS\Reports\Status::' . strtoupper($type));
                 $statusArray[] = GeneralUtility::makeInstance(
                     Status::class,
-                    $GLOBALS['LANG']->sL($pathToXliff . ':environment.status.title'),
-                    sprintf($GLOBALS['LANG']->sL($pathToXliff . ':environment.status.value'), $value),
+                    $this->getLanguageService()->sL($pathToXliff . ':environment.status.title'),
+                    sprintf($this->getLanguageService()->sL($pathToXliff . ':environment.status.value'), $value),
                     $message,
                     $severity
                 );
@@ -125,4 +126,12 @@ class EnvironmentStatusReport implements StatusProviderInterface, ExtendedStatus
 
         return $statusArray;
     }
+
+    /**
+     * @return LanguageService|null
+     */
+    protected function getLanguageService(): ?LanguageService
+    {
+        return $GLOBALS['LANG'] ?? null;
+    }
 }
index 63d2465..f00ca4a 100644 (file)
@@ -17,6 +17,7 @@ namespace TYPO3\CMS\Install\Report;
 use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Crypto\PasswordHashing\InvalidPasswordHashException;
 use TYPO3\CMS\Core\Crypto\PasswordHashing\PasswordHashFactory;
+use TYPO3\CMS\Core\Localization\LanguageService;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Install\Service\EnableFileService;
 use TYPO3\CMS\Reports\Status;
@@ -49,7 +50,7 @@ class SecurityStatusReport implements \TYPO3\CMS\Reports\StatusProviderInterface
     protected function getInstallToolPasswordStatus()
     {
         // @todo @deprecated: This should be removed in TYPO3 v10.0 when install tool allows proper hashes only
-        $value = $GLOBALS['LANG']->getLL('status_ok');
+        $value = $this->getLanguageService()->getLL('status_ok');
         $message = '';
         $severity = Status::OK;
         $validPassword = true;
@@ -67,20 +68,20 @@ class SecurityStatusReport implements \TYPO3\CMS\Reports\StatusProviderInterface
             $validPassword = false;
         }
         if (!$validPassword) {
-            $value = $GLOBALS['LANG']->getLL('status_insecure');
+            $value = $this->getLanguageService()->getLL('status_insecure');
             $severity = Status::ERROR;
             /** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */
             $uriBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder::class);
             $changeInstallToolPasswordUrl = (string)$uriBuilder->buildUriFromRoute('tools_toolssettings');
             $message = sprintf(
-                $GLOBALS['LANG']->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:warning.installtool_default_password'),
+                $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:warning.installtool_default_password'),
                 '<a href="' . htmlspecialchars($changeInstallToolPasswordUrl) . '">',
                 '</a>'
             );
         }
         return GeneralUtility::makeInstance(
             Status::class,
-            $GLOBALS['LANG']->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_installToolPassword'),
+            $this->getLanguageService()->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_installToolPassword'),
             $value,
             $message,
             $severity
@@ -95,40 +96,40 @@ class SecurityStatusReport implements \TYPO3\CMS\Reports\StatusProviderInterface
     protected function getInstallToolProtectionStatus()
     {
         $enableInstallToolFile = Environment::getPublicPath() . '/' . EnableFileService::INSTALL_TOOL_ENABLE_FILE_PATH;
-        $value = $GLOBALS['LANG']->getLL('status_disabled');
+        $value = $this->getLanguageService()->getLL('status_disabled');
         $message = '';
         $severity = Status::OK;
         if (EnableFileService::installToolEnableFileExists()) {
             if (EnableFileService::isInstallToolEnableFilePermanent()) {
                 $severity = Status::WARNING;
                 $disableInstallToolUrl = GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL') . '&adminCmd=remove_ENABLE_INSTALL_TOOL';
-                $value = $GLOBALS['LANG']->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_enabledPermanently');
+                $value = $this->getLanguageService()->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_enabledPermanently');
                 $message = sprintf(
-                    $GLOBALS['LANG']->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:warning.install_enabled'),
+                    $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:warning.install_enabled'),
                     '<code style="white-space: nowrap;">' . $enableInstallToolFile . '</code>'
                 );
                 $message .= ' <a href="' . htmlspecialchars($disableInstallToolUrl) . '">' .
-                    $GLOBALS['LANG']->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:warning.install_enabled_cmd') . '</a>';
+                    $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:warning.install_enabled_cmd') . '</a>';
             } else {
                 if (EnableFileService::installToolEnableFileLifetimeExpired()) {
                     EnableFileService::removeInstallToolEnableFile();
                 } else {
                     $severity = Status::NOTICE;
                     $disableInstallToolUrl = GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL') . '&adminCmd=remove_ENABLE_INSTALL_TOOL';
-                    $value = $GLOBALS['LANG']->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_enabledTemporarily');
+                    $value = $this->getLanguageService()->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_enabledTemporarily');
                     $message = sprintf(
-                        $GLOBALS['LANG']->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_installEnabledTemporarily'),
+                        $this->getLanguageService()->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_installEnabledTemporarily'),
                         '<code style="white-space: nowrap;">' . $enableInstallToolFile . '</code>',
                         floor((@filemtime($enableInstallToolFile) + EnableFileService::INSTALL_TOOL_ENABLE_FILE_LIFETIME - time()) / 60)
                     );
                     $message .= ' <a href="' . htmlspecialchars($disableInstallToolUrl) . '">' .
-                        $GLOBALS['LANG']->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:warning.install_enabled_cmd') . '</a>';
+                        $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:warning.install_enabled_cmd') . '</a>';
                 }
             }
         }
         return GeneralUtility::makeInstance(
             Status::class,
-            $GLOBALS['LANG']->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_installTool'),
+            $this->getLanguageService()->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_installTool'),
             $value,
             $message,
             $severity
@@ -149,4 +150,12 @@ class SecurityStatusReport implements \TYPO3\CMS\Reports\StatusProviderInterface
                 // Do nothing
         }
     }
+
+    /**
+     * @return LanguageService|null
+     */
+    protected function getLanguageService(): ?LanguageService
+    {
+        return $GLOBALS['LANG'] ?? null;
+    }
 }
index c677134..9b94641 100644 (file)
@@ -15,7 +15,6 @@ namespace TYPO3\CMS\Linkvalidator\Task;
  */
 
 use TYPO3\CMS\Backend\Utility\BackendUtility;
-use TYPO3\CMS\Core\Localization\LanguageService;
 use TYPO3\CMS\Core\Mail\MailMessage;
 use TYPO3\CMS\Core\Service\MarkerBasedTemplateService;
 use TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser;
@@ -611,12 +610,4 @@ class ValidatorTask extends AbstractTask
             $this->countInARun
         ];
     }
-
-    /**
-     * @return LanguageService
-     */
-    protected function getLanguageService()
-    {
-        return $GLOBALS['LANG'];
-    }
 }
index d8662e8..127e47f 100644 (file)
@@ -163,12 +163,4 @@ class CleanerTask extends AbstractTask
     {
         return $this->tcaTables;
     }
-
-    /**
-     * @return \TYPO3\CMS\Core\Localization\LanguageService
-     */
-    protected function getLanguageService()
-    {
-        return $GLOBALS['LANG'];
-    }
 }
index c190636..af9ee49 100644 (file)
@@ -14,7 +14,6 @@ namespace TYPO3\CMS\Reports\Task;
  * The TYPO3 project - inspiring people to share!
  */
 
-use TYPO3\CMS\Core\Localization\LanguageService;
 use TYPO3\CMS\Core\Mail\MailMessage;
 use TYPO3\CMS\Core\Registry;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -136,12 +135,4 @@ class SystemStatusUpdateTask extends AbstractTask
     {
         $this->notificationAll = $notificationAll;
     }
-
-    /**
-     * @return LanguageService
-     */
-    protected function getLanguageService()
-    {
-        return $GLOBALS['LANG'];
-    }
 }
index fbab27a..7aa9b8f 100644 (file)
@@ -51,6 +51,6 @@ class SleepTask extends \TYPO3\CMS\Scheduler\Task\AbstractTask
      */
     public function getAdditionalInformation()
     {
-        return $GLOBALS['LANG']->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:label.sleepTime') . ': ' . $this->sleepTime;
+        return $this->getLanguageService()->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:label.sleepTime') . ': ' . $this->sleepTime;
     }
 }
index 6ef97ab..33d6d33 100644 (file)
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Scheduler\Example;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Localization\LanguageService;
 use TYPO3\CMS\Core\Messaging\FlashMessage;
 use TYPO3\CMS\Scheduler\AbstractAdditionalFieldProvider;
 use TYPO3\CMS\Scheduler\Controller\SchedulerModuleController;
@@ -77,7 +78,7 @@ class SleepTaskAdditionalFieldProvider extends AbstractAdditionalFieldProvider
     {
         $submittedData['sleepTime'] = (int)$submittedData['sleepTime'];
         if ($submittedData['sleepTime'] < 0) {
-            $this->addMessage($GLOBALS['LANG']->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:msg.invalidSleepTime'), FlashMessage::ERROR);
+            $this->addMessage($this->getLanguageService()->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:msg.invalidSleepTime'), FlashMessage::ERROR);
             $result = false;
         } else {
             $result = true;
@@ -96,4 +97,12 @@ class SleepTaskAdditionalFieldProvider extends AbstractAdditionalFieldProvider
     {
         $task->sleepTime = $submittedData['sleepTime'];
     }
+
+    /**
+     * @return LanguageService|null
+     */
+    protected function getLanguageService(): ?LanguageService
+    {
+        return $GLOBALS['LANG'] ?? null;
+    }
 }
index 652867f..3545e47 100644 (file)
@@ -86,6 +86,6 @@ class TestTask extends \TYPO3\CMS\Scheduler\Task\AbstractTask
      */
     public function getAdditionalInformation()
     {
-        return $GLOBALS['LANG']->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:label.email') . ': ' . $this->email;
+        return $this->getLanguageService()->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:label.email') . ': ' . $this->email;
     }
 }
index 9b785fc..78eefc1 100644 (file)
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Scheduler\Example;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Localization\LanguageService;
 use TYPO3\CMS\Core\Messaging\FlashMessage;
 use TYPO3\CMS\Scheduler\AbstractAdditionalFieldProvider;
 use TYPO3\CMS\Scheduler\Controller\SchedulerModuleController;
@@ -78,7 +79,7 @@ class TestTaskAdditionalFieldProvider extends AbstractAdditionalFieldProvider
         $submittedData['email'] = trim($submittedData['email']);
         if (empty($submittedData['email'])) {
             $this->addMessage(
-                $GLOBALS['LANG']->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:msg.noEmail'),
+                $this->getLanguageService()->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:msg.noEmail'),
                 FlashMessage::ERROR
             );
             $result = false;
@@ -99,4 +100,12 @@ class TestTaskAdditionalFieldProvider extends AbstractAdditionalFieldProvider
     {
         $task->email = $submittedData['email'];
     }
+
+    /**
+     * @return LanguageService|null
+     */
+    protected function getLanguageService(): ?LanguageService
+    {
+        return $GLOBALS['LANG'] ?? null;
+    }
 }
index fdaa290..312de7f 100644 (file)
@@ -19,6 +19,7 @@ use Psr\Log\LoggerAwareTrait;
 use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Database\Connection;
 use TYPO3\CMS\Core\Database\ConnectionPool;
+use TYPO3\CMS\Core\Localization\LanguageService;
 use TYPO3\CMS\Core\Log\LogManager;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Scheduler\Execution;
@@ -174,7 +175,7 @@ abstract class AbstractTask implements LoggerAwareInterface
      */
     public function getTaskTitle()
     {
-        return $GLOBALS['LANG']->sL($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks'][static::class]['title']);
+        return $this->getLanguageService()->sL($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks'][static::class]['title']);
     }
 
     /**
@@ -184,7 +185,7 @@ abstract class AbstractTask implements LoggerAwareInterface
      */
     public function getTaskDescription()
     {
-        return $GLOBALS['LANG']->sL($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks'][static::class]['description']);
+        return $this->getLanguageService()->sL($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks'][static::class]['description']);
     }
 
     /**
@@ -621,4 +622,12 @@ abstract class AbstractTask implements LoggerAwareInterface
     {
         $this->logger->error('A Task Exception was captured: ' . $e->getMessage() . ' (' . $e->getCode() . ')', ['exception' => $e]);
     }
+
+    /**
+     * @return LanguageService|null
+     */
+    protected function getLanguageService(): ?LanguageService
+    {
+        return $GLOBALS['LANG'] ?? null;
+    }
 }
index 9f8880d..0fa9cef 100644 (file)
@@ -15,6 +15,7 @@ namespace TYPO3\CMS\Scheduler\Task;
  */
 
 use TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend;
+use TYPO3\CMS\Core\Localization\LanguageService;
 use TYPO3\CMS\Core\Messaging\FlashMessage;
 use TYPO3\CMS\Scheduler\AbstractAdditionalFieldProvider;
 use TYPO3\CMS\Scheduler\Controller\SchedulerModuleController;
@@ -79,11 +80,11 @@ class CachingFrameworkGarbageCollectionAdditionalFieldProvider extends AbstractA
         if (is_array($submittedData['scheduler_cachingFrameworkGarbageCollection_selectedBackends'])) {
             $invalidBackends = array_diff($submittedData['scheduler_cachingFrameworkGarbageCollection_selectedBackends'], $availableBackends);
             if (!empty($invalidBackends)) {
-                $this->addMessage($GLOBALS['LANG']->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:msg.selectionOfNonExistingCacheBackends'), FlashMessage::ERROR);
+                $this->addMessage($this->getLanguageService()->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:msg.selectionOfNonExistingCacheBackends'), FlashMessage::ERROR);
                 $validData = false;
             }
         } else {
-            $this->addMessage($GLOBALS['LANG']->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:msg.noCacheBackendSelected'), FlashMessage::ERROR);
+            $this->addMessage($this->getLanguageService()->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:msg.noCacheBackendSelected'), FlashMessage::ERROR);
             $validData = false;
         }
         return $validData;
@@ -140,4 +141,12 @@ class CachingFrameworkGarbageCollectionAdditionalFieldProvider extends AbstractA
         }
         return $backends;
     }
+
+    /**
+     * @return LanguageService|null
+     */
+    protected function getLanguageService(): ?LanguageService
+    {
+        return $GLOBALS['LANG'] ?? null;
+    }
 }
index daccd37..326e622 100644 (file)
@@ -19,7 +19,6 @@ use Symfony\Component\Console\Input\ArrayInput;
 use Symfony\Component\Console\Output\NullOutput;
 use TYPO3\CMS\Core\Console\CommandRegistry;
 use TYPO3\CMS\Core\Console\UnknownCommandException;
-use TYPO3\CMS\Core\Localization\LanguageService;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
 /**
@@ -118,12 +117,4 @@ class ExecuteSchedulableCommandTask extends AbstractTask
         }
         $this->defaults[$argumentName] = $argumentValue;
     }
-
-    /**
-     * @return LanguageService
-     */
-    public function getLanguageService(): LanguageService
-    {
-        return $GLOBALS['LANG'];
-    }
 }
index 3d49d23..5a18b46 100644 (file)
@@ -138,6 +138,6 @@ class IpAnonymizationTask extends AbstractTask
      */
     public function getAdditionalInformation()
     {
-        return sprintf($GLOBALS['LANG']->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:label.ipAnonymization.additionalInformationTable'), $this->table, $this->numberOfDays);
+        return sprintf($this->getLanguageService()->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:label.ipAnonymization.additionalInformationTable'), $this->table, $this->numberOfDays);
     }
 }
index b29caa3..c2844a7 100644 (file)
@@ -16,6 +16,7 @@ namespace TYPO3\CMS\Scheduler\Task;
 
 use TYPO3\CMS\Core\Database\Connection;
 use TYPO3\CMS\Core\Database\ConnectionPool;
+use TYPO3\CMS\Core\Localization\LanguageService;
 use TYPO3\CMS\Core\Messaging\FlashMessage;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Scheduler\AbstractAdditionalFieldProvider;
@@ -92,14 +93,14 @@ class OptimizeDatabaseTableAdditionalFieldProvider extends AbstractAdditionalFie
             );
             if (!empty($invalidTables)) {
                 $this->addMessage(
-                    $GLOBALS['LANG']->sL($this->languageFile . ':msg.selectionOfNonExistingDatabaseTables'),
+                    $this->getLanguageService()->sL($this->languageFile . ':msg.selectionOfNonExistingDatabaseTables'),
                     FlashMessage::ERROR
                 );
                 $validData = false;
             }
         } else {
             $this->addMessage(
-                $GLOBALS['LANG']->sL($this->languageFile . ':msg.noDatabaseTablesSelected'),
+                $this->getLanguageService()->sL($this->languageFile . ':msg.noDatabaseTablesSelected'),
                 FlashMessage::ERROR
             );
             $validData = false;
@@ -228,4 +229,12 @@ class OptimizeDatabaseTableAdditionalFieldProvider extends AbstractAdditionalFie
 
         return array_column($tables, 'Table');
     }
+
+    /**
+     * @return LanguageService|null
+     */
+    protected function getLanguageService(): ?LanguageService
+    {
+        return $GLOBALS['LANG'] ?? null;
+    }
 }
index 8604b70..3db1f17 100644 (file)
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Scheduler\Task;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Localization\LanguageService;
 use TYPO3\CMS\Core\Messaging\FlashMessage;
 use TYPO3\CMS\Scheduler\AbstractAdditionalFieldProvider;
 use TYPO3\CMS\Scheduler\Controller\SchedulerModuleController;
@@ -82,7 +83,7 @@ class RecyclerGarbageCollectionAdditionalFieldProvider extends AbstractAdditiona
         // If not, fail validation and issue error message
         if (!is_numeric($submittedData['scheduler_recyclerGarbageCollection_numberOfDays']) || (int)$submittedData['scheduler_recyclerGarbageCollection_numberOfDays'] < 0) {
             $result = false;
-            $this->addMessage($GLOBALS['LANG']->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:msg.invalidNumberOfDays'), FlashMessage::ERROR);
+            $this->addMessage($this->getLanguageService()->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:msg.invalidNumberOfDays'), FlashMessage::ERROR);
         }
         return $result;
     }
@@ -97,4 +98,12 @@ class RecyclerGarbageCollectionAdditionalFieldProvider extends AbstractAdditiona
     {
         $task->numberOfDays = (int)$submittedData['scheduler_recyclerGarbageCollection_numberOfDays'];
     }
+
+    /**
+     * @return LanguageService|null
+     */
+    protected function getLanguageService(): ?LanguageService
+    {
+        return $GLOBALS['LANG'] ?? null;
+    }
 }
index af1e43b..9a8ab88 100644 (file)
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Scheduler\Task;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Localization\LanguageService;
 use TYPO3\CMS\Core\Messaging\FlashMessage;
 use TYPO3\CMS\Scheduler\AbstractAdditionalFieldProvider;
 use TYPO3\CMS\Scheduler\Controller\SchedulerModuleController;
@@ -245,7 +246,7 @@ class TableGarbageCollectionAdditionalFieldProvider extends AbstractAdditionalFi
             $validData = true;
         } else {
             // Issue error message
-            $this->addMessage($GLOBALS['LANG']->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:msg.invalidNumberOfDays'), FlashMessage::ERROR);
+            $this->addMessage($this->getLanguageService()->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:msg.invalidNumberOfDays'), FlashMessage::ERROR);
         }
         return $validData;
     }
@@ -262,4 +263,12 @@ class TableGarbageCollectionAdditionalFieldProvider extends AbstractAdditionalFi
         $task->table = $submittedData['scheduler_tableGarbageCollection_table'];
         $task->numberOfDays = (int)$submittedData['scheduler_tableGarbageCollection_numberOfDays'];
     }
+
+    /**
+     * @return LanguageService|null
+     */
+    protected function getLanguageService(): ?LanguageService
+    {
+        return $GLOBALS['LANG'] ?? null;
+    }
 }
index 9d8150a..bc4292c 100644 (file)
@@ -122,9 +122,9 @@ class TableGarbageCollectionTask extends AbstractTask
     public function getAdditionalInformation()
     {
         if ($this->allTables) {
-            $message = $GLOBALS['LANG']->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:label.tableGarbageCollection.additionalInformationAllTables');
+            $message = $this->getLanguageService()->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:label.tableGarbageCollection.additionalInformationAllTables');
         } else {
-            $message = sprintf($GLOBALS['LANG']->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:label.tableGarbageCollection.additionalInformationTable'), $this->table);
+            $message = sprintf($this->getLanguageService()->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:label.tableGarbageCollection.additionalInformationTable'), $this->table);
         }
         return $message;
     }
index 5f1bd30..0857450 100644 (file)
@@ -16,6 +16,7 @@ namespace TYPO3\CMS\Workspaces\Hook;
  */
 
 use TYPO3\CMS\Backend\Utility\BackendUtility;
+use TYPO3\CMS\Core\Localization\LanguageService;
 use TYPO3\CMS\Core\Messaging\FlashMessage;
 use TYPO3\CMS\Core\Messaging\FlashMessageService;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -62,7 +63,7 @@ class BackendUtilityHook
                 $stages = GeneralUtility::makeInstance(StagesService::class);
                 $stageName = $stages->getStageTitle($record['t3ver_stage']);
                 $editingName = $stages->getStageTitle(StagesService::STAGE_EDIT_ID);
-                $message = $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xlf:info.elementAlreadyModified');
+                $message = $this->getLanguageService()->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xlf:info.elementAlreadyModified');
                 $flashMessage = GeneralUtility::makeInstance(FlashMessage::class, sprintf($message, $stageName, $editingName), '', FlashMessage::INFO, true);
                 /** @var FlashMessageService $flashMessageService */
                 $flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class);
@@ -73,4 +74,12 @@ class BackendUtilityHook
         }
         return $params['hasAccess'];
     }
+
+    /**
+     * @return LanguageService|null
+     */
+    protected function getLanguageService(): ?LanguageService
+    {
+        return $GLOBALS['LANG'] ?? null;
+    }
 }
index 7612c36..cbff406 100644 (file)
@@ -18,6 +18,7 @@ use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
 use TYPO3\CMS\Core\Database\Connection;
 use TYPO3\CMS\Core\Database\ConnectionPool;
+use TYPO3\CMS\Core\Localization\LanguageService;
 use TYPO3\CMS\Core\SingletonInterface;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\MathUtility;
@@ -252,9 +253,9 @@ class StagesService implements SingletonInterface
                 'label' => $stageRecord->getTitle(),
             ];
             if (!$stageRecord->isExecuteStage()) {
-                $stage['title'] = $GLOBALS['LANG']->sL($this->pathToLocallang . ':actionSendToStage') . ' "' . $stageRecord->getTitle() . '"';
+                $stage['title'] = $this->getLanguageService()->sL($this->pathToLocallang . ':actionSendToStage') . ' "' . $stageRecord->getTitle() . '"';
             } else {
-                $stage['title'] = $GLOBALS['LANG']->sL($this->pathToLocallang . ':publish_execute_action_option');
+                $stage['title'] = $this->getLanguageService()->sL($this->pathToLocallang . ':publish_execute_action_option');
             }
             $stagesArray[] = $stage;
         }
@@ -271,18 +272,18 @@ class StagesService implements SingletonInterface
     {
         switch ($ver_stage) {
             case self::STAGE_PUBLISH_EXECUTE_ID:
-                $stageTitle = $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang_mod_user_ws.xlf:stage_publish');
+                $stageTitle = $this->getLanguageService()->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang_mod_user_ws.xlf:stage_publish');
                 break;
             case self::STAGE_PUBLISH_ID:
-                $stageTitle = $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang_mod.xlf:stage_ready_to_publish');
+                $stageTitle = $this->getLanguageService()->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang_mod.xlf:stage_ready_to_publish');
                 break;
             case self::STAGE_EDIT_ID:
-                $stageTitle = $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang_mod_user_ws.xlf:stage_editing');
+                $stageTitle = $this->getLanguageService()->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang_mod_user_ws.xlf:stage_editing');
                 break;
             default:
                 $stageTitle = $this->getPropertyOfCurrentWorkspaceStage($ver_stage, 'title');
                 if ($stageTitle == null) {
-                    $stageTitle = $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xlf:error.getStageTitle.stageNotFound');
+                    $stageTitle = $this->getLanguageService()->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xlf:error.getStageTitle.stageNotFound');
                 }
         }
         return $stageTitle;
@@ -310,7 +311,7 @@ class StagesService implements SingletonInterface
     {
         if (!MathUtility::canBeInterpretedAsInteger($stageId)) {
             throw new \InvalidArgumentException(
-                $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xlf:error.stageId.integer'),
+                $this->getLanguageService()->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xlf:error.stageId.integer'),
                 1291109987
             );
         }
@@ -330,8 +331,8 @@ class StagesService implements SingletonInterface
         if ($nextStage === false) {
             $nextStage[] = [
                 'uid' => self::STAGE_EDIT_ID,
-                'title' => $GLOBALS['LANG']->sL($this->pathToLocallang . ':actionSendToStage') . ' "'
-                    . $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang_mod_user_ws.xlf:stage_editing') . '"'
+                'title' => $this->getLanguageService()->sL($this->pathToLocallang . ':actionSendToStage') . ' "'
+                    . $this->getLanguageService()->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang_mod_user_ws.xlf:stage_editing') . '"'
             ];
         }
         return $nextStage;
@@ -377,7 +378,7 @@ class StagesService implements SingletonInterface
     {
         if (!MathUtility::canBeInterpretedAsInteger($stageId)) {
             throw new \InvalidArgumentException(
-                $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xlf:error.stageId.integer'),
+                $this->getLanguageService()->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xlf:error.stageId.integer'),
                 1476048351
             );
         }
@@ -651,7 +652,7 @@ class StagesService implements SingletonInterface
         $result = null;
         if (!MathUtility::canBeInterpretedAsInteger($stageId)) {
             throw new \InvalidArgumentException(
-                $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xlf:error.stageId.integer'),
+                $this->getLanguageService()->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xlf:error.stageId.integer'),
                 1476048371
             );
         }
@@ -788,4 +789,12 @@ class StagesService implements SingletonInterface
     {
         return $GLOBALS['BE_USER'];
     }
+
+    /**
+     * @return LanguageService|null
+     */
+    protected function getLanguageService(): ?LanguageService
+    {
+        return $GLOBALS['LANG'] ?? null;
+    }
 }
index 6ec21a4..323591f 100644 (file)
@@ -21,6 +21,7 @@ use TYPO3\CMS\Core\Database\Query\QueryBuilder;
 use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
 use TYPO3\CMS\Core\Database\Query\Restriction\RootLevelRestriction;
 use TYPO3\CMS\Core\Database\QueryView;
+use TYPO3\CMS\Core\Localization\LanguageService;
 use TYPO3\CMS\Core\SingletonInterface;
 use TYPO3\CMS\Core\Type\Bitmask\Permission;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -111,7 +112,7 @@ class WorkspaceService implements SingletonInterface
         $title = false;
         switch ($wsId) {
             case self::LIVE_WORKSPACE_ID:
-                $title = $GLOBALS['LANG']->sL('LLL:EXT:core/Resources/Private/Language/locallang_misc.xlf:shortcut_onlineWS');
+                $title = static::getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_misc.xlf:shortcut_onlineWS');
                 break;
             default:
                 $labelField = $GLOBALS['TCA']['sys_workspace']['ctrl']['label'];
@@ -918,4 +919,12 @@ class WorkspaceService implements SingletonInterface
             ->add(GeneralUtility::makeInstance(DeletedRestriction::class));
         return $queryBuilder;
     }
+
+    /**
+     * @return LanguageService|null
+     */
+    protected static function getLanguageService(): ?LanguageService
+    {
+        return $GLOBALS['LANG'] ?? null;
+    }
 }