prepareRow example

if (!empty($this->configuration['domain_negotiation'])) {
      // Check if domain negotiation is used to be able to fill in the default       // language domain, which may be empty. In D6, domain negotiation is used       // when the 'language_negotiation' variable is set to '3', and in D7, when       // the 'locale_language_negotiation_url_part' variable is set to '1'.       if ($this->variableGet('language_negotiation', 0) == 3 || $this->variableGet('locale_language_negotiation_url_part', 0) == 1) {
        $row->setSourceProperty('domain_negotiation_used', TRUE);
      }
    }

    return parent::prepareRow($row);
  }

}

    );
    $query->orderBy('c.cid');
    return $query;
  }

  /** * {@inheritdoc} */
  public function prepareRow(Row $row) {
    $row->setSourceProperty('recipients', explode(',', $row->getSourceProperty('recipients')));
    return parent::prepareRow($row);
  }

  /** * {@inheritdoc} */
  public function fields() {
    return [
      'cid' => $this->t('Primary Key: Unique category ID.'),
      'category' => $this->t('Category name.'),
      'recipients' => $this->t('Comma-separated list of recipient email addresses.'),
      'reply' => $this->t('Text of the auto-reply message.'),
      
$results = $this->select('imagecache_action', 'ica')
      ->fields('ica')
      ->condition('presetid', $row->getSourceProperty('presetid'))
      ->execute();

    foreach ($results as $key => $result) {
      $actions[$key] = $result;
      $actions[$key]['data'] = unserialize($result['data']);
    }

    $row->setSourceProperty('actions', $actions);
    return parent::prepareRow($row);
  }

}
$query->condition('lt.language', $language);
    $query->addField('lt', 'translation');
    $results = $query->execute()->fetchAssoc();
    if ($results) {
      $row->setSourceProperty($other_property . '_translated', $results['translation']);
    }
    else {
      // The translation does not exist.       $row->setSourceProperty($other_property . '_translated', NULL);
    }

    return parent::prepareRow($row);
  }

  /** * {@inheritdoc} */
  public function fields() {
    $fields = [
      'language' => $this->t('Language for this term.'),
      'name_translated' => $this->t('Term name translation.'),
      'description_translated' => $this->t('Term description translation.'),
    ];
    
$row->setSourceProperty('description', $description_field[0]['value']);
      }
      if (isset($description_field[0]['format'])) {
        $row->setSourceProperty('format', $description_field[0]['format']);
      }
    }

    // Determine if this is a forum container.     $forum_container_tids = $this->variableGet('forum_containers', []);
    $row->setSourceProperty('is_container', in_array($tid$forum_container_tids));

    return parent::prepareRow($row);
  }

  /** * {@inheritdoc} */
  public function fields() {
    return [
      'entity_type' => $this->t('The entity type this translation relates to'),
      'entity_id' => $this->t('The entity ID this translation relates to'),
      'revision_id' => $this->t('The entity revision ID this translation relates to'),
      'language' => $this->t('The target language for this translation.'),
      

  }

  /** * {@inheritdoc} */
  public function prepareRow(Row $row) {
    // For ease of reading the migration use 'language' as the property name for     // the language.     $language = $row->getSourceProperty('ltlanguage');
    $row->setSourceProperty('language', $language);
    return parent::prepareRow($row);
  }

  /** * {@inheritdoc} */
  public function getIds() {
    $ids['vid']['type'] = 'integer';
    $ids['language']['type'] = 'string';
    $ids['language']['alias'] = 'lt';
    return $ids;
  }

}

        elseif ($profile_value['type'] == 'list') {
          // Explode by newline and comma.           $row->setSourceProperty($profile_value['name']preg_split("/[\r\n,]+/", $profile_value['value']));
        }
        else {
          $row->setSourceProperty($profile_value['name'][$profile_value['value']]);
        }
      }
    }

    return parent::prepareRow($row);
  }

  /** * {@inheritdoc} */
  public function getIds() {
    return [
      'uid' => [
        'type' => 'integer',
        'alias' => 'u',
      ],
    ];

  public function prepareRow(Row $row) {
    // In D6, status=0 means published, while in D8 means the opposite.     $row->setSourceProperty('status', !$row->getSourceProperty('status'));

    // If node did not have a language, use site default language as a fallback.     if (!$row->getSourceProperty('language')) {
      $language_default = $this->variableGet('language_default', NULL);
      $language = $language_default ? $language_default->language : 'en';
      $row->setSourceProperty('language', $language);
    }
    return parent::prepareRow($row);
  }

  /** * {@inheritdoc} */
  public function fields() {
    return [
      'cid' => $this->t('Comment ID.'),
      'pid' => $this->t('Parent comment ID. If set to 0, this comment is not a reply to an existing comment.'),
      'nid' => $this->t('The {node}.nid to which this comment is a reply.'),
      'uid' => $this->t('The {users}.uid who authored the comment. If set to 0, this comment was created by an anonymous user.'),
      
$query->condition('i18n.type', 'block');

    // Add in the translation for the property.     $query->innerJoin('locales_target', 'lt', '[lt].[lid] = [i18n].[lid]');
    return $query;
  }

  /** * {@inheritdoc} */
  public function prepareRow(Row $row) {
    if (!parent::prepareRow($row)) {
      return FALSE;
    }
    // Set the i18n string table for use in I18nQueryTrait.     $this->i18nStringTable = static::I18N_STRING_TABLE;
    // Save the translation for this property.     $property_in_row = $row->getSourceProperty('property');
    // Get the translation for the property not already in the row and save it     // in the row.     $property_not_in_row = ($property_in_row === 'title') ? 'body' : 'title';
    return $this->getPropertyNotInRowTranslation($row$property_not_in_row, 'bid', $this->idMap);
  }

  

  public function prepareRow(Row $row) {
    // Override properties when this is an entity translation revision. The tnid     // will be set in d7_node source plugin to the value of 'nid'.     if ($row->getSourceProperty('etr_created')) {
      $row->setSourceProperty('vid', $row->getSourceProperty('revision_id'));
      $row->setSourceProperty('created', $row->getSourceProperty('etr_created'));
      $row->setSourceProperty('timestamp', $row->getSourceProperty('etr_changed'));
      $row->setSourceProperty('revision_uid', $row->getSourceProperty('etr_uid'));
      $row->setSourceProperty('source_langcode', $row->getSourceProperty('source'));
    }
    return parent::prepareRow($row);
  }

  /** * {@inheritdoc} */
  public function getIds() {
    return [
      'nid' => [
        'type' => 'integer',
        'alias' => 'n',
      ],
      
      if (!$this->mapRowAdded && ($id_map = $this->idMap->getRowBySource($this->currentSourceIds))) {
        $row->setIdMap($id_map);
      }

      // Clear any previous messages for this row before potentially adding       // new ones.       if (!empty($this->currentSourceIds)) {
        $this->idMap->delete($this->currentSourceIds, TRUE);
      }

      // Preparing the row gives source plugins the chance to skip.       if ($this->prepareRow($row) === FALSE) {
        continue;
      }

      // Check whether the row needs processing.       // 1. This row has not been imported yet.       // 2. Explicitly set to update.       // 3. The row is newer than the current high-water mark.       // 4. If no such property exists then try by checking the hash of the row.       if (!$row->getIdMap() || $row->needsUpdate() || $this->aboveHighWater($row) || $this->rowChanged($row)) {
        $this->currentRow = $row->freezeSource();
      }

      
