[BUGFIX] Fix Misleading CommandController naming for Language update 11/24511/5
authorCedric Ziel <cedric@cedric-ziel.com>
Wed, 9 Oct 2013 23:12:14 +0000 (01:12 +0200)
committerWouter Wolters <typo3@wouterwolters.nl>
Fri, 7 Mar 2014 19:44:38 +0000 (20:44 +0100)
Due to CommandControllers' nature, an UpdateCommandController leads to the
execution of `cli_dispatch.phpsh extbase update:update`.

This patch fixes it to `cli_dispatch.phpsh extbase language:update`.

Also contains a minor change and adds a type-hint for IDE's.

Resolves: #54128
Releases: 6.2
Change-Id: I1b21b8f715bfd1928f1e857846c0542d90705b6f
Reviewed-on: https://review.typo3.org/24511
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
typo3/sysext/lang/Classes/Command/LanguageCommandController.php [new file with mode: 0644]
typo3/sysext/lang/Classes/Command/UpdateCommandController.php
typo3/sysext/lang/ext_localconf.php

diff --git a/typo3/sysext/lang/Classes/Command/LanguageCommandController.php b/typo3/sysext/lang/Classes/Command/LanguageCommandController.php
new file mode 100644 (file)
index 0000000..dcd1afc
--- /dev/null
@@ -0,0 +1,80 @@
+<?php
+namespace TYPO3\CMS\Lang\Command;
+
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2013 Wouter Wolters <typo3@wouterwolters.nl>
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+/**
+ * Language command controller updates translation packages
+ */
+class LanguageCommandController extends \TYPO3\CMS\Extbase\Mvc\Controller\CommandController {
+
+       /**
+        * @var \TYPO3\CMS\Core\Package\PackageManager
+        * @inject
+        */
+       protected $packageManager;
+
+       /**
+        * @var \TYPO3\CMS\Extbase\SignalSlot\Dispatcher
+        * @inject
+        */
+       protected $signalSlotDispatcher;
+
+       /**
+        * Update language file for each extension
+        *
+        * @param string $localesToUpdate Comma separated list of locales that needs to be updated
+        * @return void
+        * @deprecated Use LanguageCommandController (language:update) instead. will be removed two versions after 6.2
+        */
+       public function updateCommand($localesToUpdate = '') {
+               /** @var $updateTranslationService \TYPO3\CMS\Lang\Service\UpdateTranslationService */
+               $updateTranslationService = $this->objectManager->get('TYPO3\\CMS\\Lang\Service\\UpdateTranslationService');
+               /** @var $languageRepository \TYPO3\CMS\Lang\Domain\Repository\LanguageRepository */
+               $languageRepository = $this->objectManager->get('TYPO3\\CMS\\Lang\\Domain\\Repository\\LanguageRepository');
+
+               $locales = array();
+               if (!empty($localesToUpdate)) {
+                       $locales = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $localesToUpdate, TRUE);
+               } else {
+                       $languages = $languageRepository->findSelected();
+                       foreach ($languages as $language) {
+                               /** @var $language \TYPO3\CMS\Lang\Domain\Model\Language */
+                               $locales[] = $language->getLocale();
+                       }
+               }
+               $this->packageManager = $this->objectManager->get('TYPO3\\CMS\\Core\\Package\\PackageManager');
+               $this->emitPackagesMayHaveChanged();
+               foreach ($this->packageManager->getAvailablePackages() as $package) {
+                       $updateTranslationService->updateTranslation($package->getPackageKey(), $locales);
+               }
+       }
+
+       /**
+        * Emits packages may have changed signal
+        */
+       protected function emitPackagesMayHaveChanged() {
+               $this->signalSlotDispatcher->dispatch('PackageManagement', 'packagesMayHaveChanged');
+       }
+}
index 4326bce..aadb7ee 100644 (file)
@@ -30,49 +30,16 @@ namespace TYPO3\CMS\Lang\Command;
 class UpdateCommandController extends \TYPO3\CMS\Extbase\Mvc\Controller\CommandController {
 
        /**
-        * @var \TYPO3\CMS\Core\Package\PackageManager
-        * @inject
-        */
-       protected $packageManager;
-
-       /**
-        * @var \TYPO3\CMS\Extbase\SignalSlot\Dispatcher
-        * @inject
-        */
-       protected $signalSlotDispatcher;
-
-       /**
         * Update language file for each extension
         *
         * @param string $localesToUpdate Comma separated list of locales that needs to be updated
         * @return void
+        * @deprecated Use LanguageCommandController (language:update) instead. will be removed two versions after 6.2
         */
        public function updateCommand($localesToUpdate = '') {
-               /** @var $updateTranslationService \TYPO3\CMS\Lang\Service\UpdateTranslationService */
-               $updateTranslationService = $this->objectManager->get('TYPO3\\CMS\\Lang\Service\\UpdateTranslationService');
-               /** @var $languageRepository \TYPO3\CMS\Lang\Domain\Repository\LanguageRepository */
-               $languageRepository = $this->objectManager->get('TYPO3\\CMS\\Lang\\Domain\\Repository\\LanguageRepository');
-
-               $locales = array();
-               if (!empty($localesToUpdate)) {
-                       $locales = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $localesToUpdate, TRUE);
-               } else {
-                       $languages = $languageRepository->findSelected();
-                       foreach ($languages as $language) {
-                               $locales[] = $language->getLocale();
-                       }
-               }
-               $this->packageManager = $this->objectManager->get('TYPO3\\CMS\\Core\\Package\\PackageManager');
-               $this->emitPackagesMayHaveChanged();
-               foreach ($this->packageManager->getAvailablePackages() as $package) {
-                       $updateTranslationService->updateTranslation($package->getPackageKey(), $locales);
-               }
-       }
-
-       /**
-        * Emits packages may have changed signal
-        */
-       protected function emitPackagesMayHaveChanged() {
-               $this->signalSlotDispatcher->dispatch('PackageManagement', 'packagesMayHaveChanged');
+               \TYPO3\CMS\Core\Utility\GeneralUtility::logDeprecatedFunction();
+               $this->outputLine('Calling update:update is deprecated since 6.2, use language:update instead');
+               $languageCommandController = $this->objectManager->get('TYPO3\\CMS\\Lang\\Command\\LanguageCommandController');
+               $languageCommandController->updateCommand($localesToUpdate);
        }
 }
index 665b2a9..fc99b33 100644 (file)
@@ -4,4 +4,8 @@ if (!defined('TYPO3_MODE')) {
 }
 
 // Register language update command controller
+// @deprecated since TYPO3 CMS 6.2 will be removed in 2 versions
 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['extbase']['commandControllers'][] = 'TYPO3\\CMS\\Lang\\Command\\UpdateCommandController';
+
+// Register language update command controller
+$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['extbase']['commandControllers'][] = 'TYPO3\\CMS\\Lang\\Command\\LanguageCommandController';