Skip to content

Commit

Permalink
TASK: Make NodeAggregateIds countable
Browse files Browse the repository at this point in the history
  • Loading branch information
mhsdesign committed Sep 24, 2024
1 parent 970f207 commit 7331e40
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

namespace Neos\ContentRepository\Core\SharedModel\Node;

use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
use Neos\ContentRepository\Core\Projection\ContentGraph\Nodes;

/**
Expand All @@ -23,7 +22,7 @@
* @implements \IteratorAggregate<string,NodeAggregateId>
* @api
*/
final class NodeAggregateIds implements \IteratorAggregate, \JsonSerializable
final class NodeAggregateIds implements \IteratorAggregate, \Countable, \JsonSerializable
{
/**
* @var array<string,NodeAggregateId>
Expand Down Expand Up @@ -124,4 +123,9 @@ public function map(\Closure $callback): array
{
return array_map($callback, $this->nodeAggregateIds);
}

public function count(): int
{
return count($this->nodeAggregateIds);
}
}
2 changes: 1 addition & 1 deletion Neos.Neos/Classes/Fusion/MenuItemsImplementation.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ protected function buildItems(): array
$maximumLevels = min($maximumLevels, $maxLevelsBasedOnLastLevel);
} elseif ($lastLevels < 0) {
$currentNodeAncestorAggregateIds = $this->getCurrentNodeRootlineAggregateIds();
$depthOfCurrentDocument = count(iterator_to_array($currentNodeAncestorAggregateIds)) - 1;
$depthOfCurrentDocument = count($currentNodeAncestorAggregateIds) - 1;
$maxLevelsBasedOnLastLevel = max($depthOfCurrentDocument + $lastLevels - $depthOfEntryParentNodeAggregateId + 1, 0);
$maximumLevels = min($maximumLevels, $maxLevelsBasedOnLastLevel);
}
Expand Down

0 comments on commit 7331e40

Please sign in to comment.