You are here

public function BiblioMigrateContributorCollections::__construct in Bibliography Module 7.3

General initialization of a Migration object.

Overrides Migration::__construct

File

includes/migrate/7300/biblio_contributor_collections.migrate.inc, line 8

Class

BiblioMigrateContributorCollections
@file

Code

public function __construct($arguments = array()) {
  $this->description = t('Migrate biblio 1.x contributors into field collections.');
  $entity_info = entity_get_info('biblio');
  $machine_names = array();
  foreach (array_keys($entity_info['bundles']) as $bundle_name) {
    $machine_names[] = 'BiblioMigrateEntries_' . $bundle_name;
  }
  $this->dependencies = $machine_names;

  // Fetch the used contributor types.
  $this->query = db_select('_biblio_contributor_1x', 'c');
  $this->query
    ->innerJoin('_biblio_contributor_type_data_1x', 'ctd', 'c.auth_type = ctd.auth_type');
  $this->query
    ->fields('c', array(
    'nid',
    'cid',
    'auth_type',
  ));
  $this->query
    ->addField('ctd', 'title', 'role');
  parent::__construct($arguments);
  $source_key = array(
    'nid' => array(
      'type' => 'int',
      'not null' => TRUE,
    ),
    'cid' => array(
      'type' => 'int',
      'not null' => TRUE,
    ),
    'auth_type' => array(
      'type' => 'int',
      'not null' => TRUE,
      'alias' => 'ctd',
    ),
  );
  $this->map = new MigrateSQLMap($this->machineName, $source_key, BiblioMigrateDestinationFieldCollection::getKeySchema());
  $this->source = new MigrateSourceSQL($this->query);
  $this->destination = new BiblioMigrateDestinationFieldCollection('contributor_field_collection', array(
    'host_entity_type' => 'biblio',
  ));
  $this
    ->addFieldMapping('host_entity_id', 'nid')
    ->sourceMigration($machine_names);
  $this
    ->addFieldMapping('biblio_contributor', 'cid');
  $this
    ->addFieldMapping('biblio_contributor_role', 'role');
  $this->roles_vocabulary = taxonomy_vocabulary_machine_name_load('biblio_roles');
}