1

I have run migration using drush migrate-upgrade by setting up Drupal 7 used module in Drupal 8 site and DB path etc. But one of my content type use field https://www.drupal.org/project/url but now link field is in Drupa 8 and version of this module is not available in Drupal 8.

In support I have gone thorugh https://www.drupal.org/project/url/issues/1778224 but didn't helped much.

How I can transfer data along with revisions data related to this field and create/migrate similar field in Drupal 8 content type (rest of fields got migrated in 8 from 7)?

2
  • 1
    Possible duplicate of Migrating link fields to Drupal 8
    – Shawn Conn
    Feb 27, 2018 at 8:35
  • yes it seems smilier but I need help for related explanation ie: is that possible to migrate without custom solution. Or there is need to create some custom solution to migrate such data, if so any tutorial links or explanation will be helpful.
    – jas
    Feb 27, 2018 at 8:39

2 Answers 2

1

Have to create solution based on https://www.drupal.org/docs/8/api/migrate-api/writing-migrations-for-contributed-and-custom-modules#field-migrations

enter image description here

<?php

namespace Drupal\custom_url_migrate\plugin\migrate\field;

use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\migrate_drupal\Plugin\migrate\field\FieldPluginBase;

/**
 * @MigrateField(
 * id = "url",
 * core = {7},
 * type_map = {
 * "url" = "link"
 * },
 * source_module = "url",
 * destination_module = "link"
 * )
 */
class url extends FieldPluginBase {

  /**
   * {@inheritdoc}
   */
  public function getFieldWidgetMap() {
    return [
      'url' => 'link',
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function getFieldFormatterMap() {
    return [
     //'default' => 'link',
      //'url' => 'link',
      'url_external' => 'link',
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function processFieldValues(MigrationInterface $migration, $field_name, $data) {
    $process = [
      'plugin' => 'sub_process',
      'source' => $field_name,
      'process' => [
        'uri' => 'value',
      ],
    ];
    $migration->setProcessOfProperty($field_name, $process);
  }

}
0

There is also now a contrib module for the URL to Link migration: https://www.drupal.org/project/migrate_url2link

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.