public function EntityTest::label

Overrides Drupal\entity\Entity::label().

Overrides EntityNG::label

File

drupal/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Plugin/Core/Entity/EntityTest.php, line 93
Definition of Drupal\entity_test\Plugin\Core\Entity\EntityTest.

Class

EntityTest
Defines the test entity class.

Namespace

Drupal\entity_test\Plugin\Core\Entity

Code

public function label($langcode = Language::LANGCODE_DEFAULT) {
  $info = $this
    ->entityInfo();
  if (isset($info['entity_keys']['label']) && $info['entity_keys']['label'] == 'name') {
    return $this
      ->getTranslation($langcode)->name->value;
  }
  else {
    return parent::label($langcode);
  }
}