You are here

public function ContentEntityBase::label in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Entity/ContentEntityBase.php \Drupal\Core\Entity\ContentEntityBase::label()
  2. 9 core/lib/Drupal/Core/Entity/ContentEntityBase.php \Drupal\Core\Entity\ContentEntityBase::label()

Gets the label of the entity.

Return value

string|\Drupal\Core\StringTranslation\TranslatableMarkup|null The label of the entity, or NULL if there is no label defined.

Overrides EntityBase::label

1 call to ContentEntityBase::label()
Term::getName in core/modules/taxonomy/src/Entity/Term.php
Gets the term name.
3 methods override ContentEntityBase::label()
EntityTestNoLabel::label in core/modules/system/tests/modules/entity_test/src/Entity/EntityTestNoLabel.php
Gets the label of the entity.
Media::label in core/modules/media/src/Entity/Media.php
Gets the label of the entity.
PathAlias::label in core/modules/path_alias/src/Entity/PathAlias.php
Gets the label of the entity.

File

core/lib/Drupal/Core/Entity/ContentEntityBase.php, line 1264

Class

ContentEntityBase
Implements Entity Field API specific enhancements to the Entity class.

Namespace

Drupal\Core\Entity

Code

public function label() {
  if ($this
    ->getEntityType()
    ->getKey('label')) {
    return $this
      ->getEntityKey('label');
  }
}