I am trying to follow the guidance from https://www.drupal.org/node/1819738 "Extending migrate_d2d classes". I am using the Migrate d2d UI. It brings back the nodes I want to migrate, but there are a couple of fields I need to add. Essentially I want to extend the DrupalNode6Migration class to add these fields to the source query used by the UI.
I created this class (which appears to be exactly like the example given in the d2d document above):
<?php
class CadeMigrateFields extends DrupalNode6Migration {
public function __construct(array $arguments) {
parent::__construct($arguments);
}
protected function query() {
// Get the default query
$query = parent::query();
// Get OG stuff as per: https://www.drupal.org/node/2033293#comment-9371471
$query->leftJoin('og_ancestry','oga','n.nid = oga.nid');
$query->addExpression('GROUP_CONCAT(DISTINCT og.group_nid)', 'og_group_ref');
$query->addField('oga', 'group_nid', 'gid');
$query->addField('oga', 'is_public', 'is_public');
return $query;
}
}
?>
This is supposed to include the additinal fields I want in the parent query. I added the path to this file to my module.info file:
; Migrate from 6.x to 7.x
files[] = cade_fields.migrate.inc
My question is: How do I declare it in the Migrate api so that Migrate sees it and executes it correctly?
If I don't add it anywhere in the api, Migrate doesn't see it. It is ignored and doesn't work.
If I code it as a migration,
$migrations = array();
$migrations['CadeFields'] = array(
'class_name' => 'CadeMigrateFields',
);
$api = array(
'api' => 2,
'migrations' => $migrations,
);
return $api;
I get errors saying that several arguments (source type, description, destination type, etct) are missing. And it still doesn't work. This missing information should be provided by the arguments passed to the parent query (created by DrupalNode6Migration) by the UI, whose query I am simply trying to extend, not override.
So, how do I declare this type of class so that:
- Migrate (d2d) sees it?
- Migrate passes the arguments from the parent class (created by UI) it is extending to it?
- It extends the parent class query to include the desired fields?
Thanks so much for any assistance!