You are here

protected function GeneralUserReferenceFormatter::checkAccess in Formatter Suite 8

Returns TRUE for all users if the display style is strictly a user ID. Otherwise returns TRUE only if the user has "view label" access to the target entity.

Overrides EntityReferenceFormatterBase::checkAccess

File

src/Plugin/Field/FieldFormatter/GeneralUserReferenceFormatter.php, line 715

Class

GeneralUserReferenceFormatter
Formats a user entity reference as one or more links.

Namespace

Drupal\formatter_suite\Plugin\Field\FieldFormatter

Code

protected function checkAccess(EntityInterface $entity) {
  switch ($this
    ->getSetting('userReferenceStyle')) {
    case 'id':
      return AccessResult::allowed();
    default:

      // Make sure we have access to the title.
      return $entity
        ->access('view label', NULL, TRUE);
  }
}