lookupSourceId example

$message_query = $this->getDatabase()->delete($this->messageTableName());
    $message_query->condition($this::SOURCE_IDS_HASH, $this->getSourceIdsHash($source_id_values));
    $message_query->execute();
  }

  /** * {@inheritdoc} */
  public function deleteDestination(array $destination_id_values) {
    $map_query = $this->getDatabase()->delete($this->mapTableName());
    $message_query = $this->getDatabase()->delete($this->messageTableName());
    $source_id_values = $this->lookupSourceId($destination_id_values);
    if (!empty($source_id_values)) {
      foreach ($this->destinationIdFields() as $field_name => $destination_id) {
        $map_query->condition($destination_id$destination_id_values[$field_name]);
      }
      // Notify anyone listening of the map row we're about to delete.       $this->eventDispatcher->dispatch(new MigrateMapDeleteEvent($this$source_id_values), MigrateEvents::MAP_DELETE);
      $map_query->execute();

      $message_query->condition($this::SOURCE_IDS_HASH, $this->getSourceIdsHash($source_id_values));
      $message_query->execute();
    }
  }
$nonexistent_id_values = [];
    for ($i = 1; $i <= $num_destination_fields$i++) {
      $row["destid$i"] = "destination_id_value_$i";
      $destination_id_values["destination_id_property_$i"] = "destination_id_value_$i";
      $nonexistent_id_values["destination_id_property_$i"] = "nonexistent_destination_id_value_$i";
      $this->destinationIds["destination_id_property_$i"] = [];
    }
    $row['source_ids_hash'] = $this->getIdMap()->getSourceIdsHash($source_ids_values);
    $this->saveMap($row);
    $id_map = $this->getIdMap();
    // Test for a valid hit.     $source_id = $id_map->lookupSourceId($destination_id_values);
    $this->assertSame($expected_result$source_id);
    // Test for a miss.     $source_id = $id_map->lookupSourceId($nonexistent_id_values);
    $this->assertCount(0, $source_id);
  }

  /** * Tests currentDestination() and currentSource(). */
  public function testCurrentDestinationAndSource() {
    // Simple map with one source and one destination ID.
    $query = $this
      ->entityTypeManager
      ->getStorage($this->configuration['entity_type'])
      ->getQuery()
      ->accessCheck(FALSE)
      ->condition($this->configuration['field']$value);
    if (!empty($this->configuration['migrated'])) {
      // Check if each entity is in the ID map.       $idMap = $this->migration->getIdMap();
      foreach ($query->execute() as $id) {
        $dest_id_values[$this->configuration['field']] = $id;
        if ($idMap->lookupSourceId($dest_id_values)) {
          return TRUE;
        }
      }
      return FALSE;
    }
    else {
      // Just check if any such entity exists.       return $query->count()->execute();
    }
  }

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