function ModuleInstaller::removeCacheBins
Same name in other branches
- 9 core/lib/Drupal/Core/Extension/ModuleInstaller.php \Drupal\Core\Extension\ModuleInstaller::removeCacheBins()
- 10 core/lib/Drupal/Core/Extension/ModuleInstaller.php \Drupal\Core\Extension\ModuleInstaller::removeCacheBins()
- 11.x core/lib/Drupal/Core/Extension/ModuleInstaller.php \Drupal\Core\Extension\ModuleInstaller::removeCacheBins()
Helper method for removing all cache bins registered by a given module.
Parameters
string $module: The name of the module for which to remove all registered cache bins.
1 call to ModuleInstaller::removeCacheBins()
- ModuleInstaller::uninstall in core/
lib/ Drupal/ Core/ Extension/ ModuleInstaller.php - Uninstalls a given list of modules.
File
-
core/
lib/ Drupal/ Core/ Extension/ ModuleInstaller.php, line 538
Class
- ModuleInstaller
- Default implementation of the module installer.
Namespace
Drupal\Core\ExtensionCode
protected function removeCacheBins($module) {
$service_yaml_file = drupal_get_path('module', $module) . "/{$module}.services.yml";
if (!file_exists($service_yaml_file)) {
return;
}
$definitions = Yaml::decode(file_get_contents($service_yaml_file));
$cache_bin_services = array_filter(isset($definitions['services']) ? $definitions['services'] : [], function ($definition) {
$tags = isset($definition['tags']) ? $definition['tags'] : [];
foreach ($tags as $tag) {
if (isset($tag['name']) && $tag['name'] == 'cache.bin') {
return TRUE;
}
}
return FALSE;
});
foreach (array_keys($cache_bin_services) as $service_id) {
$backend = $this->kernel
->getContainer()
->get($service_id);
if ($backend instanceof CacheBackendInterface) {
$backend->removeBin();
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.