function Registry::addFixedPreprocessFunctions
Adds $prefix_preprocess functions to every hook.
Parameters
array $cache: The theme registry, as documented in \Drupal\Core\Theme\Registry::processExtension().
array $fixed_preprocess_functions: A list of preprocess functions.
array $old_cache: An already processed theme registry.
1 call to Registry::addFixedPreprocessFunctions()
- Registry::build in core/
lib/ Drupal/ Core/ Theme/ Registry.php - Builds the theme registry cache.
File
-
core/
lib/ Drupal/ Core/ Theme/ Registry.php, line 954
Class
- Registry
- Defines the theme registry service.
Namespace
Drupal\Core\ThemeCode
protected function addFixedPreprocessFunctions(array &$cache, array $fixed_preprocess_functions, array $old_cache = []) : void {
foreach (array_keys(array_diff_key($cache, $old_cache)) as $hook) {
if ($hook == static::PREPROCESS_INVOKES) {
continue;
}
if (!isset($cache[$hook]['preprocess functions'])) {
$cache[$hook]['preprocess functions'] = $fixed_preprocess_functions;
}
else {
$offset = 0;
while (isset($cache[$hook]['preprocess functions'][$offset]) && is_string($cache[$hook]['preprocess functions'][$offset]) && str_starts_with($cache[$hook]['preprocess functions'][$offset], 'template_')) {
$offset++;
}
array_splice($cache[$hook]['preprocess functions'], $offset, 0, $fixed_preprocess_functions);
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.