// Keys may contain table names, so a numeric array is created
$fieldConfig['config']['items'] = array_values($fieldConfig['config']['items']);
+ // A couple of tree specific config parameters can be overwritten via page TS.
+ // Pick those that influence the data fetching and write them into the config
+ // given to the tree data provider
+ if (isset($result['pageTsConfig']['TCEFORM.'][$table . '.'][$fieldName . '.']['config.']['treeConfig.'])) {
+ $pageTsConfig = $result['pageTsConfig']['TCEFORM.'][$table . '.'][$fieldName . '.']['config.']['treeConfig.'];
+ // If rootUid is set in pageTsConfig, use it
+ if (isset($pageTsConfig['rootUid'])) {
+ $fieldConfig['config']['treeConfig']['rootUid'] = (int)$pageTsConfig['rootUid'];
+ }
+ if (isset($pageTsConfig['appearance.']['expandAll'])) {
+ $fieldConfig['config']['treeConfig']['appearance']['expandAll'] = (bool)$pageTsConfig['appearance.']['expandAll'];
+ }
+ if (isset($pageTsConfig['appearance.']['maxLevels'])) {
+ $fieldConfig['config']['treeConfig']['appearance']['maxLevels'] = (int)$pageTsConfig['appearance.']['maxLevels'];
+ }
+ if (isset($pageTsConfig['appearance.']['nonSelectableLevels'])) {
+ $fieldConfig['config']['treeConfig']['appearance']['nonSelectableLevels'] = $pageTsConfig['appearance.']['nonSelectableLevels'];
+ }
+ }
+
$fieldConfig['config']['treeData'] = $this->renderTree($result, $fieldConfig, $fieldName, $staticItems);
$result['processedTca']['columns'][$fieldName] = $fieldConfig;
];
$this->assertEquals($expected, $this->subject->addData($input));
}
+
+ /**
+ * @test
+ */
+ public function addDataHandsPageTsConfigSettingsOverToTableConfigurationTree()
+ {
+ $GLOBALS['TCA']['foreignTable'] = [];
+
+ /** @var DatabaseConnection|ObjectProphecy $database */
+ $database = $this->prophesize(DatabaseConnection::class);
+ $GLOBALS['TYPO3_DB'] = $database->reveal();
+
+ /** @var BackendUserAuthentication|ObjectProphecy $backendUserProphecy */
+ $backendUserProphecy = $this->prophesize(BackendUserAuthentication::class);
+ $GLOBALS['BE_USER'] = $backendUserProphecy->reveal();
+
+ /** @var DatabaseTreeDataProvider|ObjectProphecy $treeDataProviderProphecy */
+ $treeDataProviderProphecy = $this->prophesize(DatabaseTreeDataProvider::class);
+ GeneralUtility::addInstance(DatabaseTreeDataProvider::class, $treeDataProviderProphecy->reveal());
+
+ /** @var TableConfigurationTree|ObjectProphecy $treeDataProviderProphecy */
+ $tableConfigurationTreeProphecy = $this->prophesize(TableConfigurationTree::class);
+ GeneralUtility::addInstance(TableConfigurationTree::class, $tableConfigurationTreeProphecy->reveal());
+
+ $input = [
+ 'tableName' => 'aTable',
+ 'databaseRow' => [
+ 'aField' => '1'
+ ],
+ 'processedTca' => [
+ 'columns' => [
+ 'aField' => [
+ 'config' => [
+ 'type' => 'select',
+ 'renderType' => 'selectTree',
+ 'treeConfig' => [
+ 'childrenField' => 'childrenField'
+ ],
+ 'foreign_table' => 'foreignTable',
+ 'items' => [],
+ 'maxitems' => 1
+ ],
+ ],
+ ],
+ ],
+ 'pageTsConfig' => [
+ 'TCEFORM.' => [
+ 'aTable.' => [
+ 'aField.' => [
+ 'config.' => [
+ 'treeConfig.' => [
+ 'rootUid' => '42',
+ 'appearance.' => [
+ 'expandAll' => 1,
+ 'maxLevels' => 4,
+ 'nonSelectableLevels' => '0,1',
+ ],
+ ],
+ ],
+ ],
+ ],
+ ],
+ ],
+ ];
+
+ $this->subject->addData($input);
+
+ $treeDataProviderProphecy->setRootUid(42)->shouldHaveBeenCalled();
+ $treeDataProviderProphecy->setExpandAll(true)->shouldHaveBeenCalled();
+ $treeDataProviderProphecy->setLevelMaximum(4)->shouldHaveBeenCalled();
+ $treeDataProviderProphecy->setNonSelectableLevelList('0,1')->shouldHaveBeenCalled();
+ }
}