diff --git a/core/lib/Drupal/Core/Entity/Field/Type/EntityReferenceItem.php b/core/lib/Drupal/Core/Entity/Field/Type/EntityReferenceItem.php index 76f4d2c..b9d044b 100644 --- a/core/lib/Drupal/Core/Entity/Field/Type/EntityReferenceItem.php +++ b/core/lib/Drupal/Core/Entity/Field/Type/EntityReferenceItem.php @@ -35,7 +35,7 @@ public function getPropertyDefinitions() { $target_type = $this->definition['settings']['target_type']; if (!isset(self::$propertyDefinitions[$target_type])) { - self::$propertyDefinitions[$target_type]['target_id'] = array( + self::$propertyDefinitions[$target_type]['value'] = array( // @todo: Lookup the entity type's ID data type and use it here. 'type' => 'integer', 'label' => t('Entity ID'), @@ -50,7 +50,7 @@ public function getPropertyDefinitions() { // The entity object is computed out of the entity ID. 'computed' => TRUE, 'read-only' => FALSE, - 'settings' => array('id source' => 'target_id'), + 'settings' => array('id source' => 'value'), ); } return self::$propertyDefinitions[$target_type]; @@ -68,8 +68,8 @@ public function setValue($values) { // Entity is computed out of the ID, so we only need to update the ID. Only // set the entity field if no ID is given. - if (isset($values['target_id'])) { - $this->properties['target_id']->setValue($values['target_id']); + if (isset($values['value'])) { + $this->properties['value']->setValue($values['value']); } elseif (isset($values['entity'])) { $this->properties['entity']->setValue($values['entity']); @@ -77,7 +77,7 @@ public function setValue($values) { else { $this->properties['entity']->setValue(NULL); } - unset($values['entity'], $values['target_id']); + unset($values['entity'], $values['value']); if ($values) { throw new \InvalidArgumentException('Property ' . key($values) . ' is unknown.'); } diff --git a/core/modules/comment/lib/Drupal/comment/CommentStorageController.php b/core/modules/comment/lib/Drupal/comment/CommentStorageController.php index 4c91741..78c3ce9 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentStorageController.php +++ b/core/modules/comment/lib/Drupal/comment/CommentStorageController.php @@ -287,14 +287,14 @@ public function baseFieldDefinitions() { $properties['pid'] = array( 'label' => t('Parent ID'), 'description' => t('The parent comment ID if this is a reply to a comment.'), - 'type' => 'entityreference_field', - 'settings' => array('entity type' => 'comment'), + 'type' => 'entity_reference_field', + 'settings' => array('target_type' => 'comment'), ); $properties['nid'] = array( 'label' => t('Node ID'), 'description' => t('The ID of the node of which this comment is a reply.'), - 'type' => 'entityreference_field', - 'settings' => array('entity type' => 'node'), + 'type' => 'entity_reference_field', + 'settings' => array('target_type' => 'node'), 'required' => TRUE, ); $properties['langcode'] = array( @@ -310,8 +310,8 @@ public function baseFieldDefinitions() { $properties['uid'] = array( 'label' => t('User ID'), 'description' => t('The user ID of the comment author.'), - 'type' => 'entityreference_field', - 'settings' => array('entity type' => 'user'), + 'type' => 'entity_reference_field', + 'settings' => array('target_type' => 'user'), ); $properties['name'] = array( 'label' => t('Name'), diff --git a/core/modules/entity_reference/entity_reference.install b/core/modules/entity_reference/entity_reference.install index 17030ef..d0e9edb 100644 --- a/core/modules/entity_reference/entity_reference.install +++ b/core/modules/entity_reference/entity_reference.install @@ -12,7 +12,7 @@ function entity_reference_field_schema($field) { $schema = array( 'columns' => array( - 'target_id' => array( + 'value' => array( 'description' => 'The ID of the target entity.', 'type' => 'int', 'unsigned' => TRUE, @@ -26,7 +26,7 @@ function entity_reference_field_schema($field) { ), ), 'indexes' => array( - 'target_id' => array('target_id'), + 'value' => array('value'), ), 'foreign keys' => array(), ); @@ -42,7 +42,7 @@ function entity_reference_field_schema($field) { // // $schema['foreign keys'][$base_table] = array( // 'table' => $base_table, - // 'columns' => array('target_id' => $id_column), + // 'columns' => array('value' => $id_column), // ); return $schema; diff --git a/core/modules/entity_reference/entity_reference.module b/core/modules/entity_reference/entity_reference.module index 6cf9afa..1173926 100644 --- a/core/modules/entity_reference/entity_reference.module +++ b/core/modules/entity_reference/entity_reference.module @@ -97,11 +97,11 @@ function entity_reference_get_selection_handler($field, $instance, EntityInterfa * Implements hook_field_is_empty(). */ function entity_reference_field_is_empty($item, $field) { - if (!empty($item['target_id']) && $item['target_id'] == 'auto_create') { + if (!empty($item['value']) && $item['value'] == 'auto_create') { // Allow auto-create entities. return FALSE; } - return !isset($item['target_id']) || !is_numeric($item['target_id']); + return !isset($item['value']) || !is_numeric($item['value']); } /** @@ -123,7 +123,7 @@ function entity_reference_field_presave(EntityInterface $entity, $field, $instan } foreach ($items as $delta => $item) { - if ($item['target_id'] == 'auto_create') { + if ($item['value'] == 'auto_create') { $bundle_key = $entity_info['entity_keys']['bundle']; $label_key = $entity_info['entity_keys']['label']; $values = array( @@ -134,7 +134,7 @@ function entity_reference_field_presave(EntityInterface $entity, $field, $instan ); $target_entity = entity_create($target_type, $values); $target_entity->save(); - $items[$delta]['target_id'] = $target_entity->id(); + $items[$delta]['value'] = $target_entity->id(); } } } @@ -146,8 +146,8 @@ function entity_reference_field_presave(EntityInterface $entity, $field, $instan function entity_reference_field_validate(EntityInterface $entity = NULL, $field, $instance, $langcode, $items, &$errors) { $ids = array(); foreach ($items as $delta => $item) { - if (!entity_reference_field_is_empty($item, $field) && $item['target_id'] !== 'auto_create') { - $ids[$item['target_id']] = $delta; + if (!entity_reference_field_is_empty($item, $field) && $item['value'] !== 'auto_create') { + $ids[$item['value']] = $delta; } } diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/field/formatter/EntityReferenceEntityFormatter.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/field/formatter/EntityReferenceEntityFormatter.php index ecf3e6f..0c4c392 100644 --- a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/field/formatter/EntityReferenceEntityFormatter.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/field/formatter/EntityReferenceEntityFormatter.php @@ -94,7 +94,7 @@ public function viewElements(EntityInterface $entity, $langcode, array $items) { static $depth = 0; $depth++; if ($depth > 20) { - throw new RecursiveRenderingException(format_string('Recursive rendering detected when rendering entity @entity_type(@entity_id). Aborting rendering.', array('@entity_type' => $entity_type, '@entity_id' => $item['target_id']))); + throw new RecursiveRenderingException(format_string('Recursive rendering detected when rendering entity @entity_type(@entity_id). Aborting rendering.', array('@entity_type' => $entity_type, '@entity_id' => $item['value']))); } if (!empty($item['entity'])) { @@ -102,9 +102,9 @@ public function viewElements(EntityInterface $entity, $langcode, array $items) { unset($entity->content); $elements[$delta] = entity_view($entity, $view_mode, $langcode); - if (empty($links) && isset($result[$delta][$target_type][$item['target_id']]['links'])) { + if (empty($links) && isset($result[$delta][$target_type][$item['value']]['links'])) { // Hide the element links. - $elements[$delta][$target_type][$item['target_id']]['links']['#access'] = FALSE; + $elements[$delta][$target_type][$item['value']]['links']['#access'] = FALSE; } } else { diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/field/formatter/EntityReferenceFormatterBase.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/field/formatter/EntityReferenceFormatterBase.php index ed8dc2e..2ab0801 100644 --- a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/field/formatter/EntityReferenceFormatterBase.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/field/formatter/EntityReferenceFormatterBase.php @@ -25,7 +25,7 @@ * not be accessed. */ public function prepareView(array $entities, $langcode, array &$items) { - $target_ids = array(); + $values = array(); $revision_ids = array(); // Collect every possible entity attached to any of the entities. @@ -34,8 +34,8 @@ public function prepareView(array $entities, $langcode, array &$items) { if (!empty($item['revision_id'])) { $revision_ids[] = $item['revision_id']; } - elseif (!empty($item['target_id'])) { - $target_ids[] = $item['target_id']; + elseif (!empty($item['value'])) { + $values[] = $item['value']; } } } @@ -44,8 +44,8 @@ public function prepareView(array $entities, $langcode, array &$items) { $target_entities = array(); - if ($target_ids) { - $target_entities = entity_load_multiple($target_type, $target_ids); + if ($values) { + $target_entities = entity_load_multiple($target_type, $values); } if ($revision_ids) { @@ -64,8 +64,8 @@ public function prepareView(array $entities, $langcode, array &$items) { $rekey = FALSE; foreach ($items[$id] as $delta => $item) { // If we have a revision-ID, the key uses it as-well. - $identifier = !empty($item['revision_id']) ? $item['target_id'] . ':' . $item['revision_id'] : $item['target_id']; - if ($item['target_id'] != 'auto_create') { + $identifier = !empty($item['revision_id']) ? $item['value'] . ':' . $item['revision_id'] : $item['value']; + if ($item['value'] != 'auto_create') { if (!isset($target_entities[$identifier])) { // The entity no longer exists, so remove the key. $rekey = TRUE; diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/field/formatter/EntityReferenceIdFormatter.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/field/formatter/EntityReferenceIdFormatter.php index 263a24e..c69b4e5 100644 --- a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/field/formatter/EntityReferenceIdFormatter.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/field/formatter/EntityReferenceIdFormatter.php @@ -35,7 +35,7 @@ public function viewElements(EntityInterface $entity, $langcode, array $items) { foreach ($items as $delta => $item) { if (!empty($item['entity'])) { - $elements[$delta] = array('#markup' => check_plain($item['target_id'])); + $elements[$delta] = array('#markup' => check_plain($item['value'])); } } diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/field/widget/AutocompleteTagsWidget.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/field/widget/AutocompleteTagsWidget.php index c19b8a6..4d4243c 100644 --- a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/field/widget/AutocompleteTagsWidget.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/field/widget/AutocompleteTagsWidget.php @@ -67,11 +67,11 @@ public function elementValidate($element, &$form_state, $form) { } if ($match) { - $value[] = array('target_id' => $match); + $value[] = array('value' => $match); } elseif ($auto_create && (count($this->instance['settings']['handler_settings']['target_bundles']) == 1 || count($entity_info['bundles']) == 1)) { // Auto-create item. see entity_reference_field_presave(). - $value[] = array('target_id' => 'auto_create', 'label' => $entity); + $value[] = array('value' => 'auto_create', 'label' => $entity); } } } diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/field/widget/AutocompleteWidget.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/field/widget/AutocompleteWidget.php index 2663bdb..fe3787d 100644 --- a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/field/widget/AutocompleteWidget.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/field/widget/AutocompleteWidget.php @@ -51,7 +51,7 @@ public function formElement(array $items, $delta, array $element, $langcode, arr } $element = $this->prepareElement($items, $delta, $element, $langcode, $form, $form_state); - return array('target_id' => $element); + return array('value' => $element); } /** @@ -77,7 +77,7 @@ public function elementValidate($element, &$form_state, $form) { if (!$value && $auto_create && (count($this->instance['settings']['handler_settings']['target_bundles']) == 1 || count($entity_info['bundles']) == 1)) { // Auto-create item. see entity_reference_field_presave(). $value = array( - 'target_id' => 'auto_create', + 'value' => 'auto_create', 'label' => $element['#value'], // Keep the weight property. '_weight' => $element['#weight'], diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/field/widget/AutocompleteWidgetBase.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/field/widget/AutocompleteWidgetBase.php index 5ffd0f9..2614c98 100644 --- a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/field/widget/AutocompleteWidgetBase.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/field/widget/AutocompleteWidgetBase.php @@ -56,7 +56,7 @@ public function settingsForm(array $form, array &$form_state) { */ public function formElement(array $items, $delta, array $element, $langcode, array &$form, array &$form_state) { $element = $this->prepareElement($items, $delta, $element, $langcode, $form, $form_state, 'entity_reference/autocomplete/single'); - return array('target_id' => $element); + return array('value' => $element); } /** @@ -95,7 +95,7 @@ protected function prepareElement(array $items, $delta, array $element, $langcod * Overrides Drupal\field\Plugin\Type\Widget\WidgetBase::errorElement(). */ public function errorElement(array $element, array $error, array $form, array &$form_state) { - return $element['target_id']; + return $element['value']; } /** @@ -112,7 +112,7 @@ protected function getLabels(array $items) { // Build an array of entities ID. foreach ($items as $item) { - $entity_ids[] = $item['target_id']; + $entity_ids[] = $item['value']; } // Load those entities and loop through them to extract their labels. diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceAutoCreateTest.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceAutoCreateTest.php index 7ed83c2..d58f506 100644 --- a/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceAutoCreateTest.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceAutoCreateTest.php @@ -89,7 +89,7 @@ public function testAutoCreate() { $edit = array( 'title' => $this->randomName(), - 'test_field[und][0][target_id]' => $new_title, + 'test_field[und][0][value]' => $new_title, ); $this->drupalPost("node/add/$this->referencing_type", $edit, 'Save'); @@ -106,6 +106,6 @@ public function testAutoCreate() { $referencing_nid = key($result); $referencing_node = node_load($referencing_nid); - $this->assertEqual($referenced_nid, $referencing_node->test_field[LANGUAGE_NOT_SPECIFIED][0]['target_id'], 'Newly created node is referenced from the referencing node.'); + $this->assertEqual($referenced_nid, $referencing_node->test_field[LANGUAGE_NOT_SPECIFIED][0]['value'], 'Newly created node is referenced from the referencing node.'); } } diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceItemTest.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceItemTest.php index ab6a6c3..aac9a11 100644 --- a/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceItemTest.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceItemTest.php @@ -74,12 +74,12 @@ public function testEntityReferenceItem() { // Just being able to create the entity like this verifies a lot of // code. $entity = entity_create('entity_test', array('name' => 'foo')); - $entity->field_test->target_id = $nid; + $entity->field_test->value = $nid; $entity->save(); $this->assertTrue($entity->field_test instanceof FieldInterface, 'Field implements interface.'); $this->assertTrue($entity->field_test[0] instanceof FieldItemInterface, 'Field item implements interface.'); - $this->assertEqual($entity->field_test->target_id, $nid); + $this->assertEqual($entity->field_test->value, $nid); $this->assertEqual($entity->field_test->entity->title, $node1->label()); $this->assertEqual($entity->field_test->entity->id(), $nid); $this->assertEqual($entity->field_test->entity->uuid(), $node1->uuid()); @@ -96,7 +96,7 @@ public function testEntityReferenceItem() { // Make sure the computed node reflects updates to the node id. $node2 = $this->drupalCreateNode(); - $entity->field_test->target_id = $node2->nid; + $entity->field_test->value = $node2->nid; $this->assertEqual($entity->field_test->entity->id(), $node2->id()); $this->assertEqual($entity->field_test->entity->title, $node2->label()); } diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php index 2a98ffa..f696d00 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php @@ -46,7 +46,7 @@ protected function createTestEntity($entity_type) { // Pass in the value of the name field when creating. With the user // field we test setting a field after creation. $entity = entity_create($entity_type, array()); - $entity->user_id->target_id = $this->entity_user->uid; + $entity->user_id->value = $this->entity_user->uid; $entity->name->value = $this->entity_name; // Set a value for the test field. @@ -96,26 +96,26 @@ protected function assertReadWrite($entity_type) { $this->assertTrue($entity->user_id instanceof FieldInterface, format_string('%entity_type: Field implements interface', array('%entity_type' => $entity_type))); $this->assertTrue($entity->user_id[0] instanceof FieldItemInterface, format_string('%entity_type: Field item implements interface', array('%entity_type' => $entity_type))); - $this->assertEqual($this->entity_user->uid, $entity->user_id->target_id, format_string('%entity_type: User id can be read.', array('%entity_type' => $entity_type))); + $this->assertEqual($this->entity_user->uid, $entity->user_id->value, format_string('%entity_type: User id can be read.', array('%entity_type' => $entity_type))); $this->assertEqual($this->entity_user->name, $entity->user_id->entity->name, format_string('%entity_type: User name can be read.', array('%entity_type' => $entity_type))); // Change the assigned user by entity. $new_user = $this->drupalCreateUser(); $entity->user_id->entity = $new_user; - $this->assertEqual($new_user->uid, $entity->user_id->target_id, format_string('%entity_type: Updated user id can be read.', array('%entity_type' => $entity_type))); + $this->assertEqual($new_user->uid, $entity->user_id->value, format_string('%entity_type: Updated user id can be read.', array('%entity_type' => $entity_type))); $this->assertEqual($new_user->name, $entity->user_id->entity->name, format_string('%entity_type: Updated user name value can be read.', array('%entity_type' => $entity_type))); // Change the assigned user by id. $new_user = $this->drupalCreateUser(); - $entity->user_id->target_id = $new_user->uid; - $this->assertEqual($new_user->uid, $entity->user_id->target_id, format_string('%entity_type: Updated user id can be read.', array('%entity_type' => $entity_type))); + $entity->user_id->value = $new_user->uid; + $this->assertEqual($new_user->uid, $entity->user_id->value, format_string('%entity_type: Updated user id can be read.', array('%entity_type' => $entity_type))); $this->assertEqual($new_user->name, $entity->user_id->entity->name, format_string('%entity_type: Updated user name value can be read.', array('%entity_type' => $entity_type))); // Try unsetting a field. $entity->name->value = NULL; - $entity->user_id->target_id = NULL; + $entity->user_id->value = NULL; $this->assertNull($entity->name->value, format_string('%entity_type: Name field is not set.', array('%entity_type' => $entity_type))); - $this->assertNull($entity->user_id->target_id, format_string('%entity_type: User ID field is not set.', array('%entity_type' => $entity_type))); + $this->assertNull($entity->user_id->value, format_string('%entity_type: User ID field is not set.', array('%entity_type' => $entity_type))); $this->assertNull($entity->user_id->entity, format_string('%entity_type: User entity field is not set.', array('%entity_type' => $entity_type))); // Test using isset(), empty() and unset(). @@ -186,7 +186,7 @@ protected function assertReadWrite($entity_type) { $this->entity_name = $this->randomName(); $name_item[0]['value'] = $this->entity_name; $this->entity_user = $this->drupalCreateUser(); - $user_item[0]['target_id'] = $this->entity_user->uid; + $user_item[0]['value'] = $this->entity_user->uid; $this->entity_field_text = $this->randomName(); $text_item[0]['value'] = $this->entity_field_text; @@ -196,7 +196,7 @@ protected function assertReadWrite($entity_type) { 'field_test_text' => $text_item, )); $this->assertEqual($this->entity_name, $entity->name->value, format_string('%entity_type: Name value can be read.', array('%entity_type' => $entity_type))); - $this->assertEqual($this->entity_user->uid, $entity->user_id->target_id, format_string('%entity_type: User id can be read.', array('%entity_type' => $entity_type))); + $this->assertEqual($this->entity_user->uid, $entity->user_id->value, format_string('%entity_type: User id can be read.', array('%entity_type' => $entity_type))); $this->assertEqual($this->entity_user->name, $entity->user_id->entity->name, format_string('%entity_type: User name can be read.', array('%entity_type' => $entity_type))); $this->assertEqual($this->entity_field_text, $entity->field_test_text->value, format_string('%entity_type: Text field can be read.', array('%entity_type' => $entity_type))); @@ -208,7 +208,7 @@ protected function assertReadWrite($entity_type) { $this->assertTrue($entity->name !== $entity2->name, format_string('%entity_type: Copying properties results in a different field object.', array('%entity_type' => $entity_type))); $this->assertEqual($entity->name->value, $entity2->name->value, format_string('%entity_type: Name field copied.', array('%entity_type' => $entity_type))); - $this->assertEqual($entity->user_id->target_id, $entity2->user_id->target_id, format_string('%entity_type: User id field copied.', array('%entity_type' => $entity_type))); + $this->assertEqual($entity->user_id->value, $entity2->user_id->value, format_string('%entity_type: User id field copied.', array('%entity_type' => $entity_type))); $this->assertEqual($entity->field_test_text->value, $entity2->field_test_text->value, format_string('%entity_type: Text field copied.', array('%entity_type' => $entity_type))); // Tests adding a value to a field item list. @@ -259,14 +259,14 @@ protected function assertReadWrite($entity_type) { $this->assertEqual($entity->name->value, 'foo', format_string('%entity_type: Field value has been set via setPropertyValue() on an entity.', array('%entity_type' => $entity_type))); // Make sure the user id can be set to zero. - $user_item[0]['target_id'] = 0; + $user_item[0]['value'] = 0; $entity = entity_create($entity_type, array( 'name' => $name_item, 'user_id' => $user_item, 'field_test_text' => $text_item, )); - $this->assertNotNull($entity->user_id->target_id, format_string('%entity_type: User id is not NULL', array('%entity_type' => $entity_type))); - $this->assertIdentical($entity->user_id->target_id, 0, format_string('%entity_type: User id has been set to 0', array('%entity_type' => $entity_type))); + $this->assertNotNull($entity->user_id->value, format_string('%entity_type: User id is not NULL', array('%entity_type' => $entity_type))); + $this->assertIdentical($entity->user_id->value, 0, format_string('%entity_type: User id has been set to 0', array('%entity_type' => $entity_type))); // Test setting the ID with the value only. $entity = entity_create($entity_type, array( @@ -274,8 +274,8 @@ protected function assertReadWrite($entity_type) { 'user_id' => 0, 'field_test_text' => $text_item, )); - $this->assertNotNull($entity->user_id->target_id, format_string('%entity_type: User id is not NULL', array('%entity_type' => $entity_type))); - $this->assertIdentical($entity->user_id->target_id, 0, format_string('%entity_type: User id has been set to 0', array('%entity_type' => $entity_type))); + $this->assertNotNull($entity->user_id->value, format_string('%entity_type: User id is not NULL', array('%entity_type' => $entity_type))); + $this->assertIdentical($entity->user_id->value, 0, format_string('%entity_type: User id has been set to 0', array('%entity_type' => $entity_type))); } /** @@ -307,7 +307,7 @@ protected function assertSave($entity_type) { $this->assertTrue(is_string($entity->uuid->value), format_string('%entity_type: UUID value can be read.', array('%entity_type' => $entity_type))); $this->assertEqual(LANGUAGE_NOT_SPECIFIED, $entity->langcode->value, format_string('%entity_type: Language code can be read.', array('%entity_type' => $entity_type))); $this->assertEqual(language_load(LANGUAGE_NOT_SPECIFIED), $entity->langcode->language, format_string('%entity_type: Language object can be read.', array('%entity_type' => $entity_type))); - $this->assertEqual($this->entity_user->uid, $entity->user_id->target_id, format_string('%entity_type: User id can be read.', array('%entity_type' => $entity_type))); + $this->assertEqual($this->entity_user->uid, $entity->user_id->value, format_string('%entity_type: User id can be read.', array('%entity_type' => $entity_type))); $this->assertEqual($this->entity_user->name, $entity->user_id->entity->name, format_string('%entity_type: User name can be read.', array('%entity_type' => $entity_type))); $this->assertEqual($this->entity_field_text, $entity->field_test_text->value, format_string('%entity_type: Text field can be read.', array('%entity_type' => $entity_type))); } @@ -356,7 +356,7 @@ protected function assertIntrospection($entity_type) { $this->assertEqual($name_properties['value']['type'], 'string', $entity_type .': String value property of the name found.'); $userref_properties = $entity->user_id->getPropertyDefinitions(); - $this->assertEqual($userref_properties['target_id']['type'], 'integer', $entity_type .': Entity id property of the user found.'); + $this->assertEqual($userref_properties['value']['type'], 'integer', $entity_type .': Entity id property of the user found.'); $this->assertEqual($userref_properties['entity']['type'], 'entity', $entity_type .': Entity reference property of the user found.'); $textfield_properties = $entity->field_test_text->getPropertyDefinitions(); diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryRelationshipTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryRelationshipTest.php index 8d5fa81..4ca53c1 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryRelationshipTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryRelationshipTest.php @@ -109,7 +109,7 @@ protected function setUp() { $entity = entity_create('entity_test', array()); $entity->name->value = $this->randomName(); $index = $i ? 1 : 0; - $entity->user_id->target_id = $this->accounts[$index]->uid; + $entity->user_id->value = $this->accounts[$index]->uid; $entity->{$this->fieldName}->tid = $this->terms[$index]->tid; $entity->save(); $this->entities[] = $entity; diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php index e5f79c9..b658cd9 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php @@ -215,13 +215,13 @@ protected function assertMultilingualProperties($entity_type) { $entity = entity_load($entity_type, $entity->id()); $this->assertEqual($entity->language()->langcode, LANGUAGE_NOT_SPECIFIED, format_string('%entity_type: Entity created as language neutral.', array('%entity_type' => $entity_type))); $this->assertEqual($name, $entity->getTranslation(LANGUAGE_DEFAULT)->get('name')->value, format_string('%entity_type: The entity name has been correctly stored as language neutral.', array('%entity_type' => $entity_type))); - $this->assertEqual($uid, $entity->getTranslation(LANGUAGE_DEFAULT)->get('user_id')->target_id, format_string('%entity_type: The entity author has been correctly stored as language neutral.', array('%entity_type' => $entity_type))); + $this->assertEqual($uid, $entity->getTranslation(LANGUAGE_DEFAULT)->get('user_id')->value, format_string('%entity_type: The entity author has been correctly stored as language neutral.', array('%entity_type' => $entity_type))); // As fields, translatable properties should ignore the given langcode and // use neutral language if the entity is not translatable. $this->assertEqual($name, $entity->getTranslation($langcode)->get('name')->value, format_string('%entity_type: The entity name defaults to neutral language.', array('%entity_type' => $entity_type))); - $this->assertEqual($uid, $entity->getTranslation($langcode)->get('user_id')->target_id, format_string('%entity_type: The entity author defaults to neutral language.', array('%entity_type' => $entity_type))); + $this->assertEqual($uid, $entity->getTranslation($langcode)->get('user_id')->value, format_string('%entity_type: The entity author defaults to neutral language.', array('%entity_type' => $entity_type))); $this->assertEqual($name, $entity->get('name')->value, format_string('%entity_type: The entity name can be retrieved without specifying a language.', array('%entity_type' => $entity_type))); - $this->assertEqual($uid, $entity->get('user_id')->target_id, format_string('%entity_type: The entity author can be retrieved without specifying a language.', array('%entity_type' => $entity_type))); + $this->assertEqual($uid, $entity->get('user_id')->value, format_string('%entity_type: The entity author can be retrieved without specifying a language.', array('%entity_type' => $entity_type))); // Create a language-aware entity and check that properties are stored // as language-aware. @@ -230,13 +230,13 @@ protected function assertMultilingualProperties($entity_type) { $entity = entity_load($entity_type, $entity->id()); $this->assertEqual($entity->language()->langcode, $langcode, format_string('%entity_type: Entity created as language specific.', array('%entity_type' => $entity_type))); $this->assertEqual($name, $entity->getTranslation($langcode)->get('name')->value, format_string('%entity_type: The entity name has been correctly stored as a language-aware property.', array('%entity_type' => $entity_type))); - $this->assertEqual($uid, $entity->getTranslation($langcode)->get('user_id')->target_id, format_string('%entity_type: The entity author has been correctly stored as a language-aware property.', array('%entity_type' => $entity_type))); + $this->assertEqual($uid, $entity->getTranslation($langcode)->get('user_id')->value, format_string('%entity_type: The entity author has been correctly stored as a language-aware property.', array('%entity_type' => $entity_type))); // Translatable properties on a translatable entity should use default // language if LANGUAGE_NOT_SPECIFIED is passed. $this->assertEqual($name, $entity->getTranslation(LANGUAGE_NOT_SPECIFIED)->get('name')->value, format_string('%entity_type: The entity name defaults to the default language.', array('%entity_type' => $entity_type))); - $this->assertEqual($uid, $entity->getTranslation(LANGUAGE_NOT_SPECIFIED)->get('user_id')->target_id, format_string('%entity_type: The entity author defaults to the default language.', array('%entity_type' => $entity_type))); + $this->assertEqual($uid, $entity->getTranslation(LANGUAGE_NOT_SPECIFIED)->get('user_id')->value, format_string('%entity_type: The entity author defaults to the default language.', array('%entity_type' => $entity_type))); $this->assertEqual($name, $entity->get('name')->value, format_string('%entity_type: The entity name can be retrieved without specifying a language.', array('%entity_type' => $entity_type))); - $this->assertEqual($uid, $entity->get('user_id')->target_id, format_string('%entity_type: The entity author can be retrieved without specifying a language.', array('%entity_type' => $entity_type))); + $this->assertEqual($uid, $entity->get('user_id')->value, format_string('%entity_type: The entity author can be retrieved without specifying a language.', array('%entity_type' => $entity_type))); // Create property translations. $properties = array(); @@ -266,7 +266,7 @@ protected function assertMultilingualProperties($entity_type) { '%langcode' => $langcode, ); $this->assertEqual($properties[$langcode]['name'][0], $entity->getTranslation($langcode)->get('name')->value, format_string('%entity_type: The entity name has been correctly stored for language %langcode.', $args)); - $this->assertEqual($properties[$langcode]['user_id'][0], $entity->getTranslation($langcode)->get('user_id')->target_id, format_string('%entity_type: The entity author has been correctly stored for language %langcode.', $args)); + $this->assertEqual($properties[$langcode]['user_id'][0], $entity->getTranslation($langcode)->get('user_id')->value, format_string('%entity_type: The entity author has been correctly stored for language %langcode.', $args)); } // Test query conditions (cache is reset at each call). diff --git a/core/modules/system/lib/Drupal/system/Tests/Serialization/EntitySerializationTest.php b/core/modules/system/lib/Drupal/system/Tests/Serialization/EntitySerializationTest.php index 5855e91..ea3c960 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Serialization/EntitySerializationTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Serialization/EntitySerializationTest.php @@ -90,7 +90,7 @@ public function testNormalize() { array('value' => $this->values['name']), ), 'user_id' => array( - array('target_id' => $this->values['user_id']), + array('value' => $this->values['user_id']), ), 'field_test_text' => array( array( diff --git a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestFormController.php b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestFormController.php index c08e3b3..e1892a0 100644 --- a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestFormController.php +++ b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestFormController.php @@ -36,7 +36,7 @@ public function form(array $form, array &$form_state, EntityInterface $entity) { $form['user_id'] = array( '#type' => 'textfield', '#title' => 'UID', - '#default_value' => $translation->user_id->target_id, + '#default_value' => $translation->user_id->value, '#size' => 60, '#maxlength' => 128, '#required' => TRUE, diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/formatter/EntityReferenceTaxonomyTermRssFormatter.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/formatter/EntityReferenceTaxonomyTermRssFormatter.php index c528985..253fa9e 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/formatter/EntityReferenceTaxonomyTermRssFormatter.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/formatter/EntityReferenceTaxonomyTermRssFormatter.php @@ -38,9 +38,9 @@ public function viewElements(EntityInterface $entity, $langcode, array $items) { foreach ($items as $delta => $item) { $entity->rss_elements[] = array( 'key' => 'category', - 'value' => $item['target_id'] != 'autocreate' ? $item['entity']->label() : $item['label'], + 'value' => $item['value'] != 'autocreate' ? $item['entity']->label() : $item['label'], 'attributes' => array( - 'domain' => $item['target_id'] != 'autocreate' ? url('taxonomy/term/' . $item['target_id'], array('absolute' => TRUE)) : '', + 'domain' => $item['value'] != 'autocreate' ? url('taxonomy/term/' . $item['value'], array('absolute' => TRUE)) : '', ), ); } diff --git a/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationUITest.php b/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationUITest.php index 7e88fb5..42be87c 100644 --- a/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationUITest.php +++ b/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationUITest.php @@ -311,12 +311,11 @@ protected function getTranslation(EntityInterface $entity, $langcode) { * The property value. */ protected function getValue(ComplexDataInterface $translation, $property, $langcode) { - $key = $property == 'user_id' ? 'target_id' : 'value'; if (($translation instanceof EntityInterface) && !($translation instanceof EntityNG)) { - return is_array($translation->$property) ? $translation->{$property}[$langcode][0][$key] : $translation->$property; + return is_array($translation->$property) ? $translation->{$property}[$langcode][0]['value'] : $translation->$property; } else { - return $translation->get($property)->{$key}; + return $translation->get($property)->value; } }