You are here

public function MigrateSourceReference::performRewind in Relation 7

Same name and namespace in other branches
  1. 8.2 relation_migrate/relation_migrate.source.inc \MigrateSourceReference::performRewind()
  2. 8 relation_migrate/relation_migrate.source.inc \MigrateSourceReference::performRewind()

Do whatever needs to be done to start a fresh traversal of the source data.

File

relation_migrate/relation_migrate.source.inc, line 81
Source plugin for *reference fields.

Class

MigrateSourceReference
Migration source for *ference field. This source is primary used in relation_migrate to convert *reference entries into relation entities.

Code

public function performRewind() {
  $this->result = array();
  $this->next_row = 0;

  // Load data for each field and merge all records in result array.
  foreach ($this->fields as $field_name) {
    $field_info = field_info_field($field_name);
    $columns = array_keys($field_info['columns']);
    if (!empty($field_info) && $field_info['type'] == $this->field_type) {
      $field_data = db_select('field_data_' . $field_name, 'f')
        ->fields('f', array(
        'entity_type',
        'entity_id',
        'delta',
        $field_name . '_' . $columns[0],
      ))
        ->condition('deleted', 0);
      $field_data
        ->addExpression(":name", 'field_name', array(
        ':name' => $field_name,
      ));
      $field_data = $field_data
        ->execute()
        ->fetchAll();
      $this->result = array_merge($this->result, $field_data);
    }
  }
}