protected function Registry::completeSuggestion in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Theme/Registry.php \Drupal\Core\Theme\Registry::completeSuggestion()
Completes the definition of the requested suggestion hook.
Parameters
string $hook: The name of the suggestion hook to complete.
array $cache: The theme registry, as documented in \Drupal\Core\Theme\Registry::processExtension().
1 call to Registry::completeSuggestion()
- Registry::postProcessExtension in core/
lib/ Drupal/ Core/ Theme/ Registry.php - Completes the theme registry adding discovered functions and hooks.
File
- core/
lib/ Drupal/ Core/ Theme/ Registry.php, line 591 - Contains \Drupal\Core\Theme\Registry.
Class
- Registry
- Defines the theme registry service.
Namespace
Drupal\Core\ThemeCode
protected function completeSuggestion($hook, array &$cache) {
$previous_hook = $hook;
$incomplete_previous_hook = array();
while ((!isset($cache[$previous_hook]) || isset($cache[$previous_hook]['incomplete preprocess functions'])) && ($pos = strrpos($previous_hook, '__'))) {
if (isset($cache[$previous_hook]) && !$incomplete_previous_hook && isset($cache[$previous_hook]['incomplete preprocess functions'])) {
$incomplete_previous_hook = $cache[$previous_hook];
unset($incomplete_previous_hook['incomplete preprocess functions']);
}
$previous_hook = substr($previous_hook, 0, $pos);
// If base hook exists clone of it for the preprocess function
// without a template.
// @see https://www.drupal.org/node/2457295
if (isset($cache[$previous_hook]) && !isset($cache[$previous_hook]['incomplete preprocess functions'])) {
$cache[$hook] = $incomplete_previous_hook + $cache[$previous_hook];
if (isset($incomplete_previous_hook['preprocess functions'])) {
$diff = array_diff($incomplete_previous_hook['preprocess functions'], $cache[$previous_hook]['preprocess functions']);
$cache[$hook]['preprocess functions'] = array_merge($cache[$previous_hook]['preprocess functions'], $diff);
}
// If a base hook isn't set, this is the actual base hook.
if (!isset($cache[$previous_hook]['base hook'])) {
$cache[$hook]['base hook'] = $previous_hook;
}
}
}
}