You are here

public function MenuLinkItemList::defaultAccess in Menu Link (Field) 8

Same name and namespace in other branches
  1. 2.0.x src/Plugin/Field/MenuLinkItemList.php \Drupal\menu_link\Plugin\Field\MenuLinkItemList::defaultAccess()

Contains the default access logic of this field.

See \Drupal\Core\Entity\EntityAccessControlHandlerInterface::fieldAccess() for the parameter documentation.

Return value

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

Overrides FieldItemList::defaultAccess

File

src/Plugin/Field/MenuLinkItemList.php, line 25

Class

MenuLinkItemList
Defines a custom menu link item list for better access checking.

Namespace

Drupal\menu_link\Plugin\Field

Code

public function defaultAccess($operation = 'view', AccountInterface $account = NULL) {
  if ($operation === 'edit') {
    return AccessResult::allowedIfHasPermission($account, 'administer menu');
  }
  return parent::defaultAccess($operation, $account);
}