diff --git a/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeTest.php b/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeTest.php index 638d8e5..cb154b7 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeTest.php @@ -41,7 +41,7 @@ function setUp() { * Render arrays that use a render element and templates (and hence call * template_preprocess()) must ensure the attributes at different occasions * are all merged correctly: - * - $variables['attributes'] as passed in to _theme() + * - $variables['attributes'] as passed in to drupal_render() * - the render element's #attributes * - any attributes set in the template's preprocessing function */ @@ -58,21 +58,23 @@ function testAttributeMerging() { } /** - * Test that _theme() returns expected data types. + * Test that drupal_render() returns expected data types. */ function testThemeDataTypes() { - // theme_test_false is an implemented theme hook so _theme() should return a + // theme_test_false is an implemented theme hook so drupal_render() 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)); + $theme_test_foo = array('#theme' => 'theme_test_foo', '#foo' => $example); + $output = drupal_render($theme_test_foo); $this->assertTrue(is_string($output), format_string('_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_render() // 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.'); + $suggestionnotimplemented = array('#theme' => 'suggestionnotimplemented'); + $output = drupal_render($suggestionnotimplemented); + $this->assertIdentical($output, FALSE, 'drupal_render() returns FALSE when a hook suggestion is not implemented.'); } /** diff --git a/core/modules/system/lib/Drupal/system/Tests/Theme/TwigDebugMarkupTest.php b/core/modules/system/lib/Drupal/system/Tests/Theme/TwigDebugMarkupTest.php index 9c2105a..f3bd56d 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Theme/TwigDebugMarkupTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Theme/TwigDebugMarkupTest.php @@ -34,7 +34,7 @@ public static function getInfo() { */ function testTwigDebugMarkup() { $extension = twig_extension(); - theme_enable(array('test_theme')); + \Drupal::service('theme_handler')->enable(array('test_theme')); \Drupal::config('system.theme')->set('default', 'test_theme')->save(); // Enable debug, rebuild the service container, and clear all caches. $this->settingsSet('twig_debug', TRUE); @@ -48,9 +48,10 @@ function testTwigDebugMarkup() { // Create a node and test different features of the debug markup. $node = $this->drupalCreateNode(); - $output = _theme('node', node_view($node)); + $node_output = entity_view($node, 'full'); + $output = drupal_render($node_output); $this->assertTrue(strpos($output, '') !== FALSE, 'Twig debug markup found in theme output when debug is enabled.'); - $this->assertTrue(strpos($output, "CALL: _theme('node')") !== FALSE, 'Theme call information found.'); + $this->assertTrue(strpos($output, "CALL: drupal_render('node')") !== FALSE, 'Theme call information found.'); $this->assertTrue(strpos($output, 'x node--1' . $extension . PHP_EOL . ' * node--page' . $extension . PHP_EOL . ' * node' . $extension) !== FALSE, 'Suggested template files found in order and node ID specific template shown as current template.'); $template_filename = $templates['node__1']['path'] . '/' . $templates['node__1']['template'] . $extension; $this->assertTrue(strpos($output, "BEGIN OUTPUT from '$template_filename'") !== FALSE, 'Full path to current template file found.'); @@ -58,16 +59,17 @@ function testTwigDebugMarkup() { // Create another node and make sure the template suggestions shown in the // debug markup are correct. $node2 = $this->drupalCreateNode(); - $output = _theme('node', node_view($node2)); + $node2_output = entity_view($node2, 'full'); + $output = drupal_render($node2_output); $this->assertTrue(strpos($output, '* node--2' . $extension . PHP_EOL . ' * node--page' . $extension . PHP_EOL . ' x node' . $extension) !== FALSE, 'Suggested template files found in order and base template shown as current template.'); // Create another node and make sure the template suggestions shown in the // debug markup are correct. $node3 = $this->drupalCreateNode(); $build = array('#theme' => 'node__foo__bar'); - $build += node_view($node3); + $build += entity_view($node3, 'full');; $output = drupal_render($build); - $this->assertTrue(strpos($output, "CALL: _theme('node__foo__bar')") !== FALSE, 'Theme call information found.'); + $this->assertTrue(strpos($output, "CALL: drupal_render('node__foo__bar')") !== FALSE, 'Theme call information found.'); $this->assertTrue(strpos($output, '* node--foo--bar' . $extension . PHP_EOL . ' * node--foo' . $extension . PHP_EOL . ' * node--3' . $extension . PHP_EOL . ' * node--page' . $extension . PHP_EOL . ' x node' . $extension) !== FALSE, 'Suggested template files found in order and base template shown as current template.'); // Disable debug, rebuild the service container, and clear all caches. @@ -75,7 +77,8 @@ function testTwigDebugMarkup() { $this->rebuildContainer(); $this->resetAll(); - $output = _theme('node', node_view($node)); + $node_output = entity_view($node, 'full'); + $output = drupal_render($node_output); $this->assertFalse(strpos($output, '') !== FALSE, 'Twig debug markup not found in theme output when debug is disabled.'); } diff --git a/core/modules/system/tests/modules/theme_test/lib/Drupal/theme_test/ThemeTestController.php b/core/modules/system/tests/modules/theme_test/lib/Drupal/theme_test/ThemeTestController.php index 31b25a0..df04a06 100644 --- a/core/modules/system/tests/modules/theme_test/lib/Drupal/theme_test/ThemeTestController.php +++ b/core/modules/system/tests/modules/theme_test/lib/Drupal/theme_test/ThemeTestController.php @@ -55,7 +55,8 @@ public function testInfoStylesheets() { * A render array containing a theme override. */ public function testTemplate() { - return _theme('theme_test_template_test'); + $theme_test_template_test = array('#theme' => 'theme_test_template_test'); + return drupal_render($theme_test_template_test); } /** @@ -65,7 +66,8 @@ public function testTemplate() { * An HTML string containing the themed output. */ public function testSuggestion() { - return _theme(array('theme_test__suggestion', 'theme_test'), array()); + $theme_test__suggestion = array('#theme' => array('theme_test__suggestion', 'theme_test')); + return drupal_render($theme_test__suggestion); } /** diff --git a/core/modules/system/tests/modules/twig_theme_test/lib/Drupal/twig_theme_test/TwigThemeTestController.php b/core/modules/system/tests/modules/twig_theme_test/lib/Drupal/twig_theme_test/TwigThemeTestController.php index ba2a718..b4817f5 100644 --- a/core/modules/system/tests/modules/twig_theme_test/lib/Drupal/twig_theme_test/TwigThemeTestController.php +++ b/core/modules/system/tests/modules/twig_theme_test/lib/Drupal/twig_theme_test/TwigThemeTestController.php @@ -16,7 +16,8 @@ class TwigThemeTestController { * Menu callback for testing PHP variables in a Twig template. */ public function phpVariablesRender() { - return _theme('twig_theme_test_php_variables'); + $twig_theme_test_php_variables = array('#theme' => 'twig_theme_test_php_variables'); + return drupal_render($twig_theme_test_php_variables); } /** diff --git a/core/themes/engines/twig/twig.engine b/core/themes/engines/twig/twig.engine index 74de2b8..f398f7b 100644 --- a/core/themes/engines/twig/twig.engine +++ b/core/themes/engines/twig/twig.engine @@ -54,7 +54,7 @@ function twig_render_template($template_file, $variables) { ); if (Settings::get('twig_debug', FALSE)) { $output['debug_prefix'] .= "\n\n"; - $output['debug_prefix'] .= "\n"; + $output['debug_prefix'] .= "\n"; // If there are theme suggestions, reverse the array so more specific // suggestions are shown first. if (!empty($variables['theme_hook_suggestions'])) {