function quickedit_entity_view_alter

Same name in other branches
  1. 8.9.x core/modules/quickedit/quickedit.module \quickedit_entity_view_alter()

Implements hook_entity_view_alter().

File

core/modules/quickedit/quickedit.module, line 209

Code

function quickedit_entity_view_alter(&$build, EntityInterface $entity, EntityViewDisplayInterface $display) {
    if (\Drupal::moduleHandler()->moduleExists('layout_builder')) {
        
        /** @var \Drupal\quickedit\LayoutBuilderIntegration $layout_builder_integration */
        $layout_builder_integration = \Drupal::classResolver(LayoutBuilderIntegration::class);
        $layout_builder_integration->entityViewAlter($build, $entity, $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();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.