public function EntityNG::label

Overrides Entity::label() to access the label field with the new API.

Overrides Entity::label

1 call to EntityNG::label()
EntityTest::label in drupal/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Plugin/Core/Entity/EntityTest.php
Overrides Drupal\entity\Entity::label().
3 methods override EntityNG::label()
EntityTest::label in drupal/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Plugin/Core/Entity/EntityTest.php
Overrides Drupal\entity\Entity::label().
Feed::label in drupal/core/modules/aggregator/lib/Drupal/aggregator/Plugin/Core/Entity/Feed.php
Implements Drupal\Core\Entity\EntityInterface::label().
Item::label in drupal/core/modules/aggregator/lib/Drupal/aggregator/Plugin/Core/Entity/Item.php
Implements Drupal\Core\Entity\EntityInterface::label().

File

drupal/core/lib/Drupal/Core/Entity/EntityNG.php, line 581
Contains \Drupal\Core\Entity\EntityNG.

Class

EntityNG
Implements Entity Field API specific enhancements to the Entity class.

Namespace

Drupal\Core\Entity

Code

public function label($langcode = NULL) {
  $label = NULL;
  $entity_info = $this
    ->entityInfo();
  if (isset($entity_info['label_callback']) && function_exists($entity_info['label_callback'])) {
    $label = $entity_info['label_callback']($this->entityType, $this, $langcode);
  }
  elseif (!empty($entity_info['entity_keys']['label']) && isset($this->{$entity_info['entity_keys']['label']})) {
    $label = $this->{$entity_info['entity_keys']['label']}->value;
  }
  return $label;
}