1

I am having trouble creating and registering migrate modules. At the moment, when I go to the UI screen, it says 'Class X no longer exists' (so, at least its being picked up) and wont show in the list of migrations on the page. At the moment, I have only implemented one class and had this issue (when I figure this out, I will create everything else). Here is my code:

function migrate_rcmd_migrate_api() {
  $api = array(
    'api' => 2,
    'groups' => array(
      'Test' => array(
        'title' => t('Test Migrations'),
      ),
    ),
    'migrations' => array(
      'EventNode' => array(
        'class_name' => 'EventNodeMigration',
        'group_name' => 'Test',
      ),
      'CareerNode' => array(
        'class_name' => 'CareerNodeMigration',
        'group_name' => 'Test',
      ),
      'NodeRegistrationEntity' => array(
        'class_name' => 'NodeRegistrationEntityMigration',
        'group_name' => 'Test',
      ),
      'JobPostingEntity' => array(
        'class_name' => 'JobPostingEntityMigration',
        'group_name' => 'Test',
      ),
      'CoverLetterFileEntity' =>array(  //may only need one file entity migration class
        'class_name' => 'CoverLetterFileEntityMigration',
        'group_name' => 'Test',
      ),
      'ResumeFileEntity' => array(
        'class_name' => 'ResumeFileEntityMigration',
        'group_name' => 'Test',
      ),
    ),
  );
  return $api;
}

and

abstract class Test_Migration extends DynamicMigration {
  public function __construct() {
    // Always call the parent constructor first for basic setup
    parent::__construct();

    // With migrate_ui enabled, migration pages will indicate people involved in
    // the particular migration, with their role and contact info. We default the
    // list in the shared class; it can be overridden for specific migrations.
    $this->team = array(
      new MigrateTeamMember('Liz Taster', 'ltaster@example.com', t('Product Owner')),
      new MigrateTeamMember('Larry Brewer', 'lbrewer@example.com', t('Implementor')),
    );

    // Individual mappings in a migration can be linked to a ticket or issue
    // in an external tracking system. Define the URL pattern here in the shared
    // class with ':id:' representing the position of the issue number, then add
    // ->issueNumber(1234) to a mapping.
    $this->issuePattern = 'http://drupal.org/node/:id:';
  }
}

class EventNodeMigration extends Test_Migration {
  public function __construct($arguments) {
    parent::__construct($arguments);
    //WE WILL NEED THIS
    //$this->dependencies = array('BeerTerm', 'BeerUser');

    $this->map = new MigrateSQLMap($this->machineName,
      array(
        'nid' => array(
          'type' => 'int',
          'not null' => TRUE,
          'description' => 'The primary identifier for a node.',
          'alias' => 'n',
        )
      ),
      MigrateDestinationNode::getKeySchema()
    );
    //example
    $query = Database::getConnection('default', 'legacy')
             ->select('node', 'n')
             ->fields('n', array('nid','vid','type','language','title','uid','status','created', 'changed','comment','promote','sticky','tnid','translate','uuid'))
              ->condition('type', 'events','=');
              //ADD JOINS TO FIELD TABLES HERE
    $this->source = new MigrateSourceSQL($query);
    $this->destination = new MigrateDestinationNode('events');

    $this->addSimpleMappings(array('nid','vid','type','language','title','uid','status','created', 'changed','comment','promote','sticky','tnid','translate','uuid'));
    //$this->addFieldMapping('title', 'page_title');
    //$this->addFieldMapping('body', 'page_body');
  }
} 

closed as unclear what you're asking by kiamlaluno Nov 26 '16 at 6:27

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

1

Be sure:

  1. your migrate_rcmd_migrate_api function is in the file migrate_rcmd.migrate.inc.
  2. your Classes are included in .inc files defined in your modules .info file. See this documentation page on Migrate: https://drupal.org/node/1006982
  3. Lastly in Migrate > 2.5 (i think thats the right version) migration auto discovery is now gone. You can use drush migrate-register to register your migrations and classes. See drush help migrate-register as needed.
  4. when in doubt clear your caches: drush cc all to be sure the .inc files are registered in drupals code registry.
  • I think I've done all that. This is what I have in the .info file: files[] = migrate_rcmd.migrate.inc files[] = rcmd_migration.inc -- the hook api is in the first file and the class in the second. And actually, for #3, it says that automatic discovery is on – user1015214 Apr 3 '14 at 21:22
  • Thanks @tenken, 3. drush mreg did the trick for me – baikho Dec 6 '17 at 23:51
-1

Add this code your module hook_enable().

/**
* Implements hook_enable().
*/
function MODULENAME_enable() {
  Migration::registerMigration('MigrationClassName');
  $migration = Migration::getInstance('MigrationClassName');
  $result = $migration->processImport();
}

Not the answer you're looking for? Browse other questions tagged or ask your own question.