You are here

class MigrateCckPhoneHandler in Migrate Extras 6.2

Same name and namespace in other branches
  1. 7.2 cck_phone.inc \MigrateCckPhoneHandler

Primary value passed to this field must be the two letter ISO country code of the phone number.

Arguments are used to specify all the other values: 'number' - The actual phone number. 'extension' - The extension.

Add the source field mappings to the argument array then add null mappings to avoid having fields flagged as unmapped:

$arguments = array(
  'number' => array(
    'source_field' => 'phone_number',
  ),
  'extension' => array(
    'source_field' => 'profile_phone_ext',
  ),
);

// The country should be passed in as the primary value.
$this
  ->addFieldMapping('field_user_phone', 'profile_country')
  ->arguments($arguments);

// Since the excerpt is mapped via an argument, add a null mapping so it's
// not flagged as unmapped.
$this
  ->addFieldMapping(NULL, 'profile_phone_number');
$this
  ->addFieldMapping(NULL, 'profile_phone_ext');

Hierarchy

Expanded class hierarchy of MigrateCckPhoneHandler

1 string reference to 'MigrateCckPhoneHandler'
migrate_extras_migrate_api in ./migrate_extras.module

File

./cck_phone.inc, line 27

View source
class MigrateCckPhoneHandler extends MigrateFieldHandler {
  public function __construct() {
    $this
      ->registerTypes(array(
      'phone_number',
    ));
  }
  static function arguments($number = '', $extension = '') {
    return array(
      'number' => $number,
      'extension' => $extension,
    );
  }
  public function prepare($entity, array $instance, array $values) {
    $arguments = array();
    if (isset($values['arguments'])) {
      $arguments = array_filter($values['arguments']);
      unset($values['arguments']);
    }

    // Setup the standard Field API array for saving.
    $delta = 0;
    foreach ($values as $value) {
      $return[$delta]['country_codes'] = drupal_strtolower($value);
      $return[$delta]['number'] = isset($arguments['number']) ? $arguments['number'] : '';
      $return[$delta]['extension'] = isset($arguments['extension']) ? $arguments['extension'] : '';
      $delta++;
    }
    return isset($return) ? $return : NULL;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
MigrateCckPhoneHandler::arguments static function
MigrateCckPhoneHandler::prepare public function
MigrateCckPhoneHandler::__construct public function Overrides MigrateHandler::__construct
MigrateHandler::$dependencies protected property List of other handler classes which should be invoked before the current one.
MigrateHandler::$typesHandled protected property List of "types" handled by this handler. Depending on the kind of handler, these may be destination types, field types, etc.
MigrateHandler::getDependencies public function
MigrateHandler::getTypesHandled public function
MigrateHandler::handlesType public function Does this handler handle the given type?
MigrateHandler::registerTypes protected function Register a list of types handled by this class