Commit 1398ddf6 authored by alexpott's avatar alexpott

Issue #2030457 by Mark Carver, Cottser: Fixed Warning: Missing argument 3 for...

Issue #2030457 by Mark Carver, Cottser: Fixed Warning: Missing argument 3 for template_preprocess() for theme functions overridden by templates.
parent 63057b78
......@@ -1131,7 +1131,7 @@ function theme($hook, $variables = array()) {
// new variable to track that.
if (!isset($variables['directory'])) {
$default_template_variables = array();
template_preprocess($default_template_variables, $hook);
template_preprocess($default_template_variables, $hook, $info);
$variables += $default_template_variables;
}
if (!isset($default_attributes)) {
......
......@@ -161,6 +161,14 @@ function testTemplateOverride() {
$this->assertText('Success: Template overridden.', 'Template overridden by defined \'template\' filename.');
}
/**
* Ensures a theme template can override a theme function.
*/
function testFunctionOverride() {
$this->drupalGet('theme-test/function-template-overridden');
$this->assertText('Success: Template overrides theme function.', 'Theme function overridden by test_theme template.');
}
/**
* Test the list_themes() function.
*/
......
<?php
/**
* @file
* Contains \Drupal\theme_test\ThemeTestController.
*/
namespace Drupal\theme_test;
use Drupal\Core\Controller\ControllerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Controller routines for theme test routes.
*/
class ThemeTestController implements ControllerInterface {
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static();
}
/**
* Menu callback for testing that a theme template overrides a theme function.
*/
function functionTemplateOverridden() {
return array(
'#theme' => 'theme_test_function_template_override',
);
}
}
......@@ -24,6 +24,9 @@ function theme_test_theme($existing, $type, $theme, $path) {
$items['theme_test_render_element_children'] = array(
'render element' => 'element',
);
$items['theme_test_function_template_override'] = array(
'variables' => array(),
);
return $items;
}
......@@ -71,6 +74,10 @@ function theme_test_menu() {
'access callback' => TRUE,
'type' => MENU_CALLBACK,
);
$items['theme-test/function-template-overridden'] = array(
'theme callback' => '_theme_custom_theme',
'route_name' => 'function_template_override',
);
return $items;
}
......@@ -157,6 +164,13 @@ function theme_theme_test_foo($variables) {
return $variables['foo'];
}
/**
* Theme function for testing theme('theme_test_function_template_override').
*/
function theme_theme_test_function_template_override($variables) {
return 'theme_test_function_template_override test failed.';
}
/**
* Process variables for theme-test-render-element.tpl.php.
*/
......
function_template_override:
pattern: '/theme-test/function-template-overridden'
defaults:
_content: '\Drupal\theme_test\ThemeTestController::functionTemplateOverridden'
requirements:
_permission: 'access content'
{# Output for Theme API test #}
Success: Template overrides theme function.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment