public function Sql::delete in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/migrate/src/Plugin/migrate/id_map/Sql.php \Drupal\migrate\Plugin\migrate\id_map\Sql::delete()
Deletes the map and message entries for a given source record.
Parameters
array $source_id_values: The source identifier keyed values of the record, e.g. ['nid' => 5].
bool $messages_only: TRUE to only delete the migrate messages.
Overrides MigrateIdMapInterface::delete
File
- core/
modules/ migrate/ src/ Plugin/ migrate/ id_map/ Sql.php, line 663 - Contains \Drupal\migrate\Plugin\migrate\id_map\Sql.
Class
- Sql
- Defines the sql based ID map implementation.
Namespace
Drupal\migrate\Plugin\migrate\id_mapCode
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());
}
$message_query = $this
->getDatabase()
->delete($this
->messageTableName());
foreach ($this
->sourceIdFields() as $field_name => $source_id) {
if (!$messages_only) {
$map_query
->condition($source_id, $source_id_values[$field_name]);
}
$message_query
->condition($source_id, $source_id_values[$field_name]);
}
if (!$messages_only) {
// 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
->execute();
}