You are here

public function EntityType::getLabelCallback in Drupal 8

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.

Return value

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

Overrides EntityTypeInterface::getLabelCallback

Deprecated

in drupal:8.0.0 and is removed from drupal:9.0.0. Override the EntityInterface::label() method instead for dynamic labels.

See also

\Drupal\Core\Entity\EntityInterface::label()

\Drupal\Core\Entity\EntityTypeInterface::setLabelCallback()

\Drupal\Core\Entity\EntityTypeInterface::hasLabelCallback()

File

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

Class

EntityType
Provides an implementation of an entity type and its metadata.

Namespace

Drupal\Core\Entity

Code

public function getLabelCallback() {
  @trigger_error('EntityType::getLabelCallback() is deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. Override the EntityInterface::label() method instead for dynamic labels. See https://www.drupal.org/node/3050794', E_USER_DEPRECATED);
  return $this->label_callback;
}