You are here

protected function AuthorFormatter::checkAccess in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/user/src/Plugin/Field/FieldFormatter/AuthorFormatter.php \Drupal\user\Plugin\Field\FieldFormatter\AuthorFormatter::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/modules/user/src/Plugin/Field/FieldFormatter/AuthorFormatter.php, line 54

Class

AuthorFormatter
Plugin implementation of the 'author' formatter.

Namespace

Drupal\user\Plugin\Field\FieldFormatter

Code

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