You are here

function hook_rebuild in Drupal 10

Same name and namespace in other branches
  1. 8 core/core.api.php \hook_rebuild()
  2. 9 core/core.api.php \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

7 functions implement hook_rebuild()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

block_rebuild in core/modules/block/block.module
Implements hook_rebuild().
drupal_rebuild in core/includes/utility.inc
Rebuilds all caches even when Drupal itself does not work.
drupal_theme_rebuild in core/includes/theme.inc
Forces the system to rebuild the theme registry.
FormTestStoragePageCacheForm::form_test_storage_page_cache_rebuild in core/modules/system/tests/modules/form_test/src/Form/FormTestStoragePageCacheForm.php
Form submit callback: Rebuild the form and continue.
form_test_user_register_form_rebuild in core/modules/system/tests/modules/form_test/form_test.module
Submit callback that just lets the form rebuild.

... See full list

1 invocation of hook_rebuild()
drupal_flush_all_caches in core/includes/common.inc
Rebuilds the container, flushes all persistent caches, resets all variables, and rebuilds all data structures.

File

core/core.api.php, line 2209
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());
  }
}