cacheflush-8.x-1.x-dev/cacheflush.module
cacheflush.module
<?php
/**
* @file
* Cacheflush module.
*/
/**
* Implements hook_page_attachments().
*/
function cacheflush_page_attachments(array &$page) {
$page['#attached']['library'][] = 'cacheflush/cacheflush.menu';
}
/**
* Implements hook_cacheflush_tabs_options().
*/
function cacheflush_cacheflush_tabs_options() {
$options = [
'static' => [
'description' => t('Reset all static caches.'),
'category' => 'vertical_tabs_functions',
'functions' => [
'0' => [
'#name' => 'drupal_static_reset',
'#params' => [],
],
],
],
'asset' => [
'description' => t('Flush asset file caches.'),
'category' => 'vertical_tabs_functions',
'functions' => [
'0' => [
'#name' => '\Drupal\cacheflush\Controller\CacheflushApi::clearBinCache',
'#params' => ['asset.css.collection_optimizer'],
],
'1' => [
'#name' => '\Drupal\cacheflush\Controller\CacheflushApi::clearBinCache',
'#params' => ['asset.js.collection_optimizer'],
],
'2' => [
'#name' => '_drupal_flush_css_js',
'#params' => [],
],
],
],
'kernel' => [
'description' => t('Invalidate the container.'),
'category' => 'vertical_tabs_functions',
'functions' => [
'0' => [
'#name' => '\Drupal\cacheflush\Controller\CacheflushApi::clearBinCache',
'#params' => ['kernel', 'invalidateContainer'],
],
],
],
'twig' => [
'description' => t('Wipe the Twig PHP Storage cache.'),
'category' => 'vertical_tabs_functions',
'functions' => [
'0' => [
'#name' => '\Drupal\cacheflush\Controller\CacheflushApi::clearStorageCache',
'#params' => ['twig'],
],
],
],
'plugin' => [
'description' => t('Clear all plugin caches.'),
'category' => 'vertical_tabs_functions',
'functions' => [
'0' => [
'#name' => '\Drupal\cacheflush\Controller\CacheflushApi::clearBinCache',
'#params' => ['plugin.cache_clearer', 'clearCachedDefinitions'],
],
],
],
'module' => [
'description' => t('Rebuild module and theme data.'),
'category' => 'vertical_tabs_functions',
'functions' => [
'0' => [
'#name' => '\Drupal\cacheflush\Controller\CacheflushApi::clearModuleCache',
'#params' => [],
],
],
],
// Rebuild the menu router based on all rebuilt data.
// Important: This rebuild must happen last, so the menu router is
// guaranteed to be based on up to date information.
'router' => [
'description' => t('Rebuild the menu router based on all rebuilt data.'),
'category' => 'vertical_tabs_functions',
'functions' => [
'0' => [
'#name' => '\Drupal\cacheflush\Controller\CacheflushApi::clearBinCache',
'#params' => ['router.builder', 'rebuild'],
],
],
],
];
return $options;
}