/** * {@inheritdoc} */
  public function prepareRow(Row $row) {
    $query = $this->select('upload', 'u')
      ->fields('u', ['fid', 'description', 'list'])
      ->condition('u.nid', $row->getSourceProperty('nid'))
      ->orderBy('u.weight');
    $query->innerJoin('node', 'n', static::JOIN);
    $row->setSourceProperty('upload', $query->execute()->fetchAll());
    return parent::prepareRow($row);
  }

  /** * {@inheritdoc} */
  public function fields() {
    return [
      'fid' => $this->t('The file Id.'),
      'nid' => $this->t('The node Id.'),
      'vid' => $this->t('The version Id.'),
      'type' => $this->t('The node type'),
      
->willReturn([TRUE, TRUE])
      ->shouldBeCalled();
    $module_handler->invokeAll('migrate_' . $migration->id() . '_prepare_row', [$row$source$migration])
      ->willReturn([TRUE, TRUE])
      ->shouldBeCalled();
    $source->setModuleHandler($module_handler->reveal());

    // Ensure we don't log this to the mapping table.     $this->idMap->expects($this->never())
      ->method('saveIdMapping');

    $this->assertTrue($source->prepareRow($row));

    // Track_changes...     $source = new StubSourcePlugin(['track_changes' => TRUE], '', []$migration);
    $row2 = $this->prophesize(Row::class);
    $row2->rehash()
      ->shouldBeCalled();
    $module_handler->invokeAll('migrate_prepare_row', [$row2$source$migration])
      ->willReturn([TRUE, TRUE])
      ->shouldBeCalled();
    $module_handler->invokeAll('migrate_' . $migration->id() . '_prepare_row', [$row2$source$migration])
      ->willReturn([TRUE, TRUE])
      
$i18n_node_options = $this->variableGet('i18n_node_options_' . $type, NULL);
    if ($i18n_node_options && in_array('lock', $i18n_node_options)) {
      $row->setSourceProperty('i18n_lock_node', 1);
    }
    else {
      $row->setSourceProperty('i18n_lock_node', 0);
    }

    // Get the entity translation entity settings.     $entity_translation_entity_types = $this->variableGet('entity_translation_entity_types', NULL);
    $row->setSourceProperty('entity_translation_entity_types', $entity_translation_entity_types);
    return parent::prepareRow($row);
  }

  /** * {@inheritdoc} */
  public function getIds() {
    $ids['type']['type'] = 'string';
    return $ids;
  }

}


    // If the node title was replaced by a real field using the Drupal 7 Title     // module, use the field value instead of the node title.     if ($this->moduleExists('title')) {
      $title_field = $row->getSourceProperty('title_field');
      if (isset($title_field[0]['value'])) {
        $row->setSourceProperty('title', $title_field[0]['value']);
      }
    }

    return parent::prepareRow($row);
  }

  /** * {@inheritdoc} */
  public function fields() {
    return [
      'entity_type' => $this->t('The entity type this translation relates to'),
      'entity_id' => $this->t('The entity ID this translation relates to'),
      'revision_id' => $this->t('The entity revision ID this translation relates to'),
      'language' => $this->t('The target language for this translation.'),
      
Home | Imprint | This part of the site doesn't use cookies.