You are here

public function RelationMigrateReference::__construct in Relation 7

Same name and namespace in other branches
  1. 8.2 relation_migrate/relation_migrate.migration.inc \RelationMigrateReference::__construct()
  2. 8 relation_migrate/relation_migrate.migration.inc \RelationMigrateReference::__construct()

Constructor.

Parameters

$field_type Field type machine name.:

Overrides Migration::__construct

4 calls to RelationMigrateReference::__construct()
RelationMigrateEntityReference::__construct in relation_migrate/relation_migrate.migration.inc
Constructor.
RelationMigrateNodeReference::__construct in relation_migrate/relation_migrate.migration.inc
Constructor.
RelationMigrateTermReference::__construct in relation_migrate/relation_migrate.migration.inc
Constructor.
RelationMigrateUserReference::__construct in relation_migrate/relation_migrate.migration.inc
Constructor.
4 methods override RelationMigrateReference::__construct()
RelationMigrateEntityReference::__construct in relation_migrate/relation_migrate.migration.inc
Constructor.
RelationMigrateNodeReference::__construct in relation_migrate/relation_migrate.migration.inc
Constructor.
RelationMigrateTermReference::__construct in relation_migrate/relation_migrate.migration.inc
Constructor.
RelationMigrateUserReference::__construct in relation_migrate/relation_migrate.migration.inc
Constructor.

File

relation_migrate/relation_migrate.migration.inc, line 15
Migration for entityreference fields.

Class

RelationMigrateReference
@file Migration for entityreference fields.

Code

public function __construct($field_type) {
  parent::__construct();
  $this->fields = array_filter(variable_get('relation_migrate_' . $field_type . '_fields', array()));
  $this->relation_type = variable_get('relation_migrate_' . $field_type . '_relation_type', NULL);
  $this->dependencies = array();
  $this->description = 'Copy the contents from the ' . $field_type . ' fields to relation entities.';
  $this->map = new MigrateSQLMap($this->machineName, array(
    'source_type' => array(
      'type' => 'varchar',
      'length' => 128,
      'not null' => TRUE,
    ),
    'source_id' => array(
      'type' => 'int',
      'unsigned' => TRUE,
      'not null' => TRUE,
    ),
    'destination_type' => array(
      'type' => 'varchar',
      'length' => 128,
      'not null' => TRUE,
    ),
    'destination_id' => array(
      'type' => 'int',
      'unsigned' => TRUE,
      'not null' => TRUE,
    ),
    'delta' => array(
      'type' => 'int',
      'unsigned' => TRUE,
      'not null' => TRUE,
    ),
  ), MigrateDestinationRelation::getKeySchema());
  $this->destination = new MigrateDestinationRelation($this->relation_type);
  $this
    ->addFieldMapping('uid')
    ->defaultValue(variable_get('relation_migrate_' . $field_type . '_user', 1))
    ->description(t('The owner of relation.'));
}