function Sql::deleteDestination

Same name in other branches
  1. 9 core/modules/migrate/src/Plugin/migrate/id_map/Sql.php \Drupal\migrate\Plugin\migrate\id_map\Sql::deleteDestination()
  2. 10 core/modules/migrate/src/Plugin/migrate/id_map/Sql.php \Drupal\migrate\Plugin\migrate\id_map\Sql::deleteDestination()
  3. 11.x core/modules/migrate/src/Plugin/migrate/id_map/Sql.php \Drupal\migrate\Plugin\migrate\id_map\Sql::deleteDestination()

Overrides MigrateIdMapInterface::deleteDestination

File

core/modules/migrate/src/Plugin/migrate/id_map/Sql.php, line 816

Class

Sql
Defines the sql based ID map implementation.

Namespace

Drupal\migrate\Plugin\migrate\id_map

Code

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(MigrateEvents::MAP_DELETE, new MigrateMapDeleteEvent($this, $source_id_values));
        $map_query->execute();
        $message_query->condition($this::SOURCE_IDS_HASH, $this->getSourceIdsHash($source_id_values));
        $message_query->execute();
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.