[TASK] Allow command controller classes to reside in subfolders 75/42275/4
authorThorsten Boock <tboock@codegy.de>
Wed, 5 Aug 2015 13:48:40 +0000 (15:48 +0200)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Thu, 6 Aug 2015 08:19:23 +0000 (10:19 +0200)
CommandController classes were required to reside in the main
folder inside Classes and have to be named like <name>CommandController.
With this change, the usage of subfolders is permitted, the namespace
needs to reflect the position under the Classes folder.
The CommandController Suffix is kept.

Resolves: #68758
Releases: master
Change-Id: Ic8afa101120bfde1397183c174a694aeddda63a0
Reviewed-on: http://review.typo3.org/42275
Reviewed-by: Felix Oertel <mehl@foertel.com>
Tested-by: Felix Oertel <mehl@foertel.com>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
typo3/sysext/extbase/Classes/Mvc/Cli/Command.php
typo3/sysext/extbase/Tests/Unit/Mvc/Cli/CommandTest.php

index fc8bf76..8add314 100644 (file)
@@ -89,15 +89,23 @@ class Command {
                        unset($classNameParts[1]);
                        $classNameParts = array_values($classNameParts);
                }
-               if (count($classNameParts) !== 4 || strpos($classNameParts[3], 'CommandController') === FALSE) {
+               $numberOfClassNameParts = count($classNameParts);
+               if ($numberOfClassNameParts < 3) {
+                       throw new \InvalidArgumentException(
+                               'Controller class names must at least consist of three parts: vendor, extension name and path.',
+                               1438782187
+                       );
+               }
+               if (strpos($classNameParts[$numberOfClassNameParts - 1], 'CommandController') === FALSE) {
                        throw new \InvalidArgumentException(
                                'Invalid controller class name "' . $controllerClassName . '". Class name must end with "CommandController".',
                                1305100019
                        );
                }
+
                $this->extensionName = $classNameParts[1];
                $extensionKey = \TYPO3\CMS\Core\Utility\GeneralUtility::camelCaseToLowerCaseUnderscored($this->extensionName);
-               $this->commandIdentifier = strtolower($extensionKey . ':' . substr($classNameParts[3], 0, -17) . ':' . $controllerCommandName);
+               $this->commandIdentifier = strtolower($extensionKey . ':' . substr($classNameParts[$numberOfClassNameParts - 1], 0, -17) . ':' . $controllerCommandName);
        }
 
        /**
index 0dbd87c..fa7e1be 100644 (file)
@@ -58,7 +58,8 @@ class CommandTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
        public function commandIdentifiers() {
                return array(
                        array('Tx_ExtensionKey_Command_CacheCommandController', 'flush', 'extension_key:cache:flush'),
-                       array('Tx_Ext_Command_CookieCommandController', 'bake', 'ext:cookie:bake')
+                       array('Tx_Ext_Command_CookieCommandController', 'bake', 'ext:cookie:bake'),
+                       array('Tx_OtherExtensionKey_Foo_Faa_Fuuum_Command_CoffeeCommandController', 'brew', 'other_extension_key:coffee:brew'),
                );
        }
 
@@ -81,8 +82,6 @@ class CommandTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                return array(
                        array(''),
                        // CommandClassName must not be empty
-                       array('Tx_OtherExtensionKey_Foo_Faa_Fuuum_Command_CoffeeCommandController'),
-                       // CommandControllers in subpackages are not supported
                        array('Foo')
                );
        }