Add Migrate module support

Created on 7 September 2012, about 12 years ago
Updated 12 September 2024, 2 months ago

For the Drupal 7 version, we should add a url.migrate.inc file that includes url_migrate_api() and a migration field handler for url fields.

✨ Feature request
Status

Needs review

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States dave reid Nebraska USA

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡§πŸ‡ͺBelgium hansrossel

    Some changes for #13 to make it work in Drupal 10: Plugin folder should be capitalized, Url.php also with capitals and namespace is needed. See zip attached with the full module, just enable, rollback the failing migration and reimport.

    namespace Drupal\custom_url_migrate\Plugin\migrate\field;
    
    use Drupal\migrate\Plugin\MigrationInterface;
    use Drupal\migrate_drupal\Plugin\migrate\field\FieldPluginBase;
    
    /**
     * Defines a URL field migration plugin.
     *
     * @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',
            'title' => 'title', // Assuming that the URL field may have an optional title
            'options' => 'options', // For any additional options that might be attached to the link
          ],
        ];
        $migration->setProcessOfProperty($field_name, $process);
      }
    
    }
    
    
Production build 0.71.5 2024