W3cubDocs

/Drupal 8

function hook_rebuild

hook_rebuild()

Rebuild data based upon refreshed caches.

This hook allows your module to rebuild its data based on the latest/current module data. It runs after hook_cache_flush() and after all module data has been updated.

This hook is only invoked after the system has been completely cleared; i.e., all previously cached data is known to be gone and every API in the system is known to return current information, so your module can safely rely on all available data to rebuild its own.

See also

hook_cache_flush()

drupal_flush_all_caches()

Related topics

Hooks
Define functions that alter the behavior of Drupal core.

File

core/core.api.php, line 2160
Documentation landing page and topics, plus core library hooks.

Code

function hook_rebuild() {
  $themes = \Drupal::service('theme_handler')->listInfo();
  foreach ($themes as $theme) {
    _block_rehash($theme->getName());
  }
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!core.api.php/function/hook_rebuild/8.1.x