diff --git a/core/modules/entity/entity.module b/core/modules/entity/entity.module index aa32a33..93fefb5 100644 --- a/core/modules/entity/entity.module +++ b/core/modules/entity/entity.module @@ -412,36 +412,6 @@ function entity_uri($entity_type, $entity) { } /** - * Returns the label of an entity. - * - * See the 'label callback' component of the hook_entity_info() return value - * for more information. - * - * @param $entity_type - * The entity type; e.g., 'node' or 'user'. - * @param $entity - * The entity for which to generate the label. - * - * @return - * The entity label, or FALSE if not found. - * - * @todo - * Remove once all entity types are implementing the EntityInterface. - */ -function entity_label($entity_type, $entity) { - $label = FALSE; - $info = entity_get_info($entity_type); - if (isset($info['label callback'])) { - $label = $info['label callback']($entity_type, $entity); - } - elseif (!empty($info['entity keys']['label']) && isset($entity->{$info['entity keys']['label']})) { - $label = $entity->{$info['entity keys']['label']}; - } - - return $label; -} - -/** * Attaches field API validation to entity forms. */ function entity_form_field_validate($entity_type, $form, &$form_state) { diff --git a/core/modules/entity/lib/Drupal/entity/Entity.php b/core/modules/entity/lib/Drupal/entity/Entity.php index f0f5a76..3fa0ead 100644 --- a/core/modules/entity/lib/Drupal/entity/Entity.php +++ b/core/modules/entity/lib/Drupal/entity/Entity.php @@ -86,8 +86,6 @@ class Entity implements EntityInterface { /** * Implements EntityInterface::label(). - * - * @see entity_label() */ public function label() { $label = FALSE; diff --git a/core/modules/field/tests/field.test b/core/modules/field/tests/field.test index ca4de1b..6b74eb8 100644 --- a/core/modules/field/tests/field.test +++ b/core/modules/field/tests/field.test @@ -3396,7 +3396,7 @@ class EntityPropertiesTestCase extends FieldTestCase { $entity = field_test_create_stub_entity(); foreach ($entity_types as $entity_type) { - $label = entity_label($entity_type, $entity); + $label = entity_create($entity_type, (array)$entity)->label(); switch ($entity_type) { case 'test_entity_no_label': diff --git a/core/modules/field/tests/modules/field_test/field_test.entity.inc b/core/modules/field/tests/modules/field_test/field_test.entity.inc index 9185b85..31d20f1 100644 --- a/core/modules/field/tests/modules/field_test/field_test.entity.inc +++ b/core/modules/field/tests/modules/field_test/field_test.entity.inc @@ -81,6 +81,7 @@ function field_test_entity_info() { 'fieldable' => TRUE, 'field cache' => FALSE, 'base table' => 'test_entity', + 'revision table' => 'test_entity_revision', 'entity keys' => array( 'id' => 'ftid', 'revision' => 'ftvid', @@ -94,6 +95,7 @@ function field_test_entity_info() { 'fieldable' => TRUE, 'field cache' => FALSE, 'base table' => 'test_entity', + 'revision table' => 'test_entity_revision', 'entity keys' => array( 'id' => 'ftid', 'revision' => 'ftvid', @@ -108,6 +110,7 @@ function field_test_entity_info() { 'fieldable' => TRUE, 'field cache' => FALSE, 'base table' => 'test_entity', + 'revision table' => 'test_entity_revision', 'label callback' => 'field_test_entity_label_callback', 'entity keys' => array( 'id' => 'ftid', diff --git a/core/modules/user/lib/Drupal/user/Tests/UserEntityCallbacksTest.php b/core/modules/user/lib/Drupal/user/Tests/UserEntityCallbacksTest.php index a8fd35b..cc07ce3 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserEntityCallbacksTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserEntityCallbacksTest.php @@ -25,19 +25,19 @@ class UserEntityCallbacksTest extends WebTestBase { parent::setUp('user'); $this->account = $this->drupalCreateUser(); - $this->anonymous = drupal_anonymous_user(); + $this->anonymous = entity_create('user', (array)drupal_anonymous_user()); } /** * Test label callback. */ function testLabelCallback() { - $this->assertEqual(entity_label('user', $this->account), $this->account->name, t('The username should be used as label')); + $this->assertEqual($this->account->label(), $this->account->name, t('The username should be used as label')); // Setup a random anonymous name to be sure the name is used. $name = $this->randomName(); variable_set('anonymous', $name); - $this->assertEqual(entity_label('user', $this->anonymous), $name, t('The variable anonymous should be used for name of uid 0')); + $this->assertEqual($this->anonymous->label(), $name, t('The variable anonymous should be used for name of uid 0')); } /**