public function MenuLinks::resolve in GraphQL 8.4
Resolver.
Parameters
\Drupal\system\MenuInterface $menu:
Return value
array
File
- src/
Plugin/ GraphQL/ DataProducer/ Menu/ MenuLinks.php, line 85
Class
- MenuLinks
- Return the menu links of a menu.
Namespace
Drupal\graphql\Plugin\GraphQL\DataProducer\MenuCode
public function resolve(MenuInterface $menu) {
$tree = $this->menuLinkTree
->load($menu
->id(), new MenuTreeParameters());
$manipulators = [
[
'callable' => 'menu.default_tree_manipulators:checkAccess',
],
[
'callable' => 'menu.default_tree_manipulators:generateIndexAndSort',
],
];
return array_filter($this->menuLinkTree
->transform($tree, $manipulators), function (MenuLinkTreeElement $item) {
return $item->link instanceof MenuLinkInterface && $item->link
->isEnabled();
});
}