diff --git a/core/modules/migrate_drupal/config/install/migrate.migration.d6_vocabulary_field_instance.yml b/core/modules/migrate_drupal/config/install/migrate.migration.d6_vocabulary_field_instance.yml index d0633db..a9ada08 100644 --- a/core/modules/migrate_drupal/config/install/migrate.migration.d6_vocabulary_field_instance.yml +++ b/core/modules/migrate_drupal/config/install/migrate.migration.d6_vocabulary_field_instance.yml @@ -6,6 +6,8 @@ source: plugin: d6_taxonomy_vocabulary_per_type constants: entity_type: node + auto_create: true + selection_handler: 'default:taxonomy_term' process: entity_type: 'constants/entity_type' bundle: type @@ -13,7 +15,9 @@ process: plugin: migration migration: d6_taxonomy_vocabulary source: vid + 'settings/handler': 'constants/selection_handler' 'settings/handler_settings/target_bundles/0': @field_name + 'settings/handler_settings/auto_create': 'constants/auto_create' destination: plugin: entity:field_config migration_dependencies: diff --git a/core/modules/migrate_drupal/config/schema/migrate_drupal.source.schema.yml b/core/modules/migrate_drupal/config/schema/migrate_drupal.source.schema.yml index 1acb34e..f48c43e 100644 --- a/core/modules/migrate_drupal/config/schema/migrate_drupal.source.schema.yml +++ b/core/modules/migrate_drupal/config/schema/migrate_drupal.source.schema.yml @@ -363,3 +363,9 @@ migrate_entity_constant: sequence: type: string label: 'Settings' + selection_handler: + type: string + label: 'Entity reference selection handler' + auto_create: + type: boolean + label: 'Entity reference selection setting: Auto-create new entities' diff --git a/core/modules/migrate_drupal/src/Tests/d6/MigrateVocabularyFieldInstanceTest.php b/core/modules/migrate_drupal/src/Tests/d6/MigrateVocabularyFieldInstanceTest.php index 1ed31b9..6b84d59 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateVocabularyFieldInstanceTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateVocabularyFieldInstanceTest.php @@ -89,7 +89,9 @@ public function testVocabularyFieldInstance() { $this->assertIdentical($field_id, $field->id(), 'Field instance exists on page bundle.'); $settings = $field->getSettings(); + $this->assertIdentical('default:taxonomy_term', $settings['handler'], 'The handler plugin ID is correct.'); $this->assertIdentical(['tags'], $settings['handler_settings']['target_bundles'], 'The target_bundle handler setting is correct.'); + $this->assertIdentical(TRUE, $settings['handler_settings']['auto_create'], 'The "auto_create" setting is correct.'); $this->assertIdentical(array('node', 'article', 'tags'), entity_load('migration', 'd6_vocabulary_field_instance')->getIdMap()->lookupDestinationID(array(4, 'article'))); } diff --git a/core/modules/rdf/src/Tests/EntityReferenceFieldAttributesTest.php b/core/modules/rdf/src/Tests/EntityReferenceFieldAttributesTest.php index 1e962e8..a92ed7c 100644 --- a/core/modules/rdf/src/Tests/EntityReferenceFieldAttributesTest.php +++ b/core/modules/rdf/src/Tests/EntityReferenceFieldAttributesTest.php @@ -8,7 +8,6 @@ namespace Drupal\rdf\Tests; use Drupal\Core\Field\FieldStorageDefinitionInterface; -use Drupal\entity_reference\Tests\EntityReferenceTestTrait; use Drupal\taxonomy\Tests\TaxonomyTestBase; /** @@ -18,8 +17,6 @@ */ class EntityReferenceFieldAttributesTest extends TaxonomyTestBase { - use EntityReferenceTestTrait; - /** * Modules to enable. * @@ -50,7 +47,20 @@ protected function setUp() { // Create the field. $this->fieldName = 'field_taxonomy_test'; - $this->createEntityReferenceField($this->fieldName, $this->vocabulary); + $handler_settings = array( + 'target_bundles' => array( + $this->vocabulary->id() => $this->vocabulary->id(), + ), + 'auto_create' => TRUE, + ); + $this->createEntityReferenceField('node', 'article', $this->fieldName, 'Tags', 'taxonomy_term', 'default', $handler_settings, FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED); + + entity_get_form_display('node', 'article', 'default') + ->setComponent($this->fieldName, array('type' => 'options_select')) + ->save(); + entity_get_display('node', 'article', 'full') + ->setComponent($this->fieldName, array('type' => 'entity_reference_label')) + ->save(); // Set the RDF mapping for the new field. rdf_get_mapping('node', 'article') @@ -139,31 +149,4 @@ function testNodeTeaser() { //$this->assertTrue($graph->hasProperty($taxonomy_term_2_uri, 'http://www.w3.org/2000/01/rdf-schema#label', $expected_value), 'Taxonomy term name found in RDF output (rdfs:label).'); } - /** - * Create the taxonomy term reference field for testing. - * - * @param string $field_name - * The name of the field to create. - * @param \Drupal\taxonomy\Entity\Vocabulary $vocabulary - * The vocabulary that the field should use. - * - * @todo Move this to TaxonomyTestBase, like the other field modules. - */ - protected function createEntityReferenceField($field_name, $vocabulary) { - $handler_settings = array( - 'target_bundles' => array( - $vocabulary->id() => $vocabulary->id(), - ), - 'auto_create' => TRUE, - ); - $this->createEntityReferenceField('node', 'article', $field_name, 'Tags', 'taxonomy_term', 'default', $handler_settings, FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED); - - entity_get_form_display('node', 'article', 'default') - ->setComponent($field_name, array('type' => 'options_select')) - ->save(); - entity_get_display('node', 'article', 'full') - ->setComponent($field_name, array('type' => 'entity_reference_label')) - ->save(); - } - } diff --git a/core/modules/taxonomy/taxonomy.module b/core/modules/taxonomy/taxonomy.module index 921361d..112521f 100644 --- a/core/modules/taxonomy/taxonomy.module +++ b/core/modules/taxonomy/taxonomy.module @@ -62,18 +62,19 @@ function taxonomy_help($route_name, RouteMatchInterface $route_match) { $output .= '