[TASK] Deprecate second argument of PageRenderer::addInlineLanguageLabelArray 58/57858/3
authorWouter Wolters <typo3@wouterwolters.nl>
Fri, 10 Aug 2018 12:36:21 +0000 (14:36 +0200)
committerBenni Mack <benni@typo3.org>
Sat, 11 Aug 2018 18:19:55 +0000 (20:19 +0200)
Calling `PageRenderer::addInlineLanguageLabelArray` with a second
parameter set to "true" is deprecated. Use the LanguageService directly
when defining your labels.

Resolves: #85806
Releases: master
Change-Id: I92b5186a8e540f91b5873f007934624c4facf1fb
Reviewed-on: https://review.typo3.org/57858
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
typo3/sysext/backend/Classes/Form/FormResultCompiler.php
typo3/sysext/core/Classes/Page/PageRenderer.php
typo3/sysext/core/Documentation/Changelog/master/Deprecation-85806-DeprecateSecondArgumentOfPageRendereraddInlineLanguageLabelArray.rst [new file with mode: 0644]
typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodArgumentDroppedMatcher.php
typo3/sysext/setup/Classes/Controller/SetupModuleController.php

index 83c9da5..eb75894 100644 (file)
@@ -272,14 +272,14 @@ class FormResultCompiler
 
         // todo: change these things in JS
         $pageRenderer->addInlineLanguageLabelArray([
-            'FormEngine.noRecordTitle'          => 'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.no_title',
-            'FormEngine.fieldsChanged'          => 'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.fieldsChanged',
-            'FormEngine.fieldsMissing'          => 'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.fieldsMissing',
-            'FormEngine.maxItemsAllowed'        => 'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.maxItemsAllowed',
-            'FormEngine.refreshRequiredTitle'   => 'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:mess.refreshRequired.title',
-            'FormEngine.refreshRequiredContent' => 'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:mess.refreshRequired.content',
-            'FormEngine.remainingCharacters'    => 'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.remainingCharacters',
-        ], true);
+            'FormEngine.noRecordTitle'          => $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.no_title'),
+            'FormEngine.fieldsChanged'          => $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.fieldsChanged'),
+            'FormEngine.fieldsMissing'          => $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.fieldsMissing'),
+            'FormEngine.maxItemsAllowed'        => $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.maxItemsAllowed'),
+            'FormEngine.refreshRequiredTitle'   => $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:mess.refreshRequired.title'),
+            'FormEngine.refreshRequiredContent' => $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:mess.refreshRequired.content'),
+            'FormEngine.remainingCharacters'    => $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.remainingCharacters'),
+        ]);
 
         $out = LF . 'TBE_EDITOR.doSaveFieldName = "' . ($this->doSaveFieldName ? addslashes($this->doSaveFieldName) : '') . '";';
 
@@ -307,6 +307,16 @@ class FormResultCompiler
     }
 
     /**
+     * Returns an instance of LanguageService
+     *
+     * @return \TYPO3\CMS\Core\Localization\LanguageService
+     */
+    protected function getLanguageService()
+    {
+        return $GLOBALS['LANG'];
+    }
+
+    /**
      * Wrapper for access to the current page renderer object
      *
      * @return \TYPO3\CMS\Core\Page\PageRenderer
index e564dc6..097e1d2 100644 (file)
@@ -1525,9 +1525,10 @@ class PageRenderer implements \TYPO3\CMS\Core\SingletonInterface
      * @param array $array
      * @param bool $parseWithLanguageService
      */
-    public function addInlineLanguageLabelArray(array $array, $parseWithLanguageService = false)
+    public function addInlineLanguageLabelArray(array $array, $parseWithLanguageService = null)
     {
         if ($parseWithLanguageService === true) {
+            trigger_error('PageRenderer::addInlineLanguageLabelArray() second method argument set to true is deprecated, and will be removed in TYPO3 v10.0.', E_USER_DEPRECATED);
             foreach ($array as $key => $value) {
                 if (TYPO3_MODE === 'FE') {
                     $array[$key] = $this->getTypoScriptFrontendController()->sL($value);
@@ -1535,6 +1536,8 @@ class PageRenderer implements \TYPO3\CMS\Core\SingletonInterface
                     $array[$key] = $this->getLanguageService()->sL($value);
                 }
             }
+        } elseif ($parseWithLanguageService !== null) {
+            trigger_error('PageRenderer::addInlineLanguageLabelArray() does not need a second method argument anymore, and will be removed in TYPO3 v10.0.', E_USER_DEPRECATED);
         }
 
         $this->inlineLanguageLabels = array_merge($this->inlineLanguageLabels, $array);
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-85806-DeprecateSecondArgumentOfPageRendereraddInlineLanguageLabelArray.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-85806-DeprecateSecondArgumentOfPageRendereraddInlineLanguageLabelArray.rst
new file mode 100644 (file)
index 0000000..ddbc74e
--- /dev/null
@@ -0,0 +1,35 @@
+.. include:: ../../Includes.txt
+
+============================================================================================
+Deprecation: #85806 - Deprecate second argument of PageRenderer::addInlineLanguageLabelArray
+============================================================================================
+
+See :issue:`85806`
+
+Description
+===========
+
+The second argument in :php:`TYPO3\CMS\Core\Page\PageRenderer::addInlineLanguageLabelArray()` has been deprecated.
+
+Setting this (optional) argument to :php:`true` must be resolved by using the :php:`TYPO3\CMS\Core\Localization\LanguageService` directly.
+
+
+Impact
+======
+
+Calling the method with an explicitly set second argument will trigger a deprecation message.
+
+
+Affected Installations
+======================
+
+Any TYPO3 installation with a custom extension calling the method above with a second method argument.
+
+
+Migration
+=========
+
+If the second argument was set to :php:`true` before, use the :php:`TYPO3\CMS\Core\Localization\LanguageService`, if the
+second parameter was set to :php:`false` before, just remove the second argument.
+
+.. index:: PHP-API, FullyScanned, ext:core
\ No newline at end of file
index db9f44b..bf34a9f 100644 (file)
@@ -205,4 +205,10 @@ return [
             'Deprecation-85804-SaltedPasswordHashClassDeprecations.rst',
         ],
     ],
+    'TYPO3\CMS\Core\Page\PageRenderer->addInlineLanguageLabelArray' => [
+        'maximumNumberOfArguments' => 1,
+        'restFiles' => [
+            'Deprecation-85806-DeprecateSecondArgumentOfPageRendereraddInlineLanguageLabelArray.rst',
+        ],
+    ],
 ];
index 13bc4c5..c6e400d 100644 (file)
@@ -194,8 +194,8 @@ class SetupModuleController
         $pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/FormEngine');
         $pageRenderer->addInlineSetting('FormEngine', 'formName', 'editform');
         $pageRenderer->addInlineLanguageLabelArray([
-            'FormEngine.remainingCharacters'    => 'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.remainingCharacters',
-        ], true);
+            'FormEngine.remainingCharacters' => $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.remainingCharacters'),
+        ]);
     }
 
     /**