diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Entity/CustomBlock.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Entity/CustomBlock.php index 68c3b102ad5ccadbc8fcdc092d12eb8b4ad49f1f..12766292ae38a92dac0599abf5c199030fd69551 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Entity/CustomBlock.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Entity/CustomBlock.php @@ -188,9 +188,10 @@ public static function baseFieldDefinitions($entity_type) { ->setLabel(t('Subject')) ->setDescription(t('The custom block name.')); - $fields['type'] = FieldDefinition::create('string') + $fields['type'] = FieldDefinition::create('entity_reference') ->setLabel(t('Block type')) - ->setDescription(t('The block type.')); + ->setDescription(t('The block type.')) + ->setSetting('target_type', 'custom_block_type'); $fields['log'] = FieldDefinition::create('string') ->setLabel(t('Revision log message')) diff --git a/core/modules/comment/lib/Drupal/comment/Entity/Comment.php b/core/modules/comment/lib/Drupal/comment/Entity/Comment.php index a715fb4f4b0be836f7a0776c01e41affc162935b..0d4947941fd48b2f6c74d22fa2b8c26b6208b0d4 100644 --- a/core/modules/comment/lib/Drupal/comment/Entity/Comment.php +++ b/core/modules/comment/lib/Drupal/comment/Entity/Comment.php @@ -430,11 +430,10 @@ public static function baseFieldDefinitions($entity_type) { ->setLabel(t('Entity type')) ->setDescription(t('The entity type to which this comment is attached.')); - // @todo Convert to aa entity_reference field in - // https://drupal.org/node/2149859. - $fields['field_id'] = FieldDefinition::create('string') + $fields['field_id'] = FieldDefinition::create('entity_reference') ->setLabel(t('Field ID')) - ->setDescription(t('The comment field id.')); + ->setDescription(t('The comment field id.')) + ->setSetting('target_type', 'field_entity'); $fields['field_name'] = FieldDefinition::create('string') ->setLabel(t('Comment field name')) diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Entity/Term.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Entity/Term.php index d8f503c8a9ee2110c6d862a553b710f6816e9c4e..d4fe2cc093d37646618ae65e6d7f307374210074 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Entity/Term.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Entity/Term.php @@ -208,11 +208,10 @@ public static function baseFieldDefinitions($entity_type) { ->setDescription(t('The term UUID.')) ->setReadOnly(TRUE); - // @todo Convert this to an entity_reference field, see - // https://drupal.org/node/2181593 - $fields['vid'] = FieldDefinition::create('string') - ->setLabel(t('Vocabulary ID')) - ->setDescription(t('The ID of the vocabulary to which the term is assigned.')); + $fields['vid'] = FieldDefinition::create('entity_reference') + ->setLabel(t('Vocabulary')) + ->setDescription(t('The vocabulary to which the term is assigned.')) + ->setSetting('target_type', 'taxonomy_vocabulary'); $fields['langcode'] = FieldDefinition::create('language') ->setLabel(t('Language code')) diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TaxonomyTermReferenceItemTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TaxonomyTermReferenceItemTest.php index ed631d8420fa9c014db93a7d668a9e08165a501c..e154c4363cf00c3834969dc7f7e5a1f0fafa3502 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TaxonomyTermReferenceItemTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TaxonomyTermReferenceItemTest.php @@ -102,7 +102,7 @@ public function testTaxonomyTermReferenceItem() { // Make sure the computed term reflects updates to the term id. $term2 = entity_create('taxonomy_term', array( 'name' => $this->randomName(), - 'vid' => $this->term->vid->value, + 'vid' => $this->term->bundle(), 'langcode' => Language::LANGCODE_NOT_SPECIFIED, )); $term2->save(); diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermValidationTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermValidationTest.php index dfb9803fe1c00dcd08a9b4d4743d47a484390689..e36668f3b38b473fcbfdae0c37e7824284d80b2d 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermValidationTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermValidationTest.php @@ -41,6 +41,10 @@ public function setUp() { * Tests the term validation constraints. */ public function testValidation() { + $this->entityManager->getStorageController('taxonomy_vocabulary')->create(array( + 'vid' => 'tags', + 'name' => 'Tags', + ))->save(); $term = $this->entityManager->getStorageController('taxonomy_term')->create(array( 'name' => 'test', 'vid' => 'tags',