function MetadataGenerator::generateEntityMetadata

Same name in other branches
  1. 8.9.x core/modules/quickedit/src/MetadataGenerator.php \Drupal\quickedit\MetadataGenerator::generateEntityMetadata()

Overrides MetadataGeneratorInterface::generateEntityMetadata

File

core/modules/quickedit/src/MetadataGenerator.php, line 57

Class

MetadataGenerator
Generates in-place editing metadata for an entity field.

Namespace

Drupal\quickedit

Code

public function generateEntityMetadata(EntityInterface $entity) {
    return [
        'label' => $entity->access('view label') ? $entity->label() : new TranslatableMarkup('@label @id', [
            '@label' => $entity->getEntityType()
                ->getSingularLabel(),
            '@id' => $entity->id(),
        ]),
    ];
}

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