You are here

protected function EntityReferenceLabelFormatter::checkAccess in Drupal 8

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceLabelFormatter.php \Drupal\Core\Field\Plugin\Field\FieldFormatter\EntityReferenceLabelFormatter::checkAccess()
  2. 10 core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceLabelFormatter.php \Drupal\Core\Field\Plugin\Field\FieldFormatter\EntityReferenceLabelFormatter::checkAccess()

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

core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceLabelFormatter.php, line 107

Class

EntityReferenceLabelFormatter
Plugin implementation of the 'entity reference label' formatter.

Namespace

Drupal\Core\Field\Plugin\Field\FieldFormatter

Code

protected function checkAccess(EntityInterface $entity) {
  return $entity
    ->access('view label', NULL, TRUE);
}