public function OgVocabMigrate::__construct in OG Vocabulary 7
General initialization of a Migration object.
Overrides DynamicMigration::__construct
File
- includes/
migrate/ og_vocab.migrate.inc, line 21 - Migrate plugin to populate the OG vocabulary field by the term references.
Class
- OgVocabMigrate
- @file Migrate plugin to populate the OG vocabulary field by the term references.
Code
public function __construct(array $arguments) {
$this->arguments = $arguments;
parent::__construct();
$this->bundle = $bundle = $arguments['bundle'];
$this->description = t('Populate the OG vocabulary field by the term references.');
// Indicate we're updating existing data.
$this->systemOfRecord = Migration::DESTINATION;
$this->fieldNames = $this
->getTaxonomyFields();
$query = db_select('node', 'n')
->fields('n')
->condition('n.type', $bundle)
->orderBy('n.nid');
if (empty($this->fieldNames)) {
// Falsify the query.
$query
->condition('n.nid', 0, '=');
}
$this->query = $query;
$key = array(
'nid' => array(
'type' => 'int',
'not null' => TRUE,
),
);
$this->map = new MigrateSQLMap($this->machineName, $key, MigrateDestinationNode::getKeySchema());
// Create a MigrateSource object, which manages retrieving the input data.
$this->source = new MigrateSourceSQL($this->query);
$this->destination = new MigrateDestinationNode($bundle);
if (empty($this->fieldNames)) {
return;
}
$this
->addFieldMapping('nid', 'nid');
$this
->addFieldMapping(OG_VOCAB_FIELD, OG_VOCAB_FIELD);
}