You are here

function entity_page_label in Drupal 8

Returns the label of an entity.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity for which to generate the label.

$langcode: (optional) The language code of the language that should be used for getting the label. If set to NULL, the entity's default language is used.

Return value

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

Deprecated

in drupal:8.0.0 and is removed from drupal:9.0.0. Use the entity's label() method.

See also

https://www.drupal.org/node/2549923

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

1 call to entity_page_label()
EntityLegacyTest::testEntityLegacyCode in core/tests/Drupal/KernelTests/Core/Entity/EntityLegacyTest.php
@expectedDeprecation entity_load_multiple() is deprecated in Drupal 8.0.0 and will be removed before Drupal 9.0.0. Use the entity type storage's loadMultiple() method. See https://www.drupal.org/node/2266845 @expectedDeprecation entity_load() is…

File

core/includes/entity.inc, line 307
Entity API for handling entities like nodes or users.

Code

function entity_page_label(EntityInterface $entity, $langcode = NULL) {
  @trigger_error('entity_page_label() is deprecated in Drupal 8.0.0 and will be removed before Drupal 9.0.0. Use the entity\'s label() method. See https://www.drupal.org/node/2549923', E_USER_DEPRECATED);
  return $entity
    ->label($langcode);
}