Issue #2493989 by Antti J. Salminen, lauriii, slashrsm: template_preprocess() and other preprocess functions are called even for theme hooks implemented as functions

8.0.x
Nathaniel Catchpole 2015-09-07 11:19:02 +01:00
parent 44892524cd
commit 47295c18bc
4 changed files with 25 additions and 6 deletions

View File

@ -472,12 +472,14 @@ class Registry implements DestructableInterface {
// A template file is the default implementation for a theme hook, but
// if the theme hook specifies a function callback instead, check to
// ensure the function actually exists.
if (isset($info['function']) && !function_exists($info['function'])) {
throw new \BadFunctionCallException(sprintf(
'Theme hook "%s" refers to a theme function callback that does not exist: "%s"',
$hook,
$info['function']
));
if (isset($info['function'])) {
if (!function_exists($info['function'])) {
throw new \BadFunctionCallException(sprintf(
'Theme hook "%s" refers to a theme function callback that does not exist: "%s"',
$hook,
$info['function']
));
}
}
// Provide a default naming convention for 'template' based on the
// hook used. If the template does not exist, the theme engine used

View File

@ -100,6 +100,11 @@ class RegistryTest extends KernelTestBase {
'test_basetheme_preprocess_theme_test_template_test',
], $preprocess_functions);
$preprocess_functions = $registry_base_theme->get()['theme_test_function_suggestions']['preprocess functions'];
$this->assertIdentical([
'template_preprocess_theme_test_function_suggestions',
'test_basetheme_preprocess_theme_test_function_suggestions',
], $preprocess_functions, "Theme functions don't have template_preprocess but do have template_preprocess_HOOK");
}
/**

View File

@ -81,6 +81,12 @@ function theme_test_page_bottom(array &$page_bottom) {
$page_bottom['theme_test_page_bottom'] = array('#markup' => 'theme test page bottom markup');
}
/**
* Implements template_preprocess_HOOK() for theme_test_function_suggestions theme functions.
*/
function template_preprocess_theme_test_function_suggestions(&$variables) {
}
/**
* Theme function for testing _theme('theme_test_foo').
*/

View File

@ -28,3 +28,9 @@ function test_basetheme_views_post_render(ViewExecutable $view, &$output, CacheP
*/
function test_basetheme_preprocess_theme_test_template_test(&$variables) {
}
/**
* Implements hook_preprocess_HOOK() for theme_test_function_suggestions theme functions.
*/
function test_basetheme_preprocess_theme_test_function_suggestions(&$variables) {
}