migrate_extras_profile2.migrate.inc 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /**
  3. * @file
  4. * Examples and test fodder for migration into profile2 entities.
  5. */
  6. /**
  7. * Migration class to test import of various date fields.
  8. */
  9. class MigrateExampleProfile2Migration extends Migration {
  10. public function __construct() {
  11. parent::__construct();
  12. $this->description = t('Example migration into profile2 entities');
  13. $this->map = new MigrateSQLMap($this->machineName,
  14. array(
  15. 'id' => array(
  16. 'type' => 'int',
  17. 'unsigned' => TRUE,
  18. 'not null' => TRUE,
  19. )
  20. ),
  21. MigrateDestinationProfile2::getKeySchema()
  22. );
  23. // Our test data is in a CSV file
  24. $this->source = new MigrateSourceCSV(__DIR__ . '/migrate_extras_profile2.csv', $this->csvcolumns(), array(), $this->fields());
  25. $this->destination = new MigrateDestinationProfile2('migrate_extras_profile2');
  26. $this->addFieldMapping('uid')
  27. ->defaultValue(1);
  28. // Unmapped destination fields
  29. $this->addUnmigratedDestinations(array('id'));
  30. }
  31. function csvcolumns() {
  32. $columns[0] = array('id', 'Source ID');
  33. $columns[1] = array('uid', 'User ID');
  34. return $columns;
  35. }
  36. function fields() {
  37. return array(
  38. 'id' => 'Source ID',
  39. 'uid' => 'User ID',
  40. );
  41. }
  42. }