function hook_theme_registry_alter
Same name in other branches
- 7.x modules/system/system.api.php \hook_theme_registry_alter()
- 9 core/lib/Drupal/Core/Render/theme.api.php \hook_theme_registry_alter()
- 8.9.x core/lib/Drupal/Core/Render/theme.api.php \hook_theme_registry_alter()
- 10 core/lib/Drupal/Core/Render/theme.api.php \hook_theme_registry_alter()
Alter the theme registry information returned from hook_theme().
The theme registry stores information about all available theme hooks, including which preprocess functions those hooks will call when triggered, what template files are exposed by these hooks, and so on.
Note that this hook is only executed as the theme cache is re-built. Changes here will not be visible until the next cache clear.
The $theme_registry array is keyed by theme hook name, and contains the information returned from hook_theme(), as well as additional properties added by \Drupal\Core\Theme\Registry::processExtension().
For example:
$theme_registry['block_content_add_list'] = [
'template' => 'block-content-add-list',
'path' => 'core/themes/claro/templates',
'type' => 'theme_engine',
'theme path' => 'core/themes/claro',
'includes' => [
0 => 'core/modules/block_content/block_content.pages.inc',
],
'variables' => [
'content' => NULL,
],
'preprocess functions' => [
0 => 'template_preprocess',
1 => 'template_preprocess_block_content_add_list',
2 => 'contextual_preprocess',
3 => 'claro_preprocess_block_content_add_list',
],
];
Parameters
$theme_registry: The entire cache of theme registry information, post-processing.
See also
\Drupal\Core\Theme\Registry::processExtension()
Related topics
3 functions implement hook_theme_registry_alter()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- claro_system_module_invoked_theme_registry_alter in core/
themes/ claro/ claro.theme - Called by system.module via its hook_theme_registry_alter().
- claro_theme_registry_alter in core/
themes/ claro/ claro.theme - Implements hook_theme_registry_alter().
- test_theme_theme_registry_alter in core/
modules/ system/ tests/ themes/ test_theme/ test_theme.theme - Implements hook_theme_registry_alter().
1 invocation of hook_theme_registry_alter()
- Registry::build in core/
lib/ Drupal/ Core/ Theme/ Registry.php - Builds the theme registry cache.
File
-
core/
lib/ Drupal/ Core/ Render/ theme.api.php, line 1327
Code
function hook_theme_registry_alter(&$theme_registry) {
// Kill the next/previous my_module topic navigation links.
foreach ($theme_registry['my_module_topic_navigation']['preprocess functions'] as $key => $value) {
if ($value == 'template_preprocess_my_module_topic_navigation') {
unset($theme_registry['my_module_topic_navigation']['preprocess functions'][$key]);
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.