You are here

protected function MenuReferenceFormatter::checkAccess in Menu Reference Render (Formatter) 8.2

Checks access to the given entity.

By default, entity 'view' access is checked. However, a subclass can choose to exclude certain items from entity access checking by immediately granting access.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity to check.

Return value

\Drupal\Core\Access\AccessResult A cacheable access result.

Overrides EntityReferenceFormatterBase::checkAccess

File

src/Plugin/Field/FieldFormatter/MenuReferenceFormatter.php, line 109

Class

MenuReferenceFormatter
Plugin implementation of the 'menu_reference_render' formatter.

Namespace

Drupal\menu_reference_render\Plugin\Field\FieldFormatter

Code

protected function checkAccess(EntityInterface $entity) {

  // Set 'view label' operation for menu entity.
  // @see \Drupal\system\MenuAccessControlHandler::checkAccess().
  return $entity
    ->access('view label', NULL, TRUE);
}