getHighestId example

for ($i = 1; $i <= $dest_id_count$i++) {
      $db_keys[] = "destid$i";
    }
    $id_map = $this->getIdMap();
    foreach ($rows as $row) {
      $values = array_combine($db_keys$row);
      $source_values = array_slice($row, 0, $dest_id_count);
      $values['source_ids_hash'] = $id_map->getSourceIdsHash($source_values);
      $this->saveMap($values);
    }

    $actual = $id_map->getHighestId();
    $this->assertSame($expected$actual);
  }

  /** * Data provider for getHighestId(). * * Scenarios to test: * - Destination ID type integer. * - Destination ID types integer and string. * * @return array * An array of data values. */
$destination = $migration->getDestinationPlugin();
    if (!$destination instanceof HighestIdInterface) {
      throw new AuditException($migration, "Destination does not implement $interface");
    }

    $id_map = $migration->getIdMap();
    if (!$id_map instanceof HighestIdInterface) {
      throw new AuditException($migration, "ID map does not implement $interface");
    }

    if ($destination->getHighestId() > $id_map->getHighestId() || ($destination instanceof EntityContentComplete && !$this->auditEntityComplete($migration))) {
      return AuditResult::fail($migration[
        $this->t('The destination system contains data which was not created by a migration.'),
      ]);
    }

    return AuditResult::pass($migration);
  }

  /** * {@inheritdoc} */
  
// Email address is not defined as required in the base field definition but     // is effectively required by the UserMailRequired constraint. This means     // that Entity::processStubRow() did not populate it - we do it here.     $mail = EmailItem::generateSampleValue($field_definitions['mail']);
    $row->setDestinationProperty('mail', reset($mail));
  }

  /** * {@inheritdoc} */
  public function getHighestId() {
    $highest_id = parent::getHighestId();

    // Every Drupal site must have a user with UID of 1 and it's normal for     // migrations to overwrite this user.     if ($highest_id === 1) {
      return 0;
    }
    return $highest_id;
  }

}
Home | Imprint | This part of the site doesn't use cookies.