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 .= '
' . t('Managing terms') . '
'; $output .= '
' . t('Users who have the Administer vocabularies and terms permission or the Edit terms permission for a particular vocabulary can add, edit, and organize the terms in a vocabulary from a vocabulary\'s term listing page, which can be accessed by going to the Taxonomy administration page and clicking List terms in the Operations column. Users must have the Administer vocabularies and terms permission or the Delete terms permission for a particular vocabulary to delete terms.' , array('!taxonomy_admin' => \Drupal::url('entity.taxonomy_vocabulary.collection'))) . '
'; $output .= '
' . t('Classifying entity content') . '
'; - $output .= '
' . t('A user with the Administer fields permission for a certain entity type may add reference fields to the entity, which will allow entities to be classified using taxonomy terms. See the Field module help and the Field UI help pages for general information on fields and how to create and manage them.' , array('!field_ui' => $field_ui_url, '!field' => \Drupal::url('help.page', array('name' => 'field')))) . '
'; + $output .= '
' . t('A user with the Administer fields permission for a certain entity type may add Entity reference fields to the entity, which will allow entities to be classified using taxonomy terms. See the Field module help and the Field UI help pages for general information on fields and how to create and manage them.' , array('!field_ui' => $field_ui_url, '!field' => \Drupal::url('help.page', array('name' => 'field')))) . '
'; $output .= '
' . t('Adding new terms during content creation') . '
'; - $output .= '
' . t('Allowing users to add new terms gradually builds a vocabulary as content is added and edited. Users can add new terms if either of the two Autocomplete widgets is chosen for an Entity reference field. You will also need to enable the Create referenced entity option, and restrict the field to one vocabulary.') . '
'; - $output .= '
' . t('Configuring displays and form displays ') . '
'; - $output .= '
' . t('The reference fields have several formatters and widgets available on the Manage display and Manage form display pages, respectively:'); + $output .= '
' . t('Allowing users to add new terms gradually builds a vocabulary as content is added and edited. Users can add new terms if either of the two Autocomplete widgets is chosen for the Entity reference field. You will also need to enable the Create referenced entities if they don\'t already exist option, and restrict the field to one vocabulary.') . '
'; + $output .= '
' . t('Configuring displays and form displays') . '
'; + $output .= '
' . t('The reference field have several formatters and widgets available on the Manage display and Manage form display pages, respectively:'); $output .= ''; $output .= '
';