protected function ModuleInstaller::removeCacheBins in Zircon Profile 8
Same name and namespace in other branches
- 8.0 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 481 - Contains \Drupal\Core\Extension\ModuleInstaller.
Class
- ModuleInstaller
- Default implementation of the module installer.
Namespace
Drupal\Core\ExtensionCode
protected function removeCacheBins($module) {
// Remove any cache bins defined by a module.
$service_yaml_file = drupal_get_path('module', $module) . "/{$module}.services.yml";
if (file_exists($service_yaml_file)) {
$definitions = Yaml::decode(file_get_contents($service_yaml_file));
if (isset($definitions['services'])) {
foreach ($definitions['services'] as $id => $definition) {
if (isset($definition['tags'])) {
foreach ($definition['tags'] as $tag) {
// This works for the default cache registration and even in some
// cases when a non-default "super" factory is used. That should
// be extremely rare.
if ($tag['name'] == 'cache.bin' && isset($definition['factory_service']) && isset($definition['factory_method']) && !empty($definition['arguments'])) {
try {
$factory = \Drupal::service($definition['factory_service']);
if (method_exists($factory, $definition['factory_method'])) {
$backend = call_user_func_array(array(
$factory,
$definition['factory_method'],
), $definition['arguments']);
if ($backend instanceof CacheBackendInterface) {
$backend
->removeBin();
}
}
} catch (\Exception $e) {
watchdog_exception('system', $e, 'Failed to remove cache bin defined by the service %id.', array(
'%id' => $id,
));
}
}
}
}
}
}
}
}