Download & Extend

Support migration into phone fields

Project:Phone
Version:7.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:needs work

Issue Summary

This patch was pretty easy to write. How's it look? [Patch attached to first comment]

Comments

#1

AttachmentSize
migrate_extras.943140.patch 1.82 KB

#2

Status:needs review» needs work

How can this populate the title of each link. I see url but not title.

Not a big deal, but it may make sense to break these out into separate files so they match the module that defines the field.

#3

How can this populate the title of each link.

You tell me! (Seriously, please!) I have no idea how you're supposed to go importing two source fields into one destination field, or one source field into multiple destination fields.

#4

See #1004066: CCK Links migration for a link implementation that attempts to deal with the title using arguments.

#5

Title:Patch: Add CCK phone, email, link field support to 6.x-2.x» Support phone, email & link fields

I used this patch as a basis for a patch for Email field module to add support for Migrate: #1232028: Support for Migrate package

The only parts not covered by other issues that are mentioned here are;

  • Support for Phone fields (Phone has not yet been ported to D7 anyway)
  • Support for Drupal 6 for all of the above

I am tempted to mark this postponed or won't fix, but will leave that for the issue queue maintainer.

#6

Title:Support phone, email & link fields» Support phone fields

So two of the three modules have been taken care of:
#1010850: Update MigrateFieldHandler to work with migrate-7.x-2.4 and later
#1232028: Support for Migrate package

Lets reign this in... That said I Really like the idea of having an abstract class that we can use to simplify a lot of these one off fields.

#7

I took the idea of a base class from here re-rolled it as a patch against migrate: #1321062: Create a simple base class for field handlers

#8

I had previously (a month or two ago) been using the following block of code to allow migrate to use Phone as a destination field:

<?php
class MigratePhoneFieldHandler extends MigrateFieldHandler {
  public function
__construct() {
   
$this->registerTypes(array('phone'));
  }

  public function
prepare(stdClass $entity, array $field_info, array $instance, array $values) {
   
// Setup the Field API array for saving.                                                                                    
   
$arguments = (isset($values['arguments'])) ? $values['arguments']: array();
   
$language = $this->getFieldLanguage($entity, $field_info, $arguments);
   
$delta = 0;
    foreach (
$values as $value) {
     
$return[$language][$delta]['value'] = $value;
     
$delta++;
    }
    return isset(
$return) ? $return : NULL;
  }
}
?>

But as of today that code now throws errors:

trim() expects parameter 1 to be string, array given File [DRUPAL_ROOT]/sites/all/modules/contrib/phone/phone.module, line 371

I realize the Phone field module is still listed as -dev for 7.x but this used to work and any pointers on what I could change to make it work would be much appreciated.

#9

Title:Support phone fields» Support migration into phone fields
Project:Migrate Extras» Phone
Version:6.x-2.x-dev» 7.x-1.x-dev
Component:CCK» Code

Migration support for a contrib module best goes into that module.

nobody click here