You are here

public function OgUiPopulateField::__construct in Organic groups 7.2

General initialization of a Migration object.

Overrides Migration::__construct

File

og_ui/includes/migrate/7000/populate_field.inc, line 15
Upgrade group visibility (e.g. open, moderated, closed) from OG6.

Class

OgUiPopulateField
@file Upgrade group visibility (e.g. open, moderated, closed) from OG6.

Code

public function __construct($arguments = array()) {
  parent::__construct($arguments);
  $bundle = $arguments['bundle'];
  $this->description = t('Upgrade group visibility (e.g. open, moderated, closed) from OG6.');
  $this->dependencies = array(
    'OgUiMigrateAddField',
  );
  $query = db_select('d6_og', 'og');
  $query
    ->innerJoin('node', 'n', 'og.nid = n.nid');
  $query
    ->fields('og')
    ->condition('n.type', $bundle)
    ->orderBy('n.nid');
  $this->query = $query;
  $source_key = MigrateDestinationNode::getKeySchema();

  // Set the alias, so the query in MigrateSourceSQL::performRewind()
  // will not fail.
  $source_key['nid']['alias'] = 'n';
  $this->map = new MigrateSQLMap($this->machineName, $source_key, MigrateDestinationNode::getKeySchema());
  $this->source = new MigrateSourceSQL($this->query);
  $this->destination = new MigrateDestinationNode($bundle);
  $this
    ->addFieldMapping('nid', 'nid');
  $this
    ->addFieldMapping(OG_DEFAULT_ACCESS_FIELD, NULL)
    ->defaultValue(TRUE);
}