public function ContentEntityBase::label

public 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

File

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

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;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Entity!ContentEntityBase.php/function/ContentEntityBase::label/8.1.x