From 07253a38b312eaae30f405bb754deee7b4f7149e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20St=C3=BCck?= Date: Mon, 31 Oct 2016 09:19:57 -0400 Subject: [PATCH] =?UTF-8?q?Add=20integration=20with=20admin=5Fmenu?= =?UTF-8?q?=E2=80=99s=20UI=20for=20granular=20cache=20clearing=20(hook=5Fa?= =?UTF-8?q?dmin=5Fmenu=5Fcache=5Finfo).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libraries.admin.inc | 4 +--- libraries.module | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/libraries.admin.inc b/libraries.admin.inc index 5e0dcf4..29ddec1 100644 --- a/libraries.admin.inc +++ b/libraries.admin.inc @@ -124,9 +124,7 @@ function libraries_admin_overview(array $form, array &$form_state) { // it was just downloaded. Because these instructions use libraries_detect() // directly, they will never use the cached information, but this avoids the // overview showing a library as installed but it not being loadable. - foreach (libraries_flush_caches() as $bin) { - cache_clear_all(NULL, $bin); - } + libraries_cache_clear(); return $form; } diff --git a/libraries.module b/libraries.module index 751ecea..a9b8eed 100644 --- a/libraries.module +++ b/libraries.module @@ -967,3 +967,23 @@ function libraries_theme($existing, $type, $theme, $path) { ), ); } + +/** + * Implements hook_admin_menu_cache_info(). + */ +function libraries_admin_menu_cache_info() { + $caches['libraries'] = array( + 'title' => t('Libraries'), + 'callback' => 'libraries_flush_cache', + ); + return $caches; +} + +/** + * Clear the cached library information. + */ +function libraries_cache_clear() { + foreach (libraries_flush_caches() as $bin) { + cache_clear_all(NULL, $bin); + } +} -- 2.10.1