Entity::label

public Entity::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 EntityInterface::label

File

core/lib/Drupal/Core/Entity/Entity.php, line 155

Class

Entity
Defines a base 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')) && isset($this->{$label_key})) {
    $label = $this->{$label_key};
  }
  return $label;
}
doc_Drupal
2016-10-29 09:04:21
Comments
Leave a Comment

Please login to continue.