phone.migrate.inc 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. /**
  3. * @file phone.migrate.inc
  4. * Code to implement hook_content_migrate_field_alter, content_migrate_instance_alter() and content_migrate_data_record_alter()
  5. * on behalf of the former phone module, moved into a separate file for efficiency.
  6. */
  7. /**
  8. * Implements hook_content_migrate_field_alter().
  9. *
  10. * Use this to tweak the conversion of field settings
  11. * from the D6 style to the D7 style for specific
  12. * situations not handled by basic conversion,
  13. * as when field types or settings are changed.
  14. */
  15. function phone_field_alter(&$field_value, $instance_value) {
  16. if (substr($field_value['type'], 2) === '_phone') {
  17. $code = substr($field_value['type'], 0, 2);
  18. $field_value['type'] = 'phone';
  19. $field_value['settings']['country'] = $code;
  20. }
  21. }
  22. /**
  23. * Implements hook_migrate_api().
  24. */
  25. function phone_migrate_api() {
  26. return array('api' => 2);
  27. }
  28. /**
  29. * Wrap Migrate's simple field handler for 'phone' fields.
  30. */
  31. class MigratePhoneFieldHandler extends MigrateSimpleFieldHandler {
  32. public function __construct() {
  33. $this->registerTypes(array('phone'));
  34. }
  35. }