protected ModuleInstaller::removeCacheBins($module)
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.
File
- core/lib/Drupal/Core/Extension/ModuleInstaller.php, line 496
Class
- ModuleInstaller
- Default implementation of the module installer.
Namespace
Drupal\Core\Extension
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | 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 )); } } } } } } } } |
Please login to continue.