diff --git a/core/lib/Drupal/Core/Theme/Registry.php b/core/lib/Drupal/Core/Theme/Registry.php index c396171..32a22c4 100644 --- a/core/lib/Drupal/Core/Theme/Registry.php +++ b/core/lib/Drupal/Core/Theme/Registry.php @@ -540,8 +540,8 @@ protected function processExtension(array &$cache, $name, $type, $theme, $path) } /** - * This completes the theme registry adding missing functions and hooks. - + * This completes the theme registry adding missing functions and hooks. + * * @param array $cache * The theme registry that will eventually be cached; It is an associative * array keyed by theme hooks, whose values are associative arrays @@ -566,7 +566,7 @@ protected function processExtension(array &$cache, $name, $type, $theme, $path) * definition is kept. * - 'preprocess functions': See _theme() for detailed documentation. * @param object $theme - * current active theme. + * Current active theme. */ protected function postProcessExtension(array &$cache, $theme) { @@ -585,7 +585,8 @@ protected function postProcessExtension(array &$cache, $theme) { } $prefixes[] = $theme->getName(); - // Collect all known hooks. Discovered functions must be based on a known hook. + // Collect all known hooks. Discovered functions must be based on a known + // hook. $hooks = implode('|', array_keys($cache)); // Collect all variable processor functions in the correct order. @@ -595,13 +596,13 @@ protected function postProcessExtension(array &$cache, $theme) { } // Add missing variable processors. This is needed for hooks that do not - // explictly register the hook. For example, when a theme contains a variable - // process function but it does not implement a template, it will go missing. - // This will add the expected function. It also allows modules or themes to - // have a variable process function based on a pattern even if the hook does - // not exist. + // explictly register the hook. For example, when a theme contains a + // variable process function but it does not implement a template, it will + // go missing. This will add the expected function. It also allows modules + // or themes to have a variable process function based on a pattern even if + // the hook does not exist. foreach ($processors as $processor) { - $hook = substr($processor, strpos($processor, 'preprocess_') + strlen('preprocess_')); + $hook = substr($processor, strpos($processor, 'preprocess_') + strlen('preprocess_')); if (isset($cache[$hook]['preprocess functions']) && !in_array($hook, $cache[$hook]['preprocess functions'])) { // Add missing processor to existing hook. $cache[$hook]['preprocess functions'][] = $processor; @@ -620,12 +621,13 @@ protected function postProcessExtension(array &$cache, $theme) { } } } - // Inherit all base hook variable processors into pattern hooks. This ensures - // that derivative hooks have a complete set of variable process functions. + // Inherit all base hook variable processors into pattern hooks. + // This ensures that derivative hooks have a complete set of variable + // process functions. foreach ($cache as $hook => $info) { // The 'base hook' is only applied to derivative hooks already registered - // from a pattern. This is typically set from drupal_find_theme_functions() - // and drupal_find_theme_templates(). + // from a pattern. This is typically set from + // drupal_find_theme_functions() and drupal_find_theme_templates(). if (isset($info['base hook']) && isset($cache[$info['base hook']]['preprocess functions'])) { $diff = array_diff($cache[$info['base hook']]['preprocess functions'], $info['preprocess functions']); $cache[$hook]['preprocess functions'] = array_merge($diff, $info['preprocess functions']); diff --git a/core/modules/system/tests/modules/theme_test/theme_test.module b/core/modules/system/tests/modules/theme_test/theme_test.module index 64d45e7..7eeee9d 100644 --- a/core/modules/system/tests/modules/theme_test/theme_test.module +++ b/core/modules/system/tests/modules/theme_test/theme_test.module @@ -99,6 +99,9 @@ function theme_test_theme_suggestions_theme_test_preprocess_suggestions($variabl return array('theme_test_preprocess_suggestions__' . 'suggestion'); } +/** + * Implements hook_preprocess_HOOK(). + */ function theme_test_preprocess_theme_test_preprocess_suggestions(&$variables) { $variables['foo'] = 'Theme hook implementor=theme_theme_test_preprocess_suggestions().'; }