Commit a6a513df authored by catch's avatar catch

Issue #2692091 by amateescu, heykarthikwithu, xjm, Berdir: Use the new 'view...

Issue #2692091 by amateescu, heykarthikwithu, xjm, Berdir: Use the new 'view label' entity access check in the entity reference label formatter
parent e05ae293
......@@ -169,9 +169,9 @@ protected function needsEntityLoad(EntityReferenceItem $item) {
/**
* Checks access to the given entity.
*
* By default, entity access is checked. However, a subclass can choose to
* exclude certain items from entity access checking by immediately granting
* access.
* By default, entity 'view' access is checked. However, a subclass can choose
* to exclude certain items from entity access checking by immediately
* granting access.
*
* @param \Drupal\Core\Entity\EntityInterface $entity
* The entity to check.
......
......@@ -2,6 +2,7 @@
namespace Drupal\Core\Field\Plugin\Field\FieldFormatter;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\Exception\UndefinedLinkTemplateException;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Form\FormStateInterface;
......@@ -100,4 +101,11 @@ public function viewElements(FieldItemListInterface $items, $langcode) {
return $elements;
}
/**
* {@inheritdoc}
*/
protected function checkAccess(EntityInterface $entity) {
return $entity->access('view label', NULL, TRUE);
}
}
......@@ -54,9 +54,7 @@ public static function isApplicable(FieldDefinitionInterface $field_definition)
* {@inheritdoc}
*/
protected function checkAccess(EntityInterface $entity) {
// Always allow an entity author's username to be read, even if the current
// user does not have permission to view the entity author's profile.
return AccessResult::allowed();
return $entity->access('view label', NULL, TRUE);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment