You are here

function quickedit_preprocess_entity_page_title in Drupal 10

Implements hook_preprocess_entity_page_title().

File

core/modules/quickedit/quickedit.module, line 149
Provides in-place content editing functionality for fields.

Code

function quickedit_preprocess_entity_page_title(&$variables) {
  $variables['#cache']['contexts'][] = 'user.permissions';
  $entity = $variables['entity'];
  if (!\Drupal::currentUser()
    ->hasPermission('access in-place editing')) {
    return;
  }
  if ($entity instanceof RevisionableInterface && !$entity
    ->isLatestRevision()) {
    return;
  }
  $label_field = $entity
    ->getEntityType()
    ->getKey('label');
  $variables['attributes']['data-quickedit-field-id'] = $entity
    ->getEntityTypeId() . '/' . $entity
    ->id() . '/' . $label_field . '/' . $entity
    ->language()
    ->getId() . '/' . $variables['view_mode'];
}