function quickedit_entity_view_alter in Drupal 9
Same name and namespace in other branches
- 8 core/modules/quickedit/quickedit.module \quickedit_entity_view_alter()
- 10 core/modules/quickedit/quickedit.module \quickedit_entity_view_alter()
Implements hook_entity_view_alter().
File
- core/
modules/ quickedit/ quickedit.module, line 162 - Provides in-place content editing functionality for fields.
Code
function quickedit_entity_view_alter(&$build, EntityInterface $entity, EntityViewDisplayInterface $display) {
if (isset($build['#embed'])) {
return;
}
$build['#cache']['contexts'][] = 'user.permissions';
if (!\Drupal::currentUser()
->hasPermission('access in-place editing') || $entity instanceof RevisionableInterface && !$entity
->isLatestRevision()) {
return;
}
$build['#attributes']['data-quickedit-entity-id'] = $entity
->getEntityTypeId() . '/' . $entity
->id();
}