[BUGFIX] Make saving scheduler commandController tasks working again
authorMarc Bastian Heinrichs <typo3@mbh-software.de>
Sat, 17 Nov 2012 18:42:28 +0000 (19:42 +0100)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Mon, 19 Nov 2012 03:49:27 +0000 (04:49 +0100)
After converting to namespaces the name of the configuration fields
in backend also contains namespaces. Rename them back to the original
name.
Also the commands select box option labels wasn't compatible to
namespaces.

Fixes: #43035
Releases: 6.0

Change-Id: I6f86cccaf6936f4ef8c64d830143930f1a48971c
Reviewed-on: http://review.typo3.org/16538
Reviewed-by: Markus G√ľnther
Reviewed-by: Anja Leichsenring
Tested-by: Anja Leichsenring
Reviewed-by: Ingo Pfennigstorf
Tested-by: Ingo Pfennigstorf
typo3/sysext/extbase/Classes/Scheduler/FieldProvider.php
typo3/sysext/extbase/Tests/Unit/Scheduler/FieldProviderTest.php

index 899a95d..afc8bd2 100644 (file)
@@ -135,7 +135,7 @@ class FieldProvider implements \TYPO3\CMS\Scheduler\AdditionalFieldProviderInter
                foreach ($commands as $command) {
                        if ($command->isInternal() === FALSE) {
                                $className = $command->getControllerClassName();
-                               if (strpos($command->getControllerClassName(), '\\')) {
+                               if (strpos($className, '\\')) {
                                        $classNameParts = explode('\\', $className);
                                        // Skip vendor and product name for core classes
                                        if (strpos($className, 'TYPO3\\CMS\\') === 0) {
@@ -144,11 +144,15 @@ class FieldProvider implements \TYPO3\CMS\Scheduler\AdditionalFieldProviderInter
                                                $classPartsToSkip = 1;
                                        }
                                        $classNameParts = array_slice($classNameParts, $classPartsToSkip);
+                                       $extensionName = $classNameParts[0];
+                                       $controllerName = $classNameParts[2];
                                } else {
                                        $classNameParts = explode('_', $className);
+                                       $extensionName = $classNameParts[1];
+                                       $controllerName = $classNameParts[3];
                                }
                                $identifier = $command->getCommandIdentifier();
-                               $options[$identifier] = $classNameParts[1] . ' ' . str_replace('CommandController', '', $classNameParts[3]) . ': ' . $command->getControllerCommandName();
+                               $options[$identifier] = $extensionName . ' ' . str_replace('CommandController', '', $controllerName) . ': ' . $command->getControllerCommandName();
                        }
                }
                $name = 'action';
@@ -287,7 +291,7 @@ class FieldProvider implements \TYPO3\CMS\Scheduler\AdditionalFieldProviderInter
         */
        protected function renderSelectField($name, array $options, $selectedOptionValue) {
                $html = array(
-                       '<select name="TYPO3\\CMS\\Scheduler\\Scheduler[task_extbase][' . htmlspecialchars($name) . ']">'
+                       '<select name="tx_scheduler[task_extbase][' . htmlspecialchars($name) . ']">'
                );
                foreach ($options as $optionValue => $optionLabel) {
                        $selected = $optionValue === $selectedOptionValue ? ' selected="selected"' : '';
@@ -307,7 +311,7 @@ class FieldProvider implements \TYPO3\CMS\Scheduler\AdditionalFieldProviderInter
        protected function renderField(\TYPO3\CMS\Extbase\Mvc\Cli\CommandArgumentDefinition $argument, $currentValue) {
                $type = $this->getArgumentType($argument);
                $name = $argument->getName();
-               $fieldName = 'TYPO3\\CMS\\Scheduler\\Scheduler[task_extbase][arguments][' . htmlspecialchars($name) . ']';
+               $fieldName = 'tx_scheduler[task_extbase][arguments][' . htmlspecialchars($name) . ']';
                if ($type === 'boolean') {
                        // checkbox field for boolean values.
                        $html = '<input type="hidden" name="' . $fieldName . '" value="0" />';
index ad3698d..0f64e7a 100644 (file)
@@ -44,20 +44,33 @@ class FieldProviderTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
         */
        protected $fieldProvider;
 
+
        /**
+        *
         * @test
         */
        public function getCommandControllerActionFieldFetchesCorrectClassNames() {
                $fieldProvider = $fieldProvider = $this->getMock($this->buildAccessibleProxy('\TYPO3\CMS\Extbase\Scheduler\FieldProvider'), array('dummy'));
                $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['extbase']['commandControllers'] = array(
-                       'TYPO3\\CMS\\Extbase\\Tests\\MockACommandController'
+                       'TYPO3\\CMS\\Extbase\\Tests\\MockACommandController',
+                       'Acme\\Mypkg\\Command\\MockCCommandController',
+                       'Tx_Extbase_Command_MockDCommandController'
                );
-               eval('namespace TYPO3\\CMS\\Extbase\\Tests; class MockACommandController extends \TYPO3\CMS\Extbase\Mvc\Controller\CommandController { function MockACommand() {} } ');
+               eval('
+                       namespace TYPO3\\CMS\\Extbase\\Tests; class MockACommandController extends \TYPO3\CMS\Extbase\Mvc\Controller\CommandController { function mockBCommand() {} }
+                       namespace Acme\\Mypkg\\Command; class MockCCommandController extends \TYPO3\CMS\Extbase\Mvc\Controller\CommandController { function mockBCommand() {} }
+               ');
+               eval('
+                       class Tx_Extbase_Command_MockDCommandController extends Tx_Extbase_MVC_Controller_CommandController { function mockBCommand() {} }
+               ');
 
                $actualResult = $fieldProvider->_call('getCommandControllerActionField', array());
-               $this->assertContains('<option title="test" value="extbase:mocka:mocka">Tests : MockA</option>', $actualResult['code']);
+               $this->assertContains('<option title="test" value="extbase:mocka:mockb">Extbase MockA: mockB</option>', $actualResult['code']);
+               $this->assertContains('<option title="test" value="mypkg:mockc:mockb">Mypkg MockC: mockB</option>', $actualResult['code']);
+               $this->assertContains('<option title="test" value="extbase:mockd:mockb">Extbase MockD: mockB</option>', $actualResult['code']);
        }
 
+
        /**
         * @test
         */