[TASK] Rename DatabaseRowGroupRelations to TcaGroups 41/43241/2
authorMichael Oehlhof <typo3@oehlhof.de>
Sat, 12 Sep 2015 13:31:22 +0000 (15:31 +0200)
committerWouter Wolters <typo3@wouterwolters.nl>
Sat, 12 Sep 2015 15:57:42 +0000 (17:57 +0200)
Resolves: #69731
Releases: master
Change-Id: I06bf6fad1096dfc4f2396f5efae265eba9da25e5
Reviewed-on: http://review.typo3.org/43241
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
typo3/sysext/backend/Classes/Form/FormDataProvider/DatabaseRowGroupRelations.php [deleted file]
typo3/sysext/backend/Classes/Form/FormDataProvider/TcaGroup.php [new file with mode: 0644]
typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/DatabaseRowGroupRelationsTest.php [deleted file]
typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/TcaGroupTest.php [new file with mode: 0644]
typo3/sysext/core/Configuration/DefaultConfiguration.php

diff --git a/typo3/sysext/backend/Classes/Form/FormDataProvider/DatabaseRowGroupRelations.php b/typo3/sysext/backend/Classes/Form/FormDataProvider/DatabaseRowGroupRelations.php
deleted file mode 100644 (file)
index b3c2229..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-<?php
-namespace TYPO3\CMS\Backend\Form\FormDataProvider;
-
-/*
- * This file is part of the TYPO3 CMS project.
- *
- * It is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License, either version 2
- * of the License, or any later version.
- *
- * For the full copyright and license information, please read the
- * LICENSE.txt file that was distributed with this source code.
- *
- * The TYPO3 project - inspiring people to share!
- */
-
-use TYPO3\CMS\Backend\Form\FormDataProviderInterface;
-use TYPO3\CMS\Core\Database\RelationHandler;
-use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Core\Utility\PathUtility;
-
-/**
- * Resolve databaseRow field content to the real connected rows for type=group
- */
-class DatabaseRowGroupRelations implements FormDataProviderInterface {
-
-       /**
-        * Initialize new row with default values from various sources
-        *
-        * @param array $result
-        * @return array
-        * @todo: Should be renamed to TcaGroup to be in line with the other element based classes
-        * @todo: Should not implode valid values with | again, container & elements should work
-        * @todo: with the array as it was done for select items
-        * @throws \UnexpectedValueException
-        */
-       public function addData(array $result) {
-               foreach ($result['vanillaTableTca']['columns'] as $fieldName => $fieldConfig) {
-                       if (empty($fieldConfig['config']['type'])
-                               || $fieldConfig['config']['type'] !== 'group'
-                               || empty($fieldConfig['config']['internal_type'])
-                       ) {
-                               continue;
-                       }
-
-                       $databaseRowFieldContent = '';
-                       if (!empty($result['databaseRow'][$fieldName])) {
-                               $databaseRowFieldContent = (string)$result['databaseRow'][$fieldName];
-                       }
-
-                       $internalType = $fieldConfig['config']['internal_type'];
-                       if ($internalType === 'file_reference' || $internalType === 'file') {
-                               $files = array();
-                               // Simple list of files
-                               $fileList = GeneralUtility::trimExplode(',', $databaseRowFieldContent, TRUE);
-                               foreach ($fileList as $file) {
-                                       if ($file) {
-                                               $files[] = rawurlencode($file) . '|' . rawurlencode(PathUtility::basename($file));
-                                       }
-                               }
-                               $result['databaseRow'][$fieldName] = implode(',', $files);
-                       } elseif ($internalType === 'db') {
-                               /** @var $relationHandler RelationHandler */
-                               $relationHandler = GeneralUtility::makeInstance(RelationHandler::class);
-                               $relationHandler->start(
-                                       $databaseRowFieldContent,
-                                       $fieldConfig['config']['allowed'],
-                                       $fieldConfig['config']['MM'],
-                                       $result['databaseRow']['uid'],
-                                       $result['tableName'],
-                                       $fieldConfig['config']
-                               );
-                               $relationHandler->getFromDB();
-                               $result['databaseRow'][$fieldName] = $relationHandler->readyForInterface();
-                       } else {
-                               // @todo: "folder" is a valid internal_type, too.
-                               throw new \UnexpectedValueException(
-                                       'TCA internal_type of field "' . $fieldName . '" in table ' . $result['tableName']
-                                       .' must be set to either "db", "file" or "file_reference"',
-                                       1438780511
-                               );
-                       }
-               }
-
-               return $result;
-       }
-
-}
diff --git a/typo3/sysext/backend/Classes/Form/FormDataProvider/TcaGroup.php b/typo3/sysext/backend/Classes/Form/FormDataProvider/TcaGroup.php
new file mode 100644 (file)
index 0000000..3fe86cb
--- /dev/null
@@ -0,0 +1,87 @@
+<?php
+namespace TYPO3\CMS\Backend\Form\FormDataProvider;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+use TYPO3\CMS\Backend\Form\FormDataProviderInterface;
+use TYPO3\CMS\Core\Database\RelationHandler;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Core\Utility\PathUtility;
+
+/**
+ * Resolve databaseRow field content to the real connected rows for type=group
+ */
+class TcaGroup implements FormDataProviderInterface {
+
+       /**
+        * Initialize new row with default values from various sources
+        *
+        * @param array $result
+        * @return array
+        * @todo: Should not implode valid values with | again, container & elements should work
+        * @todo: with the array as it was done for select items
+        * @throws \UnexpectedValueException
+        */
+       public function addData(array $result) {
+               foreach ($result['vanillaTableTca']['columns'] as $fieldName => $fieldConfig) {
+                       if (empty($fieldConfig['config']['type'])
+                               || $fieldConfig['config']['type'] !== 'group'
+                               || empty($fieldConfig['config']['internal_type'])
+                       ) {
+                               continue;
+                       }
+
+                       $databaseRowFieldContent = '';
+                       if (!empty($result['databaseRow'][$fieldName])) {
+                               $databaseRowFieldContent = (string)$result['databaseRow'][$fieldName];
+                       }
+
+                       $internalType = $fieldConfig['config']['internal_type'];
+                       if ($internalType === 'file_reference' || $internalType === 'file') {
+                               $files = array();
+                               // Simple list of files
+                               $fileList = GeneralUtility::trimExplode(',', $databaseRowFieldContent, TRUE);
+                               foreach ($fileList as $file) {
+                                       if ($file) {
+                                               $files[] = rawurlencode($file) . '|' . rawurlencode(PathUtility::basename($file));
+                                       }
+                               }
+                               $result['databaseRow'][$fieldName] = implode(',', $files);
+                       } elseif ($internalType === 'db') {
+                               /** @var $relationHandler RelationHandler */
+                               $relationHandler = GeneralUtility::makeInstance(RelationHandler::class);
+                               $relationHandler->start(
+                                       $databaseRowFieldContent,
+                                       $fieldConfig['config']['allowed'],
+                                       $fieldConfig['config']['MM'],
+                                       $result['databaseRow']['uid'],
+                                       $result['tableName'],
+                                       $fieldConfig['config']
+                               );
+                               $relationHandler->getFromDB();
+                               $result['databaseRow'][$fieldName] = $relationHandler->readyForInterface();
+                       } else {
+                               // @todo: "folder" is a valid internal_type, too.
+                               throw new \UnexpectedValueException(
+                                       'TCA internal_type of field "' . $fieldName . '" in table ' . $result['tableName']
+                                       .' must be set to either "db", "file" or "file_reference"',
+                                       1438780511
+                               );
+                       }
+               }
+
+               return $result;
+       }
+
+}
diff --git a/typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/DatabaseRowGroupRelationsTest.php b/typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/DatabaseRowGroupRelationsTest.php
deleted file mode 100644 (file)
index b494a51..0000000
+++ /dev/null
@@ -1,142 +0,0 @@
-<?php
-namespace TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider;
-
-/*
- * This file is part of the TYPO3 CMS project.
- *
- * It is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License, either version 2
- * of the License, or any later version.
- *
- * For the full copyright and license information, please read the
- * LICENSE.txt file that was distributed with this source code.
- *
- * The TYPO3 project - inspiring people to share!
- */
-
-
-use Prophecy\Prophecy\ObjectProphecy;
-use TYPO3\CMS\Core\Database\RelationHandler;
-use TYPO3\CMS\Core\Tests\UnitTestCase;
-use TYPO3\CMS\Backend\Form\FormDataProvider\DatabaseRowGroupRelations;
-use TYPO3\CMS\Core\Utility\GeneralUtility;
-
-/**
- * Test case
- */
-class DatabaseRowGroupRelationsTest extends UnitTestCase {
-
-       /**
-        * @var DatabaseRowGroupRelations
-        */
-       protected $subject;
-
-       public function setUp() {
-               $this->subject = new DatabaseRowGroupRelations();
-       }
-
-       /**
-        * @test
-        */
-       public function addDataReturnsFieldUnchangedIfFieldIsNotTypeGroup() {
-               $input = [
-                       'databaseRow' => [
-                               'aField' => 'aValue',
-                       ],
-                       'vanillaTableTca' => [
-                               'columns' => [
-                                       'aField' => [
-                                               'config' => [
-                                                       'type' => 'foo',
-                                               ],
-                                       ],
-                               ],
-                       ],
-               ];
-               $expected = $input;
-               $this->assertSame($expected, $this->subject->addData($input));
-       }
-
-       /**
-        * @test
-        */
-       public function addDataThrowsExceptionWithTypeGroupAndNoValiInternalType() {
-               $input = [
-                       'vanillaTableTca' => [
-                               'columns' => [
-                                       'aField' => [
-                                               'config' => [
-                                                       'type' => 'group',
-                                                       'internal_type' => 'foo',
-                                               ],
-                                       ],
-                               ],
-                       ],
-               ];
-               $this->setExpectedException(\UnexpectedValueException::class, $this->anything(), 1438780511);
-               $this->subject->addData($input);
-       }
-
-       /**
-        * @test
-        */
-       public function addDataSetsFileData() {
-               $input = [
-                       'databaseRow' => [
-                               'aField' => '/aDir/aFile.txt,/anotherDir/anotherFile.css',
-                       ],
-                       'vanillaTableTca' => [
-                               'columns' => [
-                                       'aField' => [
-                                               'config' => [
-                                                       'type' => 'group',
-                                                       'internal_type' => 'file',
-                                               ],
-                                       ],
-                               ],
-                       ],
-               ];
-               $expected = $input;
-               $expected['databaseRow']['aField'] = '%2FaDir%2FaFile.txt|aFile.txt,%2FanotherDir%2FanotherFile.css|anotherFile.css';
-               $this->assertSame($expected, $this->subject->addData($input));
-       }
-
-       /**
-        * @test
-        */
-       public function addDataSetsDatabaseData() {
-               $aFieldConfig = [
-                       'type' => 'group',
-                       'internal_type' => 'db',
-                       'MM' => 'mmTableName',
-                       'allowed' => 'aForeignTable',
-               ];
-               $input = [
-                       'tableName' => 'aTable',
-                       'databaseRow' => [
-                               'uid' => 42,
-                               'aField' => '1,2',
-                       ],
-                       'vanillaTableTca' => [
-                               'columns' => [
-                                       'aField' => [
-                                               'config' => $aFieldConfig,
-                                       ],
-                               ],
-                       ],
-               ];
-
-               /** @var RelationHandler|ObjectProphecy $relationHandlerProphecy */
-               $relationHandlerProphecy = $this->prophesize(RelationHandler::class);
-               GeneralUtility::addInstance(RelationHandler::class, $relationHandlerProphecy->reveal());
-               $relationHandlerProphecy->start('1,2', 'aForeignTable', 'mmTableName', 42, 'aTable', $aFieldConfig)->shouldBeCalled();
-               $relationHandlerProphecy->getFromDB()->shouldBeCalled();
-               $relationHandlerProphecy->readyForInterface()->shouldBeCalled()->willReturn('1|aLabel,2|anotherLabel');
-
-               $expected = $input;
-               $expected['databaseRow']['aField'] = '1|aLabel,2|anotherLabel';
-
-               $this->assertSame($expected, $this->subject->addData($input));
-       }
-
-}
diff --git a/typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/TcaGroupTest.php b/typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/TcaGroupTest.php
new file mode 100644 (file)
index 0000000..f9f5a79
--- /dev/null
@@ -0,0 +1,142 @@
+<?php
+namespace TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+
+use Prophecy\Prophecy\ObjectProphecy;
+use TYPO3\CMS\Core\Database\RelationHandler;
+use TYPO3\CMS\Core\Tests\UnitTestCase;
+use TYPO3\CMS\Backend\Form\FormDataProvider\TcaGroup;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+
+/**
+ * Test case
+ */
+class TcaGroupTest extends UnitTestCase {
+
+       /**
+        * @var TcaGroup
+        */
+       protected $subject;
+
+       public function setUp() {
+               $this->subject = new TcaGroup();
+       }
+
+       /**
+        * @test
+        */
+       public function addDataReturnsFieldUnchangedIfFieldIsNotTypeGroup() {
+               $input = [
+                       'databaseRow' => [
+                               'aField' => 'aValue',
+                       ],
+                       'vanillaTableTca' => [
+                               'columns' => [
+                                       'aField' => [
+                                               'config' => [
+                                                       'type' => 'foo',
+                                               ],
+                                       ],
+                               ],
+                       ],
+               ];
+               $expected = $input;
+               $this->assertSame($expected, $this->subject->addData($input));
+       }
+
+       /**
+        * @test
+        */
+       public function addDataThrowsExceptionWithTypeGroupAndNoValiInternalType() {
+               $input = [
+                       'vanillaTableTca' => [
+                               'columns' => [
+                                       'aField' => [
+                                               'config' => [
+                                                       'type' => 'group',
+                                                       'internal_type' => 'foo',
+                                               ],
+                                       ],
+                               ],
+                       ],
+               ];
+               $this->setExpectedException(\UnexpectedValueException::class, $this->anything(), 1438780511);
+               $this->subject->addData($input);
+       }
+
+       /**
+        * @test
+        */
+       public function addDataSetsFileData() {
+               $input = [
+                       'databaseRow' => [
+                               'aField' => '/aDir/aFile.txt,/anotherDir/anotherFile.css',
+                       ],
+                       'vanillaTableTca' => [
+                               'columns' => [
+                                       'aField' => [
+                                               'config' => [
+                                                       'type' => 'group',
+                                                       'internal_type' => 'file',
+                                               ],
+                                       ],
+                               ],
+                       ],
+               ];
+               $expected = $input;
+               $expected['databaseRow']['aField'] = '%2FaDir%2FaFile.txt|aFile.txt,%2FanotherDir%2FanotherFile.css|anotherFile.css';
+               $this->assertSame($expected, $this->subject->addData($input));
+       }
+
+       /**
+        * @test
+        */
+       public function addDataSetsDatabaseData() {
+               $aFieldConfig = [
+                       'type' => 'group',
+                       'internal_type' => 'db',
+                       'MM' => 'mmTableName',
+                       'allowed' => 'aForeignTable',
+               ];
+               $input = [
+                       'tableName' => 'aTable',
+                       'databaseRow' => [
+                               'uid' => 42,
+                               'aField' => '1,2',
+                       ],
+                       'vanillaTableTca' => [
+                               'columns' => [
+                                       'aField' => [
+                                               'config' => $aFieldConfig,
+                                       ],
+                               ],
+                       ],
+               ];
+
+               /** @var RelationHandler|ObjectProphecy $relationHandlerProphecy */
+               $relationHandlerProphecy = $this->prophesize(RelationHandler::class);
+               GeneralUtility::addInstance(RelationHandler::class, $relationHandlerProphecy->reveal());
+               $relationHandlerProphecy->start('1,2', 'aForeignTable', 'mmTableName', 42, 'aTable', $aFieldConfig)->shouldBeCalled();
+               $relationHandlerProphecy->getFromDB()->shouldBeCalled();
+               $relationHandlerProphecy->readyForInterface()->shouldBeCalled()->willReturn('1|aLabel,2|anotherLabel');
+
+               $expected = $input;
+               $expected['databaseRow']['aField'] = '1|aLabel,2|anotherLabel';
+
+               $this->assertSame($expected, $this->subject->addData($input));
+       }
+
+}
index 43e3714..db13931 100644 (file)
@@ -348,14 +348,14 @@ return array(
                                                        \TYPO3\CMS\Backend\Form\FormDataProvider\DatabaseRowDateTimeFields::class
                                                ),
                                        ),
