Commit 4d82422e authored by alexpott's avatar alexpott

Issue #2325571 by asif_khan, omers | dawehner: Replace _theme() calls by calls...

Issue #2325571 by asif_khan, omers | dawehner: Replace _theme() calls by calls to \Drupal::theme()->render().
parent 9cf1459a
......@@ -2851,7 +2851,7 @@ function drupal_render(&$elements, $is_recursive_call = FALSE) {
// property is set, do not call the #theme function to prevent infinite
// recursion.
if ($theme_is_implemented && !isset($elements['#render_children'])) {
$elements['#children'] = _theme($elements['#theme'], $elements);
$elements['#children'] = \Drupal::theme()->render($elements['#theme'], $elements);
// If _theme() returns FALSE this means that the hook in #theme was not
// found in the registry and so we need to update our flag accordingly. This
......@@ -2906,7 +2906,7 @@ function drupal_render(&$elements, $is_recursive_call = FALSE) {
$wrapper_hook = $value;
}
$elements['#children'] = _theme($wrapper_hook, $wrapper_elements);
$elements['#children'] = Drupal::theme()->render($wrapper_hook, $wrapper_elements);
}
}
......
......@@ -741,7 +741,7 @@ protected function assertNoTitle($title, $message = '', $group = 'Other') {
* TRUE on pass, FALSE on fail.
*/
protected function assertThemeOutput($callback, array $variables = array(), $expected = '', $message = '', $group = 'Other') {
$output = _theme($callback, $variables);
$output = \Drupal::theme()->render($callback, $variables);
$this->verbose('Variables:' . '<pre>' . String::checkPlain(var_export($variables, TRUE)) . '</pre>'
. '<hr />' . 'Result:' . '<pre>' . String::checkPlain(var_export($output, TRUE)) . '</pre>'
. '<hr />' . 'Expected:' . '<pre>' . String::checkPlain(var_export($expected, TRUE)) . '</pre>'
......
......@@ -56,18 +56,18 @@ function testAttributeMerging() {
* Test that _theme() returns expected data types.
*/
function testThemeDataTypes() {
// theme_test_false is an implemented theme hook so _theme() should return a
// string, even though the theme function itself can return anything.
// theme_test_false is an implemented theme hook so \Drupal::theme() service should
// return a string, even though the theme function itself can return anything.
$foos = array('null' => NULL, 'false' => FALSE, 'integer' => 1, 'string' => 'foo');
foreach ($foos as $type => $example) {
$output = _theme('theme_test_foo', array('foo' => $example));
$this->assertTrue(is_string($output), format_string('_theme() returns a string for data type !type.', array('!type' => $type)));
$output = \Drupal::theme()->render('theme_test_foo', array('foo' => $example));
$this->assertTrue(is_string($output), format_string('\Drupal::theme() returns a string for data type !type.', array('!type' => $type)));
}
// suggestionnotimplemented is not an implemented theme hook so _theme()
// suggestionnotimplemented is not an implemented theme hook so \Drupal::theme() service
// should return FALSE instead of a string.
$output = _theme(array('suggestionnotimplemented'));
$this->assertIdentical($output, FALSE, '_theme() returns FALSE when a hook suggestion is not implemented.');
$output = \Drupal::theme()->render(array('suggestionnotimplemented'), array());
$this->assertIdentical($output, FALSE, '\Drupal::theme() returns FALSE when a hook suggestion is not implemented.');
}
/**
......
......@@ -56,7 +56,7 @@ public function testInfoStylesheets() {
* A render array containing a theme override.
*/
public function testTemplate() {
return _theme('theme_test_template_test');
return \Drupal::theme()->render('theme_test_template_test', array());
}
/**
......@@ -82,7 +82,7 @@ public function testInlineTemplate() {
* An HTML string containing the themed output.
*/
public function testSuggestion() {
return _theme(array('theme_test__suggestion', 'theme_test'), array());
return \Drupal::theme()->render(array('theme_test__suggestion', 'theme_test'), array());
}
/**
......
......@@ -16,7 +16,7 @@ class TwigThemeTestController {
* Menu callback for testing PHP variables in a Twig template.
*/
public function phpVariablesRender() {
return _theme('twig_theme_test_php_variables');
return \Drupal::theme()->render('twig_theme_test_php_variables', array());
}
/**
......
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