function Sql::delete

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

Overrides MigrateIdMapInterface::delete

File

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

Class

Sql
Defines the sql based ID map implementation.

Namespace

Drupal\migrate\Plugin\migrate\id_map

Code

public function delete(array $source_id_values, $messages_only = FALSE) {
    if (empty($source_id_values)) {
        throw new MigrateException('Without source identifier values it is impossible to find the row to delete.');
    }
    if (!$messages_only) {
        $map_query = $this->getDatabase()
            ->delete($this->mapTableName());
        $map_query->condition($this::SOURCE_IDS_HASH, $this->getSourceIdsHash($source_id_values));
        // 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 = $this->getDatabase()
        ->delete($this->messageTableName());
    $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.