-                                       \TYPO3\CMS\Backend\Form\FormDataProvider\DatabaseRowGroupRelations::class => array(
+                                       \TYPO3\CMS\Backend\Form\FormDataProvider\TcaGroup::class => array(
                                                'depends' => array(
                                                        \TYPO3\CMS\Backend\Form\FormDataProvider\DatabaseRowDefaultValues::class,
                                                ),
                                        ),
                                        \TYPO3\CMS\Backend\Form\FormDataProvider\DatabaseSystemLanguageRows::class => array(
                                                'depends' => array(
-                                                       \TYPO3\CMS\Backend\Form\FormDataProvider\DatabaseRowGroupRelations::class,
+                                                       \TYPO3\CMS\Backend\Form\FormDataProvider\TcaGroup::class,
                                                ),
                                        ),
                                        \TYPO3\CMS\Backend\Form\FormDataProvider\DatabasePageLanguageOverlayRows::class => array(
@@ -450,7 +450,7 @@ return array(
                                'flexFormSegment' => array(
                                        \TYPO3\CMS\Backend\Form\FormDataProvider\DatabaseRowDefaultValues::class => array(
                                        ),
-                                       \TYPO3\CMS\Backend\Form\FormDataProvider\DatabaseRowGroupRelations::class => array(
+                                       \TYPO3\CMS\Backend\Form\FormDataProvider\TcaGroup::class => array(
                                                'depends' => array(
                                                        \TYPO3\CMS\Backend\Form\FormDataProvider\DatabaseRowDefaultValues::class,
                                                ),