Skip to content

Commit

Permalink
Fix inaccessible menu links returned by data producers drupal-graphql…
Browse files Browse the repository at this point in the history
  • Loading branch information
Simeon Kesmev committed Sep 2, 2021
1 parent 92d3ec4 commit 0fe61f6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/Plugin/GraphQL/DataProducer/Menu/MenuLinks.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ public function resolve(MenuInterface $menu) {
];

return array_filter($this->menuLinkTree->transform($tree, $manipulators), function (MenuLinkTreeElement $item) {
return $item->link instanceof MenuLinkInterface && $item->link->isEnabled();
return $item->link instanceof MenuLinkInterface
&& $item->link->isEnabled()
&& (!isset($item->access) || $item->access->isAllowed());
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class MenuTreeSubtree extends DataProducerPluginBase {
*/
public function resolve(MenuLinkTreeElement $element) {
return array_filter($element->subtree, function (MenuLinkTreeElement $item) {
return $item->link->isEnabled();
return $item->link->isEnabled() && (!isset($item->access) || $item->access->isAllowed());
});
}

Expand Down

0 comments on commit 0fe61f6

Please sign in to comment.