protected Registry::completeSuggestion($hook, array &$cache)
Completes the definition of the requested suggestion hook.
string $hook: The name of the suggestion hook to complete.
array $cache: The theme registry, as documented in \Drupal\Core\Theme\Registry::processExtension().
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; } } } }
© 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!lib!Drupal!Core!Theme!Registry.php/function/Registry::completeSuggestion/8.1.x