From ebc0ddfe89edb23a538f779aa577b9d32dec0aad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Mu=CC=88ller?= Date: Wed, 6 Mar 2024 19:41:46 +0100 Subject: [PATCH] TASK: Remove "internal" node properties Provides a helper to access hidden status as well as renaming `_hiddenInIndex` to `hiddenInMenu`. Fixes: #4208 --- .../AbstractMenuItemsImplementation.php | 22 +++++++++---------- .../Classes/Fusion/Helper/NodeHelper.php | 1 + .../References/NeosFusionReference.rst | 12 +++++----- Neos.Neos/NodeTypes/Mixin/Document.yaml | 2 +- .../Behavior/Features/Fusion/Menu.feature | 4 ++-- 5 files changed, 21 insertions(+), 20 deletions(-) diff --git a/Neos.Neos/Classes/Fusion/AbstractMenuItemsImplementation.php b/Neos.Neos/Classes/Fusion/AbstractMenuItemsImplementation.php index 23f8055dc8a..18c0ded20f3 100644 --- a/Neos.Neos/Classes/Fusion/AbstractMenuItemsImplementation.php +++ b/Neos.Neos/Classes/Fusion/AbstractMenuItemsImplementation.php @@ -24,7 +24,7 @@ * Base class for Menu and DimensionsMenu * * Main Options: - * - renderHiddenInIndex: if TRUE, hidden-in-index nodes will be shown in the menu. FALSE by default. + * - renderHiddenInMenu: if TRUE, hidden-in-index nodes will be shown in the menu. FALSE by default. */ abstract class AbstractMenuItemsImplementation extends AbstractFusionObject { @@ -46,11 +46,11 @@ abstract class AbstractMenuItemsImplementation extends AbstractFusionObject protected $currentNode; /** - * Internal cache for the renderHiddenInIndex property. + * Internal cache for the renderHiddenInMenu property. * * @var boolean */ - protected $renderHiddenInIndex; + protected $renderHiddenInMenu; /** * Internal cache for the calculateItemStates property. @@ -76,17 +76,17 @@ public function isCalculateItemStatesEnabled(): bool } /** - * Should nodes that have "hiddenInIndex" set still be visible in this menu. + * Should nodes that have "hiddenInMenu" set still be visible in this menu. * * @return boolean */ - public function getRenderHiddenInIndex() + public function getRenderHiddenInMenu() { - if ($this->renderHiddenInIndex === null) { - $this->renderHiddenInIndex = (bool)$this->fusionValue('renderHiddenInIndex'); + if ($this->renderHiddenInMenu === null) { + $this->renderHiddenInMenu = (bool)($this->fusionValue('renderHiddenInMenu') ?? $this->fusionValue('renderHiddenInIndex')); } - return $this->renderHiddenInIndex; + return $this->renderHiddenInMenu; } /** @@ -139,7 +139,7 @@ abstract protected function buildItems(): array; /** * Return TRUE/FALSE if the node is currently hidden or not in the menu; - * taking the "renderHiddenInIndex" configuration of the Menu Fusion object into account. + * taking the "renderHiddenInMenu" configuration of the Menu Fusion object into account. * * This method needs to be called inside buildItems() in the subclasses. * @@ -148,14 +148,14 @@ abstract protected function buildItems(): array; */ protected function isNodeHidden(Node $node) { - if ($this->getRenderHiddenInIndex() === true) { + if ($this->getRenderHiddenInMenu() === true) { // Please show hiddenInIndex nodes // -> node is *never* hidden! return false; } // Node is hidden depending on the _hiddenInIndex property - return $node->getProperty('_hiddenInIndex'); + return $node->getProperty('hiddenInMenu'); } protected function buildUri(Node $node): string diff --git a/Neos.Neos/Classes/Fusion/Helper/NodeHelper.php b/Neos.Neos/Classes/Fusion/Helper/NodeHelper.php index 28de5534bb7..8bbdd02f71b 100644 --- a/Neos.Neos/Classes/Fusion/Helper/NodeHelper.php +++ b/Neos.Neos/Classes/Fusion/Helper/NodeHelper.php @@ -21,6 +21,7 @@ use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindAncestorNodesFilter; use Neos\ContentRepository\Core\Projection\ContentGraph\Node; use Neos\ContentRepository\Core\Projection\ContentGraph\NodePath; +use Neos\ContentRepository\Core\Projection\NodeHiddenState\NodeHiddenStateFinder; use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry; use Neos\Eel\ProtectedContextAwareInterface; use Neos\Flow\Annotations as Flow; diff --git a/Neos.Neos/Documentation/References/NeosFusionReference.rst b/Neos.Neos/Documentation/References/NeosFusionReference.rst index 113099e9115..1e7967244ac 100644 --- a/Neos.Neos/Documentation/References/NeosFusionReference.rst +++ b/Neos.Neos/Documentation/References/NeosFusionReference.rst @@ -927,7 +927,7 @@ The following properties are passed over to :ref:`Neos_Neos__MenuItems` internal :maximumLevels: (integer) Restrict the maximum depth of items in the menu (relative to ``entryLevel``) :startingPoint: (optional, Node) The node where the menu hierarchy starts. If not specified explicitly the startingPoint is calculated from (``node`` and ``entryLevel``), defaults to ``null`` :filter: (string) Filter items by node type (e.g. ``'!My.Site:News,Neos.Neos:Document'``), defaults to ``'Neos.Neos:Document'``. The filter is only used for fetching subItems and is ignored for determining the ``startingPoint`` -:renderHiddenInIndex: (boolean) Whether nodes with ``hiddenInIndex`` should be rendered, defaults to ``false`` +:renderHiddenInMenu: (boolean) Whether nodes with ``hiddenInIndex`` should be rendered, defaults to ``false`` :calculateItemStates: (boolean) activate the *expensive* calculation of item states defaults to ``false``. :itemCollection: (optional, array of Nodes) Explicitly set the Node items for the menu (taking precedence over ``startingPoints`` and ``entryLevel`` and ``lastLevel``). The children for each ``Node`` will be fetched taking the ``maximumLevels`` property into account. @@ -957,7 +957,7 @@ The following properties are passed over to :ref:`Neos_Neos__BreadcrumbMenuItems :node: (Node) The current node to render the menu for. Defaults to ``documentNode`` from the fusion context :maximumLevels: (integer) Restrict the maximum depth of items in the menu, defaults to ``0`` -:renderHiddenInIndex: (boolean) Whether nodes with ``hiddenInIndex`` should be rendered (the current documentNode is always included), defaults to ``false``. +:renderHiddenInMenu: (boolean) Whether nodes with ``hiddenInIndex`` should be rendered (the current documentNode is always included), defaults to ``false``. :calculateItemStates: (boolean) activate the *expensive* calculation of item states defaults to ``false`` Example:: @@ -986,7 +986,7 @@ The following fusion properties are passed over to :ref:`Neos_Neos__DimensionsMe :dimension: (optional, string): name of the dimension which this menu should be based on. Example: "language". :presets: (optional, array): If set, the presets rendered will be taken from this list of preset identifiers :includeAllPresets: (boolean, default **false**) If TRUE, include all presets, not only allowed combinations -:renderHiddenInIndex: (boolean, default **true**) If TRUE, render nodes which are marked as "hidded-in-index" +:renderHiddenInMenu: (boolean, default **true**) If TRUE, render nodes which are marked as "hidded-in-index" :calculateItemStates: (boolean) activate the *expensive* calculation of item states defaults to ``false`` .. note:: The ``items`` of the ``DimensionsMenu`` are internally calculated with the prototype :ref:`Neos_Neos__DimensionsMenuItems` which @@ -1017,7 +1017,7 @@ Create a list of menu-items items for nodes. :maximumLevels: (integer) Restrict the maximum depth of items in the menu (relative to ``entryLevel``) :startingPoint: (optional, Node) The node where the menu hierarchy starts. If not specified explicitly the startingPoint is calculated from (``node`` and ``entryLevel``), defaults to ``null`` :filter: (string) Filter items by node type (e.g. ``'!My.Site:News,Neos.Neos:Document'``), defaults to ``'Neos.Neos:Document'``. The filter is only used for fetching subItems and is ignored for determining the ``startingPoint`` -:renderHiddenInIndex: (boolean) Whether nodes with ``hiddenInIndex`` should be rendered, defaults to ``false`` +:renderHiddenInMenu: (boolean) Whether nodes with ``hiddenInIndex`` should be rendered, defaults to ``false`` :calculateItemStates: (boolean) activate the *expensive* calculation of item states defaults to ``false``. :itemCollection: (optional, array of Nodes) Explicitly set the Node items for the menu (taking precedence over ``startingPoints`` and ``entryLevel`` and ``lastLevel``). The children for each ``Node`` will be fetched taking the ``maximumLevels`` property into account. @@ -1084,7 +1084,7 @@ Create a list of of menu-items for the breadcrumb (ancestor documents). :node: (Node) The current node to render the menu for. Defaults to ``documentNode`` from the fusion context :maximumLevels: (integer) Restrict the maximum depth of items in the menu, defaults to ``0`` -:renderHiddenInIndex: (boolean) Whether nodes with ``hiddenInIndex`` should be rendered (the current documentNode is always included), defaults to ``false``. +:renderHiddenInMenu: (boolean) Whether nodes with ``hiddenInIndex`` should be rendered (the current documentNode is always included), defaults to ``false``. :calculateItemStates: (boolean) activate the *expensive* calculation of item states defaults to ``false`` Example:: @@ -1107,7 +1107,7 @@ If no node variant exists for the preset combination, a ``NULL`` node will be in :dimension: (optional, string): name of the dimension which this menu should be based on. Example: "language". :presets: (optional, array): If set, the presets rendered will be taken from this list of preset identifiers :includeAllPresets: (boolean, default **false**) If TRUE, include all presets, not only allowed combinations -:renderHiddenInIndex: (boolean, default **true**) If TRUE, render nodes which are marked as "hidded-in-index" +:renderHiddenInMenu: (boolean, default **true**) If TRUE, render nodes which are marked as "hidded-in-index" :calculateItemStates: (boolean) activate the *expensive* calculation of item states defaults to ``false`` Each ``item`` has the following properties: diff --git a/Neos.Neos/NodeTypes/Mixin/Document.yaml b/Neos.Neos/NodeTypes/Mixin/Document.yaml index 6fdfbaf2eda..c3277bf4344 100644 --- a/Neos.Neos/NodeTypes/Mixin/Document.yaml +++ b/Neos.Neos/NodeTypes/Mixin/Document.yaml @@ -59,7 +59,7 @@ _hidden: ui: reloadPageIfChanged: true - _hiddenInIndex: + hiddenInMenu: type: boolean ui: label: i18n diff --git a/Neos.Neos/Tests/Behavior/Features/Fusion/Menu.feature b/Neos.Neos/Tests/Behavior/Features/Fusion/Menu.feature index d137b1b77ec..73cbcbec51c 100644 --- a/Neos.Neos/Tests/Behavior/Features/Fusion/Menu.feature +++ b/Neos.Neos/Tests/Behavior/Features/Fusion/Menu.feature @@ -15,7 +15,7 @@ Feature: Tests for the "Neos.Neos:Menu" and related Fusion prototypes type: string uriPathSegment: type: string - _hiddenInIndex: + hiddenInIndex: type: bool 'Neos.Neos:Site': superTypes: @@ -63,7 +63,7 @@ Feature: Tests for the "Neos.Neos:Menu" and related Fusion prototypes | a1b1b | a1b1 | Neos.Neos:Test.DocumentType1 | {"uriPathSegment": "a1b1b", "title": "Node a1b1b"} | a1b1b | | a1b2 | a1b | Neos.Neos:Test.DocumentType2 | {"uriPathSegment": "a1b2", "title": "Node a1b2"} | a1b2 | | a1b3 | a1b | Neos.Neos:Test.DocumentType1 | {"uriPathSegment": "a1b3", "title": "Node a1b3"} | a1b3 | - | a1c | a1 | Neos.Neos:Test.DocumentType1 | {"uriPathSegment": "a1c", "title": "Node a1c", "_hiddenInIndex": true} | a1c | + | a1c | a1 | Neos.Neos:Test.DocumentType1 | {"uriPathSegment": "a1c", "title": "Node a1c", "hiddenInIndex": true} | a1c | | a1c1 | a1c | Neos.Neos:Test.DocumentType1 | {"uriPathSegment": "a1c1", "title": "Node a1c1"} | a1c1 | And A site exists for node name "a" and domain "http://localhost" And the sites configuration is: