Skip to content

Commit

Permalink
TASK: Remove "internal" node properties
Browse files Browse the repository at this point in the history
Provides a helper to access hidden status as well as renaming
`_hiddenInIndex` to `hiddenInMenu`.

Fixes: neos#4208
  • Loading branch information
kitsunet authored and mhsdesign committed Apr 26, 2024
1 parent dab3d0b commit ebc0ddf
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 20 deletions.
22 changes: 11 additions & 11 deletions Neos.Neos/Classes/Fusion/AbstractMenuItemsImplementation.php
Expand Up @@ -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
{
Expand All @@ -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.
Expand All @@ -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;
}

/**
Expand Down Expand Up @@ -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.
*
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions Neos.Neos/Classes/Fusion/Helper/NodeHelper.php
Expand Up @@ -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;
Expand Down
12 changes: 6 additions & 6 deletions Neos.Neos/Documentation/References/NeosFusionReference.rst
Expand Up @@ -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.

Expand Down Expand Up @@ -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::
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.

Expand Down Expand Up @@ -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::
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion Neos.Neos/NodeTypes/Mixin/Document.yaml
Expand Up @@ -59,7 +59,7 @@
_hidden:
ui:
reloadPageIfChanged: true
_hiddenInIndex:
hiddenInMenu:
type: boolean
ui:
label: i18n
Expand Down
4 changes: 2 additions & 2 deletions Neos.Neos/Tests/Behavior/Features/Fusion/Menu.feature
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit ebc0ddf

Please sign in to comment.