class MigrateCckPhoneHandler in Migrate Extras 7.2
Same name and namespace in other branches
- 6.2 cck_phone.inc \MigrateCckPhoneHandler
Primary value passed to this field must be the two letter ISO country code of the phone number.
Subfields are used to specify all the other values: 'number' - The actual phone number. 'extension' - The extension.
// The country should be passed in as the primary value.
$this
->addFieldMapping('field_user_phone', 'profile_country');
$this
->addFieldMapping('field_user_phone:number', 'profile_number');
$this
->addFieldMapping('field_user_phone:extension', 'profile_extension');
Hierarchy
- class \MigrateHandler
- class \MigrateFieldHandler
- class \MigrateCckPhoneHandler
- class \MigrateFieldHandler
Expanded class hierarchy of MigrateCckPhoneHandler
1 string reference to 'MigrateCckPhoneHandler'
File
- ./
cck_phone.inc, line 18
View source
class MigrateCckPhoneHandler extends MigrateFieldHandler {
public function __construct() {
$this
->registerTypes(array(
'phone_number',
));
}
public function fields($type) {
return array(
'number' => t('Subfield: The phone number itself'),
'extension' => t('Extension: An optional extension'),
);
}
public function prepare($entity, array $field_info, array $instance, array $values) {
$arguments = array();
if (isset($values['arguments'])) {
$arguments = array_filter($values['arguments']);
unset($values['arguments']);
}
$language = $this
->getFieldLanguage($entity, $field_info, $arguments);
// Setup the standard Field API array for saving.
$delta = 0;
foreach ($values as $value) {
$return[$language][$delta] = array(
'country_codes' => drupal_strtolower($value),
);
if (isset($arguments['number'])) {
if (is_array($arguments['number'])) {
$return[$language][$delta]['number'] = $arguments['number'][$delta];
}
else {
$return[$language][$delta]['number'] = $arguments['number'];
}
}
if (isset($arguments['extension'])) {
if (is_array($arguments['extension'])) {
$return[$language][$delta]['extension'] = $arguments['extension'][$delta];
}
else {
$return[$language][$delta]['extension'] = $arguments['extension'];
}
}
$delta++;
}
return isset($return) ? $return : NULL;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
MigrateCckPhoneHandler:: |
public | function | ||
MigrateCckPhoneHandler:: |
public | function | ||
MigrateCckPhoneHandler:: |
public | function |
Overrides MigrateHandler:: |
|
MigrateFieldHandler:: |
function | Determine the language of the field. | ||
MigrateHandler:: |
protected | property | List of other handler classes which should be invoked before the current one. | |
MigrateHandler:: |
protected | property | List of "types" handled by this handler. Depending on the kind of handler, these may be destination types, field types, etc. | |
MigrateHandler:: |
public | function | ||
MigrateHandler:: |
public | function | ||
MigrateHandler:: |
public | function | Does this handler handle the given type? | 1 |
MigrateHandler:: |
protected | function | Register a list of types handled by this class |