diff --git a/core/includes/theme.inc b/core/includes/theme.inc index f98aadd..a250f56b 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -8,6 +8,7 @@ * customized by user themes. */ +use Drupal; use Drupal\Component\Utility\String; use Drupal\Component\Utility\Url; use Drupal\Core\Config\Config; diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php index 3917ffa..e22ec6e 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php @@ -2888,7 +2888,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_render(array('#theme' => $callback, $variables); $this->verbose('Variables:' . '
' .  check_plain(var_export($variables, TRUE)) . '
' . '
' . 'Result:' . '
' .  check_plain(var_export($output, TRUE)) . '
' . '
' . 'Expected:' . '
' .  check_plain(var_export($expected, TRUE)) . '
' diff --git a/core/modules/system/lib/Drupal/system/Tests/Theme/TableTest.php b/core/modules/system/lib/Drupal/system/Tests/Theme/TableTest.php index 1a9d3d1..b4c843a 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Theme/TableTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Theme/TableTest.php @@ -27,7 +27,7 @@ public static function getInfo() { function testThemeTableStickyHeaders() { $header = array('one', 'two', 'three'); $rows = array(array(1,2,3), array(4,5,6), array(7,8,9)); - $this->content = theme('table', array('header' => $header, 'rows' => $rows, 'sticky' => TRUE)); + $this->content = drupal_render(array('#theme' => 'table', '#header' => $header, '#rows' => $rows, '#sticky' => TRUE)); $js = _drupal_add_js(); $this->assertTrue(isset($js['core/misc/tableheader.js']), 'tableheader.js was included when $sticky = TRUE.'); $this->assertRaw('sticky-enabled', 'Table has a class of sticky-enabled when $sticky = TRUE.'); @@ -43,7 +43,7 @@ function testThemeTableNoStickyHeaders() { $attributes = array(); $caption = NULL; $colgroups = array(); - $this->content = theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => $attributes, 'caption' => $caption, 'colgroups' => $colgroups, 'sticky' => FALSE)); + $this->content = drupal_render(array('#theme' => 'table', '#header' => $header, '#rows' => $rows, '#attributes' => $attributes, '#caption' => $caption, '#colgroups' => $colgroups, '#sticky' => FALSE)); $js = _drupal_add_js(); $this->assertFalse(isset($js['core/misc/tableheader.js']), 'tableheader.js was not included because $sticky = FALSE.'); $this->assertNoRaw('sticky-enabled', 'Table does not have a class of sticky-enabled because $sticky = FALSE.'); @@ -62,7 +62,7 @@ function testThemeTableWithEmptyMessage() { 'colspan' => 2, ), ); - $this->content = theme('table', array('header' => $header, 'rows' => array(), 'empty' => t('No strings available.'))); + $this->content = drupal_render(array('#theme' => 'table', '#header' => $header, '#rows' => array(), '#empty' => t('No strings available.'))); $this->assertRaw('No strings available.', 'Correct colspan was set on empty message.'); $this->assertRaw('Header 1', 'Table header was printed.'); } @@ -77,7 +77,7 @@ function testThemeTableWithNoStriping() { 'no_striping' => TRUE, ), ); - $this->content = theme('table', array('rows' => $rows)); + $this->content = drupal_render(array('#theme' => 'table', '#rows' => $rows)); $this->assertNoRaw('class="odd"', 'Odd/even classes were not added because $no_striping = TRUE.'); $this->assertNoRaw('no_striping', 'No invalid no_striping HTML attribute was printed.'); } 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 492dfd6..4e00b40 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,21 @@ 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)); + $output = drupal_render(array('#theme' => 'theme_test_foo', '#foo' => $example)); $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.'); + $output = drupal_render(array('#theme' => '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 3a26efe..49ce8d2 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,9 @@ function testTwigDebugMarkup() { // Create a node and test different features of the debug markup. $node = $this->drupalCreateNode(); - $output = theme('node', node_view($node)); + $output = drupal_render(array('#theme' => 'node', 'node' => node_view($node)); $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(array('#theme' =>'node'))") !== FALSE, 'Theme call information found.'); $this->assertTrue(strpos($output, 'x node--1' . $extension) !== FALSE, 'Node ID specific template shown as current template.'); $this->assertTrue(strpos($output, '* node' . $extension) !== FALSE, 'Base template file found.'); $template_filename = $templates['node__1']['path'] . '/' . $templates['node__1']['template'] . $extension; @@ -59,7 +59,7 @@ 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)); + $output = drupal_render(array('#theme' => 'node', 'node' => node_view($node2)); $this->assertTrue(strpos($output, '* node--2' . $extension) !== FALSE, 'Node ID specific template suggestion found.'); $this->assertTrue(strpos($output, 'x node' . $extension) !== FALSE, 'Base template file shown as current template.'); @@ -68,7 +68,7 @@ function testTwigDebugMarkup() { $this->rebuildContainer(); $this->resetAll(); - $output = theme('node', node_view($node)); + $output = drupal_render(array('#theme' => 'node', 'node' => node_view($node)); $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/EventSubscriber/ThemeTestSubscriber.php b/core/modules/system/tests/modules/theme_test/lib/Drupal/theme_test/EventSubscriber/ThemeTestSubscriber.php index 2e5417d..81dd267 100644 --- a/core/modules/system/tests/modules/theme_test/lib/Drupal/theme_test/EventSubscriber/ThemeTestSubscriber.php +++ b/core/modules/system/tests/modules/theme_test/lib/Drupal/theme_test/EventSubscriber/ThemeTestSubscriber.php @@ -42,7 +42,7 @@ public function onRequest(GetResponseEvent $event) { // theme_test_request_listener_page_callback() to test that even when the // theme system is initialized this early, it is still capable of // returning output and theming the page as a whole. - $GLOBALS['theme_test_output'] = theme('more_link', array('url' => 'user', 'title' => 'Themed output generated in a KernelEvents::REQUEST listener')); + $GLOBALS['theme_test_output'] = drupal_render(array('#theme' => 'more_link', 'url' => 'user', 'title' => 'Themed output generated in a KernelEvents::REQUEST listener')); } } 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 29bfa4e..75c9c34 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,7 @@ public function testInfoStylesheets() { * A render array containing a theme override. */ public function testTemplate() { - return theme('theme_test_template_test'); + return drupal_render(array('#theme' => 'theme_test_template_test')); } /** @@ -65,7 +65,7 @@ public function testTemplate() { * An HTML string containing the themed output. */ public function testSuggestion() { - return theme(array('theme_test__suggestion', 'theme_test'), array()); + return drupal_render(array('#theme' => 'theme_test__suggestion', 'theme_test' => array())); } /** 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 b46f948..ca25a8b 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,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_render(array('#theme' => 'twig_theme_test_php_variables')); } /**