You are here

public function ContentEntityBase::label in Zircon Profile 8.0

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

Gets the label of the entity.

Return value

string|null The label of the entity, or NULL if there is no label defined.

Overrides Entity::label

1 call to ContentEntityBase::label()
Term::getName in core/modules/taxonomy/src/Entity/Term.php
Gets the name of the term.
3 methods override ContentEntityBase::label()
EntityTestNoLabel::label in core/modules/system/tests/modules/entity_test/src/Entity/EntityTestNoLabel.php
inheritdoc}
Feed::label in core/modules/aggregator/src/Entity/Feed.php
Gets the label of the entity.
Item::label in core/modules/aggregator/src/Entity/Item.php
Gets the label of the entity.

File

core/lib/Drupal/Core/Entity/ContentEntityBase.php, line 1044
Contains \Drupal\Core\Entity\ContentEntityBase.

Class

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

Namespace

Drupal\Core\Entity

Code

public function label() {
  $label = NULL;
  $entity_type = $this
    ->getEntityType();
  if (($label_callback = $entity_type
    ->getLabelCallback()) && is_callable($label_callback)) {
    $label = call_user_func($label_callback, $this);
  }
  elseif ($label_key = $entity_type
    ->getKey('label')) {
    $label = $this
      ->getEntityKey('label');
  }
  return $label;
}