|
@@ -23,12 +23,20 @@ class FrontMenuTreeResolver implements QueryCollectionResolverInterface
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Recursively build the menu tree from a flat collection.
|
|
* Recursively build the menu tree from a flat collection.
|
|
|
|
|
+ *
|
|
|
|
|
+ * Only enabled (status = 1) items are kept at every level, so a disabled
|
|
|
|
|
+ * item is excluded whether it is a root node or a nested child.
|
|
|
*/
|
|
*/
|
|
|
protected function buildTree($items, ?int $parentId = null): array
|
|
protected function buildTree($items, ?int $parentId = null): array
|
|
|
{
|
|
{
|
|
|
$tree = [];
|
|
$tree = [];
|
|
|
|
|
|
|
|
foreach ($items as $item) {
|
|
foreach ($items as $item) {
|
|
|
|
|
+ // Exclude disabled items at every level.
|
|
|
|
|
+ if (! $item->status) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
$itemParentId = $item->parent_id === null ? null : (int) $item->parent_id;
|
|
$itemParentId = $item->parent_id === null ? null : (int) $item->parent_id;
|
|
|
|
|
|
|
|
if ($itemParentId === $parentId) {
|
|
if ($itemParentId === $parentId) {
|