Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ParagraphsMigration extends XMLMigration {
- public function __construct($arguments) {
- $group = MigrateGroup::getInstance($arguments['group_name']);
- // pass $group instead of $arguments
- parent::__construct($group);
- //Fields
- $fields = array(
- 'field_name' => '',
- 'field_paragraph_body' => '',
- 'field_paragraph_title' => '',
- 'language' => '',
- );
- $xml_folder = DRUPAL_ROOT . '/' . drupal_get_path('module', 'migrate_dutchculture') . '/xml/';
- $items_url = $xml_folder . 'paragraph.xml';
- $item_xpath = '/paragraphs/item'; // relative to document
- $item_ID_xpath = 'id'; // relative to item_xpath and gets assembled
- // into full path /producers/producer/sourceid
- $items_class = new MigrateItemsXML($items_url, $item_xpath, $item_ID_xpath);
- $this->source = new MigrateSourceMultiItems($items_class, $fields);
- $this->destination = new MigrateDestinationParagraphsItem('text');
- $this->map = new MigrateSQLMap(
- $this->machineName,
- array(
- 'id' => array(
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
- )
- ),
- MigrateDestinationParagraphsItem::getKeySchema()
- );
- $this->addSimpleMappings(array('field_name', 'field_paragraph_body','field_paragraph_title'));
- $this->addFieldMapping('archived')->defaultValue(TRUE);
- $this->addFieldMapping('field_paragraph_body:format')->defaultValue("filtered html");
- $this->addFieldMapping('field_paragraph_body:language', 'language');
- $this->addFieldMapping('field_paragraph_title:language', 'language');
- }
- function addSimpleMappings(array $simplemap)
- {
- foreach($simplemap as $item)
- {
- $this->addFieldMapping($item, $item)->xpath($item);
- }
- }
- function addForeignKey($destination, $source, $dependency) {
- $this->dependencies[] = $dependency;
- $this->addFieldMapping($destination, $source)
- ->xpath($source)
- ->sourceMigration($dependency);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement