Skip to content

Commit 0fe61f6

Browse files
author
Simeon Kesmev
committed
Fix inaccessible menu links returned by data producers drupal-graphql#1204
1 parent 92d3ec4 commit 0fe61f6

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/Plugin/GraphQL/DataProducer/Menu/MenuLinks.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,9 @@ public function resolve(MenuInterface $menu) {
9191
];
9292

9393
return array_filter($this->menuLinkTree->transform($tree, $manipulators), function (MenuLinkTreeElement $item) {
94-
return $item->link instanceof MenuLinkInterface && $item->link->isEnabled();
94+
return $item->link instanceof MenuLinkInterface
95+
&& $item->link->isEnabled()
96+
&& (!isset($item->access) || $item->access->isAllowed());
9597
});
9698
}
9799

src/Plugin/GraphQL/DataProducer/Menu/MenuTree/MenuTreeSubtree.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class MenuTreeSubtree extends DataProducerPluginBase {
3636
*/
3737
public function resolve(MenuLinkTreeElement $element) {
3838
return array_filter($element->subtree, function (MenuLinkTreeElement $item) {
39-
return $item->link->isEnabled();
39+
return $item->link->isEnabled() && (!isset($item->access) || $item->access->isAllowed());
4040
});
4141
}
4242

0 commit comments

Comments
 (0)