Commit 5e2c6848 authored by Oliver Bartsch's avatar Oliver Bartsch
Browse files

[FOLLOWUP] Rename "entryPoints" to "elementBrowserEntryPoints"

Resolves: #91077
Releases: main
Change-Id: Iac0b8433a77ef4d6f6f0d1734e84c6a35f6addb4
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/73008

Reviewed-by: Mathias Brodala's avatarMathias Brodala <mbrodala@pagemachine.de>
Reviewed-by: Nikita Hovratov's avatarNikita Hovratov <nikita.h@live.de>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Jochen's avatarJochen <rothjochen@gmail.com>
Reviewed-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: Jochen's avatarJochen <rothjochen@gmail.com>
Tested-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
parent 3e48a344
......@@ -101,13 +101,13 @@ class ElementBrowser extends AbstractNode
*/
protected function addEntryPoint(string $table, string $fieldName, array $fieldConfig, array $linkAttributes): array
{
if (!isset($fieldConfig['entryPoints']) || !is_array($fieldConfig['entryPoints'])) {
if (!isset($fieldConfig['elementBrowserEntryPoints']) || !is_array($fieldConfig['elementBrowserEntryPoints'])) {
// Early return in case no entry points are defined
return $linkAttributes;
}
// Fetch the configured default entry point (which might be a marker)
$entryPoint = (string)($fieldConfig['entryPoints']['_default'] ?? '');
$entryPoint = (string)($fieldConfig['elementBrowserEntryPoints']['_default'] ?? '');
// In case no default entry point is given, check if we deal with type=db and only one allowed table
if ($entryPoint === '') {
......@@ -117,9 +117,9 @@ class ElementBrowser extends AbstractNode
}
// Check for the allowed tables, if only one table is allowed check if an entry point is defined for it
$allowed = GeneralUtility::trimExplode(',', $fieldConfig['allowed'] ?? '', true);
if (count($allowed) === 1 && isset($fieldConfig['entryPoints'][$allowed[0]])) {
if (count($allowed) === 1 && isset($fieldConfig['elementBrowserEntryPoints'][$allowed[0]])) {
// Use the entry point for the single table as default
$entryPoint = (string)$fieldConfig['entryPoints'][$allowed[0]];
$entryPoint = (string)$fieldConfig['elementBrowserEntryPoints'][$allowed[0]];
}
if ($entryPoint === '') {
// Return if still empty
......
......@@ -101,13 +101,13 @@ class TableList extends AbstractNode
*/
protected function addEntryPoint(string $tableName, array $fieldConfig, array $attributes): array
{
if (!isset($fieldConfig['entryPoints']) || !is_array($fieldConfig['entryPoints'])) {
if (!isset($fieldConfig['elementBrowserEntryPoints']) || !is_array($fieldConfig['elementBrowserEntryPoints'])) {
// Early return in case no entry points are defined
return $attributes;
}
// Fetch the configured value (which might be a marker) - falls back to _default
$entryPoint = (string)($fieldConfig['entryPoints'][$tableName] ?? $fieldConfig['entryPoints']['_default'] ?? '');
$entryPoint = (string)($fieldConfig['elementBrowserEntryPoints'][$tableName] ?? $fieldConfig['elementBrowserEntryPoints']['_default'] ?? '');
if ($entryPoint === '') {
// In case no entry point exists for the given table and also no default is defined, return
......
......@@ -48,7 +48,7 @@ class FormEngineUtility
'check' => ['cols', 'readOnly'],
'select' => ['size', 'autoSizeMax', 'maxitems', 'minitems', 'readOnly', 'treeConfig', 'fileFolderConfig'],
'category' => ['size', 'maxitems', 'minitems', 'readOnly', 'treeConfig'],
'group' => ['size', 'autoSizeMax', 'max_size', 'maxitems', 'minitems', 'readOnly', 'entryPoints'],
'group' => ['size', 'autoSizeMax', 'max_size', 'maxitems', 'minitems', 'readOnly', 'elementBrowserEntryPoints'],
'inline' => ['appearance', 'behaviour', 'foreign_label', 'foreign_selector', 'foreign_unique', 'maxitems', 'minitems', 'size', 'autoSizeMax', 'symmetric_label', 'readOnly'],
'imageManipulation' => ['ratios', 'cropVariants'],
];
......
......@@ -108,7 +108,7 @@ class ElementBrowserTest extends UnitTestCase
yield 'Wildcard' => [
[
'allowed' => '*',
'entryPoints' => [
'elementBrowserEntryPoints' => [
'_default' => 123,
],
],
......@@ -117,7 +117,7 @@ class ElementBrowserTest extends UnitTestCase
yield 'One table' => [
[
'allowed' => 'pages',
'entryPoints' => [
'elementBrowserEntryPoints' => [
'pages' => 123,
],
],
......@@ -126,7 +126,7 @@ class ElementBrowserTest extends UnitTestCase
yield 'One table with default' => [
[
'allowed' => 'pages',
'entryPoints' => [
'elementBrowserEntryPoints' => [
'_default' => 123,
],
],
......@@ -135,7 +135,7 @@ class ElementBrowserTest extends UnitTestCase
yield 'One table with default and table definition' => [
[
'allowed' => 'pages',
'entryPoints' => [
'elementBrowserEntryPoints' => [
'_default' => 123,
'pages' => 124,
],
......@@ -145,7 +145,7 @@ class ElementBrowserTest extends UnitTestCase
yield 'One table with invalid configuration' => [
[
'allowed' => 'pages',
'entryPoints' => [
'elementBrowserEntryPoints' => [
'some_table' => 123,
],
],
......@@ -154,7 +154,7 @@ class ElementBrowserTest extends UnitTestCase
yield 'Two tables without _defualt' => [
[
'allowed' => 'pages,some_table',
'entryPoints' => [
'elementBrowserEntryPoints' => [
'pages' => 123,
'some_table' => 124,
],
......@@ -164,7 +164,7 @@ class ElementBrowserTest extends UnitTestCase
yield 'Two tables with _defualt' => [
[
'allowed' => 'pages,some_table',
'entryPoints' => [
'elementBrowserEntryPoints' => [
'_default' => 123,
'pages' => 124,
'some_table' => 125,
......@@ -175,7 +175,7 @@ class ElementBrowserTest extends UnitTestCase
yield 'Folder' => [
[
'internal_type' => 'folder',
'entryPoints' => [
'elementBrowserEntryPoints' => [
'_default' => '1:/storage/',
],
],
......@@ -184,7 +184,7 @@ class ElementBrowserTest extends UnitTestCase
yield 'Folder without mandatory _default' => [
[
'internal_type' => 'folder',
'entryPoints' => [
'elementBrowserEntryPoints' => [
'file' => 123,
],
],
......@@ -193,7 +193,7 @@ class ElementBrowserTest extends UnitTestCase
yield 'Entry point is escaped' => [
[
'internal_type' => 'folder',
'entryPoints' => [
'elementBrowserEntryPoints' => [
'_default' => '1:/<script>alert(1)</script>/',
],
],
......@@ -202,7 +202,7 @@ class ElementBrowserTest extends UnitTestCase
yield 'Pid placeholder is resolved' => [
[
'allowed' => '*',
'entryPoints' => [
'elementBrowserEntryPoints' => [
'_default' => '###CURRENT_PID###',
],
],
......@@ -211,7 +211,7 @@ class ElementBrowserTest extends UnitTestCase
yield 'Site placeholder is resolved' => [
[
'allowed' => '*',
'entryPoints' => [
'elementBrowserEntryPoints' => [
'_default' => '###SITEROOT###',
],
],
......
......@@ -81,7 +81,7 @@ class TableListTest extends UnitTestCase
yield 'Wildcard' => [
[
'allowed' => '*',
'entryPoints' => [
'elementBrowserEntryPoints' => [
'_default' => 123,
],
],
......@@ -90,7 +90,7 @@ class TableListTest extends UnitTestCase
yield 'One table' => [
[
'allowed' => 'pages',
'entryPoints' => [
'elementBrowserEntryPoints' => [
'pages' => 123,
],
],
......@@ -101,7 +101,7 @@ class TableListTest extends UnitTestCase
yield 'One table with default' => [
[
'allowed' => 'pages',
'entryPoints' => [
'elementBrowserEntryPoints' => [
'_default' => 123,
],
],
......@@ -112,7 +112,7 @@ class TableListTest extends UnitTestCase
yield 'One table with default and table definition' => [
[
'allowed' => 'pages',
'entryPoints' => [
'elementBrowserEntryPoints' => [
'_default' => 123,
'pages' => 124,
],
......@@ -124,7 +124,7 @@ class TableListTest extends UnitTestCase
yield 'One table with invalid configuration' => [
[
'allowed' => 'pages',
'entryPoints' => [
'elementBrowserEntryPoints' => [
'some_table' => 123,
],
],
......@@ -139,7 +139,7 @@ class TableListTest extends UnitTestCase
yield 'Two tables without _default' => [
[
'allowed' => 'pages,some_table',
'entryPoints' => [
'elementBrowserEntryPoints' => [
'pages' => 123,
'some_table' => 124,
],
......@@ -152,7 +152,7 @@ class TableListTest extends UnitTestCase
yield 'Two tables with just _default' => [
[
'allowed' => 'pages,some_table',
'entryPoints' => [
'elementBrowserEntryPoints' => [
'_default' => 123,
],
],
......@@ -164,7 +164,7 @@ class TableListTest extends UnitTestCase
yield 'Two tables with _default' => [
[
'allowed' => 'pages,some_table',
'entryPoints' => [
'elementBrowserEntryPoints' => [
'_default' => 123,
'pages' => 124,
'some_table' => 125,
......@@ -178,7 +178,7 @@ class TableListTest extends UnitTestCase
yield 'Entry point is escaped' => [
[
'allowed' => 'pages',
'entryPoints' => [
'elementBrowserEntryPoints' => [
'pages' => '<script>alert(1)</script>',
],
], [
......@@ -188,7 +188,7 @@ class TableListTest extends UnitTestCase
yield 'Pid placeholder is resolved' => [
[
'allowed' => 'pages',
'entryPoints' => [
'elementBrowserEntryPoints' => [
'_default' => '###CURRENT_PID###',
],
],
......@@ -199,7 +199,7 @@ class TableListTest extends UnitTestCase
yield 'Site placeholder is resolved' => [
[
'allowed' => 'pages',
'entryPoints' => [
'elementBrowserEntryPoints' => [
'_default' => '###SITEROOT###',
],
],
......
.. include:: ../../Includes.txt
==============================================================
Feature: #91077 - Default entry points for TCA type "group"
==============================================================
===================================================================
Feature: #91077 - Element browser entry points for TCA type "group"
===================================================================
See :issue:`91077`
......@@ -24,18 +24,18 @@ for this particular page, which might take some time, especially in
systems with large page trees.
This situation has now been improved by introducing a new TCA field
configuration `entryPoints` for the TCA type "group". It's a PHP
:php:`array`, containing table and page id pairs. When opening the
element browser for a specific table (buttons below the group field),
the defined page or folder is then always selected by default. There
is also the special `_default` key, used for the general element browser
button (on the right side of the group field), which is not dedicated
to a specific table.
configuration `elementBrowserEntryPoints` for the TCA type "group".
It's a PHP :php:`array`, containing `table => id` pairs. When
opening the element browser for a specific table (buttons below the
group field), the defined page or folder is then always selected by
default. There is also the special `_default` key, used for the
general element browser button (on the right side of the group field),
which is not dedicated to a specific table.
Making this even more useful, the new configuration also supports the known
markers `###SITEROOT###`, `###CURRENT_PID###` and `###PAGE_TSCONFIG_<key>###`.
Additionally, the configuration is also added to FormEngine's "allowOverrideMatrix".
This means, each "table <=> id" pair can be overridden via page TSconfig.
This means, each `table => id` pair can be overridden via page TSconfig.
Let's see a simple example for a group field with one allowed table:
......@@ -46,7 +46,7 @@ Let's see a simple example for a group field with one allowed table:
'config' => [
'type' => 'group',
'allowed' => 'tt_content',
'entryPoints' => [
'elementBrowserEntryPoints' => [
'tt_content' => 123,
]
]
......@@ -56,7 +56,7 @@ This could then be overridden via page TSconfig:
.. code-block:: typoscript
TCEFORM.my_table.simple_group.config.entryPoints.tt_content = 321
TCEFORM.my_table.simple_group.config.elementBrowserEntryPoints.tt_content = 321
Since only one table is allowed, the defined entry point is also automatically
used for the general element browser button. In case the group field allows
......@@ -70,7 +70,7 @@ to be set:
'config' => [
'type' => 'group',
'allowed' => 'tt_content,tx_news_domain_model_news',
'entryPoints' => [
'elementBrowserEntryPoints' => [
'_default' => '###CURRENT_PID###' // E.g. use a special marker
'tt_content' => 123,
'tx_news_domain_model_news' => 124,
......@@ -82,9 +82,9 @@ Of course, the `_default` key can also be overridden via page TSconfig:
.. code-block:: typoscript
TCEFORM.my_table.extended_group.config.entryPoints._default = 122
TCEFORM.my_table.extended_group.config.elementBrowserEntryPoints._default = 122
For `interna_type=folder` one can also define a entry point with the `_default` key:
For `internal_type=folder` one can also define a entry point with the `_default` key:
.. code-block:: php
......@@ -93,7 +93,7 @@ For `interna_type=folder` one can also define a entry point with the `_default`
'config' => [
'type' => 'group',
'internal_type' => 'folder',
'entryPoints' => [
'elementBrowserEntryPoints' => [
'_default' => '1:/styleguide/'
]
]
......@@ -108,7 +108,7 @@ It's also possible to use a special TSconfig key:
'config' => [
'type' => 'group',
'internal_type' => 'folder',
'entryPoints' => [
'elementBrowserEntryPoints' => [
'_default' => '###PAGE_TSCONFIG_ID###'
]
]
......@@ -121,8 +121,8 @@ This key has then to be defined on field level:
TCEFORM.my_table.folder_group.PAGE_TSCONFIG_ID = 1:/styleguide/subfolder
In case an allowed table has no entry point defined, the `_default` is used.
In case `_default` is also not set or `entryPoints` is not used at all,
the previous behaviour applies.
In case `_default` is also not set or `elementBrowserEntryPoints` is not
used at all, the previous behaviour applies.
Impact
======
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment