Skip to content

Commit

Permalink
fix(dataproducer): Fix entity label handling
Browse files Browse the repository at this point in the history
  • Loading branch information
klausi committed Nov 8, 2023
1 parent 3aaa111 commit 712bd73
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,13 @@ class EntityLabel extends FieldPluginBase {
*/
public function resolveValues($value, array $args, ResolveContext $context, ResolveInfo $info) {
if ($value instanceof EntityInterface) {
yield $value->label();
/** @var \Drupal\Core\Access\AccessResultInterface $accessResult */
$accessResult = $value->access('view label', NULL, TRUE);
$context->addCacheableDependency($accessResult);
if ($accessResult->isAllowed()) {
yield $value->label();
}
yield NULL;
}
}

Expand Down

0 comments on commit 712bd73

Please sign in to comment.