You are here

class GroupMenuAccess in Group Menu 8

Checks access for displaying menu pages.

Hierarchy

Expanded class hierarchy of GroupMenuAccess

File

src/Access/GroupMenuAccess.php, line 14

Namespace

Drupal\groupmenu\Access
View source
class GroupMenuAccess implements GroupMenuAccessInterface {

  /**
   * {@inheritdoc}
   */
  public function menuEditAccess(AccountInterface $account, MenuInterface $menu) {
    return \Drupal::service('groupmenu.menu')
      ->menuAccess('update', $menu, $account);
  }

  /**
   * {@inheritdoc}
   */
  public function menuDeleteAccess(AccountInterface $account, MenuInterface $menu) {
    return \Drupal::service('groupmenu.menu')
      ->menuAccess('delete', $menu, $account);
  }

  /**
   * {@inheritdoc}
   */
  public function menuItemAccess(AccountInterface $account, MenuLinkContentInterface $menu_link_content = NULL) {
    $menus = \Drupal::service('groupmenu.menu')
      ->loadUserGroupMenus('edit', $account);
    if ($account
      ->hasPermission('administer menu') || !empty($menus)) {
      return AccessResult::allowed();
    }
    return AccessResult::neutral();
  }

  /**
   * {@inheritdoc}
   */
  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();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
GroupMenuAccess::menuDeleteAccess public function A custom access check for menu delete page. Overrides GroupMenuAccessInterface::menuDeleteAccess
GroupMenuAccess::menuEditAccess public function A custom access check for menu page and add link page. Overrides GroupMenuAccessInterface::menuEditAccess
GroupMenuAccess::menuItemAccess public function A custom access check for menu items page. Overrides GroupMenuAccessInterface::menuItemAccess
GroupMenuAccess::menuLinkAccess public function A custom access check for menu link page. Overrides GroupMenuAccessInterface::menuLinkAccess