Advertisement
Guest User

Untitled

a guest
Nov 18th, 2014
375
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. class ParagraphsMigration extends XMLMigration {
  2. public function __construct($arguments) {
  3.  
  4. $group = MigrateGroup::getInstance($arguments['group_name']);
  5. // pass $group instead of $arguments
  6. parent::__construct($group);
  7.  
  8. //Fields
  9. $fields = array(
  10. 'field_name' => '',
  11. 'field_paragraph_body' => '',
  12. 'field_paragraph_title' => '',
  13. 'language' => '',
  14. );
  15. $xml_folder = DRUPAL_ROOT . '/' . drupal_get_path('module', 'migrate_dutchculture') . '/xml/';
  16. $items_url = $xml_folder . 'paragraph.xml';
  17. $item_xpath = '/paragraphs/item'; // relative to document
  18. $item_ID_xpath = 'id'; // relative to item_xpath and gets assembled
  19. // into full path /producers/producer/sourceid
  20.  
  21. $items_class = new MigrateItemsXML($items_url, $item_xpath, $item_ID_xpath);
  22. $this->source = new MigrateSourceMultiItems($items_class, $fields);
  23.  
  24. $this->destination = new MigrateDestinationParagraphsItem('text');
  25.  
  26. $this->map = new MigrateSQLMap(
  27. $this->machineName,
  28. array(
  29. 'id' => array(
  30. 'type' => 'int',
  31. 'unsigned' => TRUE,
  32. 'not null' => TRUE,
  33. )
  34. ),
  35. MigrateDestinationParagraphsItem::getKeySchema()
  36. );
  37.  
  38. $this->addSimpleMappings(array('field_name', 'field_paragraph_body','field_paragraph_title'));
  39. $this->addFieldMapping('archived')->defaultValue(TRUE);
  40. $this->addFieldMapping('field_paragraph_body:format')->defaultValue("filtered html");
  41. $this->addFieldMapping('field_paragraph_body:language', 'language');
  42. $this->addFieldMapping('field_paragraph_title:language', 'language');
  43.  
  44. }
  45.  
  46. function addSimpleMappings(array $simplemap)
  47. {
  48. foreach($simplemap as $item)
  49. {
  50. $this->addFieldMapping($item, $item)->xpath($item);
  51. }
  52. }
  53.  
  54. function addForeignKey($destination, $source, $dependency) {
  55.  
  56. $this->dependencies[] = $dependency;
  57. $this->addFieldMapping($destination, $source)
  58. ->xpath($source)
  59. ->sourceMigration($dependency);
  60. }
  61.  
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement