migrate_extras_pathauto.migrate.inc 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /**
  3. * @file
  4. * Examples and test fodder for migration with Pathauto enabled.
  5. */
  6. /**
  7. * Migration class to test import with Pathauto enabled.
  8. */
  9. class MigrateExamplePathautoMigration extends XMLMigration {
  10. public function __construct() {
  11. parent::__construct();
  12. $this->description = t('Example migration with Pathauto enabled');
  13. $this->map = new MigrateSQLMap($this->machineName,
  14. array(
  15. 'id' => array(
  16. 'type' => 'int',
  17. 'unsigned' => TRUE,
  18. 'not null' => TRUE,
  19. 'description' => 'Pathauto ID',
  20. )
  21. ),
  22. MigrateDestinationNode::getKeySchema()
  23. );
  24. // Source fields available in the XML file.
  25. $fields = array(
  26. 'id' => t('Source id'),
  27. 'title' => t('Title'),
  28. 'body' => t('Description'),
  29. );
  30. // Our test data is in an XML file
  31. $xml_folder = drupal_get_path('module', 'migrate_extras_pathauto');
  32. $items_url = $xml_folder . '/migrate_extras_pathauto.xml';
  33. $item_xpath = '/source_data/item';
  34. $item_ID_xpath = 'id';
  35. $items_class = new MigrateItemsXML($items_url, $item_xpath, $item_ID_xpath);
  36. $this->source = new MigrateSourceMultiItems($items_class, $fields);
  37. $this->destination = new MigrateDestinationNode('migrate_example_pathauto');
  38. // Basic fields
  39. $this->addFieldMapping('title', 'title')
  40. ->xpath('title');
  41. $this->addFieldMapping('uid')
  42. ->defaultValue(1);
  43. $this->addFieldMapping('body', 'body')
  44. ->xpath('body');
  45. // Disable application of pathauto during migration
  46. $this->addFieldMapping('pathauto')
  47. ->defaultValue(FALSE);
  48. // Unmapped destination fields
  49. $this->addUnmigratedDestinations(array('is_new', 'status', 'promote',
  50. 'revision', 'language', 'sticky', 'created', 'changed', 'revision_uid',
  51. 'path'));
  52. }
  53. }