8.2.x EntityType.php public EntityType::getLabelCallback()
8.0.x EntityType.php public EntityType::getLabelCallback()
8.1.x EntityType.php public EntityType::getLabelCallback()
8.3.x EntityType.php public EntityType::getLabelCallback()

Gets the callback for the label of the entity.

The function takes an entity and returns the label of the entity. Use language() on the entity to get information on the requested language. The entity label is the main string associated with an entity; for example, the title of a node or the subject of a comment. If there is an entity object property that defines the label, use the 'label' element of the 'entity_keys' return value component to provide this information. If more complex logic is needed to determine the label of an entity, you can instead specify a callback function here, which will be called to determine the entity label.

@todo Remove usages of label_callback https://www.drupal.org/node/2450793.

Return value

callable|null The callback, or NULL if none exists.

Overrides EntityTypeInterface::getLabelCallback


in Drupal 8.0.x-dev and will be removed before Drupal 9.0.0. Use Drupal\Core\Entity\EntityInterface::label() for complex label generation as needed.

See also





core/lib/Drupal/Core/Entity/EntityType.php, line 645


Provides an implementation of an entity type and its metadata.




public function getLabelCallback() {
  return $this->label_callback;