function ip2country_uninstall in IP-based Determination of a Visitor's Country 8
Same name and namespace in other branches
- 6 ip2country.install \ip2country_uninstall()
- 7 ip2country.install \ip2country_uninstall()
Implements hook_uninstall().
Removes all tables and variables inserted into the database by this module.
File
- ./
ip2country.install, line 94 - Install, update, and uninstall functions for the ip2country module.
Code
function ip2country_uninstall() {
// Ensure temporary table is removed.
\Drupal::database()
->schema()
->dropTable('ip2country_temp');
// Remove state variables.
\Drupal::state()
->delete('ip2country_populate_database_on_install');
\Drupal::state()
->delete('ip2country_last_update');
\Drupal::state()
->delete('ip2country_last_update_rir');
// Remove date formats.
$formats = DateFormat::loadMultiple([
'ip2country_date',
'ip2country_time',
]);
if (!empty($formats)) {
$format_names = [];
foreach ($formats as $format) {
$format_names[] = $format
->label();
}
\Drupal::messenger()
->addWarning(\Drupal::translation()
->formatPlural(count($format_names), 'The date format %format has not been deleted. If you need to delete it, <a href=":url">please do so manually</a>.', 'The date formats %formats have not been deleted. If you need to delete them, <a href=":url">please do so manually</a>.', [
'%format' => $format_names[0],
'%formats' => implode(', ', $format_names),
':url' => Url::fromRoute('entity.date_format.collection')
->toString(),
]));
}
}