diff --git c/composer.json w/composer.json index ac7fd46..df08b1d 100644 --- c/composer.json +++ w/composer.json @@ -1,7 +1,7 @@ { "name": "drupal/webform_migrate", "type": "drupal-module", - "description": "Migration routines from d6 webform to d8 webform", + "description": "Migration routines from d6 or d7 webform to d8 webform", "keywords": ["Drupal"], "license": "GPL-2.0+", "homepage": "https://www.drupal.org/project/webform_migrate", diff --git c/migrations/d7_yamlform.yml w/migrations/d7_webform.yml similarity index 96% rename from migrations/d7_yamlform.yml rename to migrations/d7_webform.yml index 9322bfe..807ccd7 100644 --- c/migrations/d7_yamlform.yml +++ w/migrations/d7_webform.yml @@ -1,12 +1,12 @@ -id: d7_yamlform -label: 'YAML Form (webform)' +id: d7_webform +label: 'Webform' migration_tags: - 'Drupal 7' migration_group: migrate_drupal_7 source: plugin: d7_webform process: - id: yaml_id + id: wf_id uid: node_uid title: title status: status @@ -69,7 +69,7 @@ process: 'settings/results_disabled': {} 'settings/token_update': {} destination: - plugin: 'entity:yamlform' + plugin: 'entity:webform' migration_dependencies: required: - d7_user_role diff --git c/migrations/d7_yamlform_submission.yml w/migrations/d7_webform_submission.yml similarity index 73% rename from migrations/d7_yamlform_submission.yml rename to migrations/d7_webform_submission.yml index f0c2521..f6a8f18 100644 --- c/migrations/d7_yamlform_submission.yml +++ w/migrations/d7_webform_submission.yml @@ -1,5 +1,5 @@ -id: d7_yamlform_submission -label: 'YAML Form Submission (webform)' +id: d7_webform_submission +label: 'Webform Submission' migration_tags: - 'Drupal 7' migration_group: migrate_drupal_7 @@ -7,8 +7,8 @@ source: plugin: d7_webform_submission process: sid: sid - yamlform_id: yaml_id - uri: yaml_uri + webform_id: wf_id + uri: wf_uri created: submitted completed: submitted changed: submitted @@ -26,9 +26,9 @@ process: sticky: {} notes: {} serial: {} - data: yaml_data + data: wf_data destination: - plugin: 'entity:yamlform_submission' + plugin: 'entity:webform_submission' migration_dependencies: required: - - d7_yamlform + - d7_webform diff --git c/src/Plugin/migrate/source/d7/Webform.php w/src/Plugin/migrate/source/d7/Webform.php index e39ee64..51a0a8b 100644 --- c/src/Plugin/migrate/source/d7/Webform.php +++ w/src/Plugin/migrate/source/d7/Webform.php @@ -1,6 +1,6 @@ $this->t('Automatic save'), 'total_submit_limit' => $this->t('Total submission limit'), 'total_submit_interval' => $this->t('Total submission interval'), - 'yaml_id' => $this->t('Id to be used for YAML form'), - 'elements' => $this->t('Elements for the YAML form'), + 'wf_id' => $this->t('Id to be used for the Webform entity'), + 'elements' => $this->t('Elements for the form'), ); return $fields; } @@ -139,7 +139,7 @@ public function prepareRow(Row $row) { $row->setSourceProperty('elements', $elements); $row->setSourceProperty('handlers', $handlers); $row->setSourceProperty('access', $access); - $row->setSourceProperty('yaml_id', 'webform_' . $nid); + $row->setSourceProperty('wf_id', 'webform_' . $nid); return parent::prepareRow($row); } @@ -453,7 +453,7 @@ private function buildEmailHandlers($nid, $xref) { $id = 'email_' . $email['eid']; foreach (array('email', 'subject', 'from_name', 'from_address') as $field) { if (!empty($email[$field]) && is_numeric($email[$field]) && !empty($xref[$email[$field]])) { - $email[$field] = "[yamlform-submission:values:{$xref[$email[$field]]}:raw]"; + $email[$field] = "[webform-submission:values:{$xref[$email[$field]]}:raw]"; } } $excluded = array(); @@ -583,29 +583,29 @@ public function preImport(MigrateImportEvent $event) {} * {@inheritdoc} */ public function postImport(MigrateImportEvent $event) { - // Add the YAMLform field to the webform content type + // Add the Webform reference field to the webform content type // if it doesn't already exist. - $field_storage = FieldStorageConfig::loadByName('node', 'yamlform'); - $field = FieldConfig::loadByName('node', 'webform', 'yamlform'); + $field_storage = FieldStorageConfig::loadByName('node', 'webform'); + $field = FieldConfig::loadByName('node', 'webform', 'webform'); if (empty($field)) { $field = entity_create('field_config', array( 'field_storage' => $field_storage, 'bundle' => 'webform', - 'label' => 'YAML form', + 'label' => 'Webform', 'settings' => array(), )); $field->save(); // Assign widget settings for the 'default' form mode. - $display = entity_get_form_display('node', 'yamlform', 'default')->getComponent('yamlform'); + $display = entity_get_form_display('node', 'webform', 'default')->getComponent('webform'); entity_get_form_display('node', 'webform', 'default') - ->setComponent('yamlform', array( + ->setComponent('webform', array( 'type' => $display['type'], )) ->save(); // Assign display settings for the 'default' and 'teaser' view modes. - $display = entity_get_display('node', 'yamlform', 'default')->getComponent('yamlform'); + $display = entity_get_display('node', 'webform', 'default')->getComponent('webform'); entity_get_display('node', 'webform', 'default') - ->setComponent('yamlform', array( + ->setComponent('webform', array( 'label' => $display['label'], 'type' => $display['type'], )) @@ -614,9 +614,9 @@ public function postImport(MigrateImportEvent $event) { // might not exist. $view_modes = \Drupal::entityManager()->getViewModes('node'); if (isset($view_modes['teaser'])) { - $display = entity_get_display('node', 'yamlform', 'teaser')->getComponent('yamlform'); + $display = entity_get_display('node', 'webform', 'teaser')->getComponent('webform'); entity_get_display('node', 'webform', 'teaser') - ->setComponent('yamlform', array( + ->setComponent('webform', array( 'label' => $display['label'], 'type' => $display['type'], )) @@ -624,18 +624,19 @@ public function postImport(MigrateImportEvent $event) { } } - // Attach any YAML forms created to the relevant webforms if - // YAML form exists and Webform exists and YAML form field is empty. + // Attach any Webform forms created to the relevant webform nodes if + // the Webform form exists and Webform exists and webform form field + // is empty. $webforms = $this->query()->execute(); foreach ($webforms as $webform) { - $yamlform_id = 'webform_' . $webform['nid']; - $yamlform = YamlForm::load($yamlform_id); - if (!empty($yamlform)) { + $webform_id = 'webform_' . $webform['nid']; + $webform_entity = EntityWebform::load($webform_id); + if (!empty($webform_entity)) { $node = Node::load($webform['nid']); if (!empty($node) && $node->getType() == 'webform') { - if (empty($node->yamlform->target_id)) { - $node->yamlform->target_id = $yamlform_id; - $node->yamlform->status = 1; + if (empty($node->webform->target_id)) { + $node->webform->target_id = $webform_id; + $node->webform->status = 1; $node->save(); } } @@ -653,16 +654,16 @@ public function preRollback(MigrateRollbackEvent $event) {} * {@inheritdoc} */ public function postRollback(MigrateRollbackEvent $event) { - // Remove any YAML forms from webform if yamlform no longer exists. + // Remove any Webform forms from webform nodes if webform no longer exists. $webforms = $this->query()->execute(); foreach ($webforms as $webform) { - $yamlform_id = 'webform_' . $webform['nid']; - $yamlform = YamlForm::load($yamlform_id); - if (empty($yamlform)) { + $webform_id = 'webform_' . $webform['nid']; + $webform_entity = EntityWebform::load($webform_id); + if (empty($webform_entity)) { $node = Node::load($webform['nid']); if (!empty($node) && $node->getType() == 'webform') { - if (!empty($node->yamlform->target_id) && $node->yamlform->target_id == $yamlform_id) { - $node->yamlform->target_id = NULL; + if (!empty($node->webform->target_id) && $node->webform->target_id == $webform_id) { + $node->webform->target_id = NULL; $node->save(); } } diff --git c/src/Plugin/migrate/source/d7/WebformSubmission.php w/src/Plugin/migrate/source/d7/WebformSubmission.php index cb2a358..f35c140 100644 --- c/src/Plugin/migrate/source/d7/WebformSubmission.php +++ w/src/Plugin/migrate/source/d7/WebformSubmission.php @@ -1,6 +1,6 @@ $this->t('Submission timestamp'), 'remote_addr' => $this->t('IP Address of submitter'), 'is_draft' => $this->t('Whether this submission is draft'), - 'yaml_id' => $this->t('Id to be used for YAML form'), - 'yaml_data' => $this->t('YAML form submitted data'), - 'yaml_uri' => $this->t('Submission uri'), + 'wf_id' => $this->t('Id to be used for the Webform entity'), + 'wf_data' => $this->t('Webform submitted data'), + 'wf_uri' => $this->t('Submission uri'), ); return $fields; } @@ -57,9 +57,9 @@ public function prepareRow(Row $row) { $nid = $row->getSourceProperty('nid'); $sid = $row->getSourceProperty('sid'); $submitted_data = $this->buildSubmittedData($sid); - $row->setSourceProperty('yaml_id', 'webform_' . $nid); - $row->setSourceProperty('yaml_data', $submitted_data); - $row->setSourceProperty('yaml_uri', '/form/webform-' . $nid); + $row->setSourceProperty('wf_id', 'webform_' . $nid); + $row->setSourceProperty('wf_data', $submitted_data); + $row->setSourceProperty('wf_uri', '/form/webform-' . $nid); return parent::prepareRow($row); } @@ -73,7 +73,7 @@ public function getIds() { } /** - * Build submitted data from webform submitted data table + * Build submitted data from webform submitted data table. */ private function buildSubmittedData($sid) { $query = $this->select('webform_submitted_data', 'wfsd');