You are here

public function GroupMenuAccess::menuLinkAccess in Group Menu 8

A custom access check for menu link page.

Parameters

\Drupal\Core\Session\AccountInterface $account: Run access checks for this account.

\Drupal\Core\Menu\MenuLinkInterface $menu_link_plugin: Run access checks for this menu link object.

Return value

\Drupal\Core\Access\AccessResult The access result.

Overrides GroupMenuAccessInterface::menuLinkAccess

File

src/Access/GroupMenuAccess.php, line 44

Class

GroupMenuAccess
Checks access for displaying menu pages.

Namespace

Drupal\groupmenu\Access

Code

public function menuLinkAccess(AccountInterface $account, MenuLinkInterface $menu_link_plugin = NULL) {
  $menus = \Drupal::service('groupmenu.menu')
    ->loadUserGroupMenus('edit', $account);
  if ($account
    ->hasPermission('administer menu') || !empty($menus)) {
    return AccessResult::allowed();
  }
  return AccessResult::neutral();
}