diff --git a/core/modules/system/lib/Drupal/system/Controller/SystemInfoController.php b/core/modules/system/lib/Drupal/system/Controller/SystemInfoController.php index af48c1f..e67453d 100644 --- a/core/modules/system/lib/Drupal/system/Controller/SystemInfoController.php +++ b/core/modules/system/lib/Drupal/system/Controller/SystemInfoController.php @@ -53,7 +53,11 @@ public function __construct(SystemManager $systemManager) { public function status() { $requirements = $this->systemManager->listRequirements(); $this->systemManager->fixAnonymousUid(); - return theme('status_report', array('requirements' => $requirements)); + $status_report = array( + '#theme' => 'status_report', + '#requirements' => $requirements, + ); + return drupal_render($status_report); } /** diff --git a/core/modules/system/lib/Drupal/system/Plugin/Block/SystemPoweredByBlock.php b/core/modules/system/lib/Drupal/system/Plugin/Block/SystemPoweredByBlock.php index 7edd34b..b5fe6da 100644 --- a/core/modules/system/lib/Drupal/system/Plugin/Block/SystemPoweredByBlock.php +++ b/core/modules/system/lib/Drupal/system/Plugin/Block/SystemPoweredByBlock.php @@ -26,8 +26,9 @@ class SystemPoweredByBlock extends BlockBase { * {@inheritdoc} */ public function build() { + $system_powered_by = array('#theme' => 'system_powered_by'); return array( - '#children' => theme('system_powered_by'), + '#children' => drupal_render($system_powered_by), ); } 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 072bfb0..8c03477 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeTest.php @@ -41,19 +41,17 @@ function setUp() { * Render arrays that use a render element and templates (and hence call * template_preprocess()) must ensure the attributes at different occassions * 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 */ function testAttributeMerging() { - $output = theme('theme_test_render_element', array( - 'elements' => array( - '#attributes' => array('data-foo' => 'bar'), - ), - 'attributes' => array( - 'id' => 'bazinga', - ), - )); + $theme_test_render_element = array( + '#theme' => 'theme_test_render_element', + '#elements' => array('#attributes' => array('data-foo' => 'bar')), + '#attributes' => array('id' => 'bazinga'), + ); + $output = drupal_render($theme_test_render_element); $this->assertIdentical($output, '
' . "\n"); } @@ -196,44 +194,47 @@ function testThemeGetSetting() { * Ensures the theme registry is rebuilt when modules are disabled/enabled. */ function testRegistryRebuild() { - $this->assertIdentical(theme('theme_test_foo', array('foo' => 'a')), 'a', 'The theme registry contains theme_test_foo.'); + $theme_test_foo = array( '#theme' => 'theme_test_foo', '#foo' => 'a' ); + $this->assertIdentical(drupal_render($theme_test_foo), 'a', 'The theme registry contains theme_test_foo.'); module_disable(array('theme_test'), FALSE); // After enabling/disabling a module during a test, we need to rebuild the - // container and ensure the extension handler is loaded, otherwise theme() - // throws an exception. + // container and ensure the extension handler is loaded, otherwise + // drupal_render() throws an exception. $this->rebuildContainer(); $this->container->get('module_handler')->loadAll(); - $this->assertIdentical(theme('theme_test_foo', array('foo' => 'b')), FALSE, 'The theme registry does not contain theme_test_foo, because the module is disabled.'); + $theme_test_foo = array('#theme' => 'theme_test_foo', '#foo' => 'b'); + $this->assertIdentical(drupal_render($theme_test_foo), FALSE, 'The theme registry does not contain theme_test_foo, because the module is disabled.'); module_enable(array('theme_test'), FALSE); // After enabling/disabling a module during a test, we need to rebuild the - // container and ensure the extension handler is loaded, otherwise theme() - // throws an exception. + // container and ensure the extension handler is loaded, otherwise + // drupal_render() throws an exception. $this->rebuildContainer(); $this->container->get('module_handler')->loadAll(); - $this->assertIdentical(theme('theme_test_foo', array('foo' => 'c')), 'c', 'The theme registry contains theme_test_foo again after re-enabling the module.'); + $theme_test_foo = array('#theme' => 'theme_test_foo', '#foo' => 'c'); + $this->assertIdentical(drupal_render($theme_test_foo), 'c', 'The theme registry contains theme_test_foo again after re-enabling the module.'); } /** * Tests child element rendering for 'render element' theme hooks. */ function testDrupalRenderChildren() { - $element = array( + $theme_test_render_element_children = array( '#theme' => 'theme_test_render_element_children', 'child' => array( '#markup' => 'Foo', ), ); - $this->assertIdentical(theme('theme_test_render_element_children', $element), 'Foo', 'drupal_render() avoids #theme recursion loop when rendering a render element.'); + $this->assertIdentical(drupal_render($theme_test_render_element_children), 'Foo', 'drupal_render() avoids #theme recursion loop when rendering a render element.'); - $element = array( + $theme_test_render_element_children = array( '#theme_wrappers' => array('theme_test_render_element_children'), 'child' => array( '#markup' => 'Foo', ), ); - $this->assertIdentical(theme('theme_test_render_element_children', $element), 'Foo', 'drupal_render() avoids #theme_wrappers recursion loop when rendering a render element.'); + $this->assertIdentical(drupal_render($theme_test_render_element_children), 'Foo', 'drupal_render() avoids #theme_wrappers recursion loop when rendering a render element.'); } /** 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 38e183b..c049dd0 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Theme/TwigDebugMarkupTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Theme/TwigDebugMarkupTest.php @@ -52,7 +52,7 @@ 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(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, 'x node--1' . $extension) !== FALSE, 'Node ID specific template shown as current template.'); @@ -63,7 +63,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(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.'); @@ -72,7 +72,7 @@ function testTwigDebugMarkup() { $this->rebuildContainer(); $this->resetAll(); - $output = theme('node', node_view($node)); + $output = drupal_render(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/system.admin.inc b/core/modules/system/system.admin.inc index 957db86..e72a57f 100644 --- a/core/modules/system/system.admin.inc +++ b/core/modules/system/system.admin.inc @@ -48,8 +48,12 @@ function system_admin_config_page() { unset($item['localized_options']['attributes']['title']); } $block = $item; + $admin_block_content = array( + '#theme' => 'admin_block_content', + '#content' => system_admin_menu_block($item), + ); $block['content'] = ''; - $block['content'] .= theme('admin_block_content', array('content' => system_admin_menu_block($item))); + $block['content'] .= drupal_render($admin_block_content); if (!empty($block['content'])) { $block['show'] = TRUE; } @@ -62,7 +66,11 @@ function system_admin_config_page() { } if ($blocks) { ksort($blocks); - return theme('admin_page', array('blocks' => $blocks)); + $admin_page = array( + '#theme' => 'admin_page', + '#blocks' => $blocks, + ); + return drupal_render($admin_page); } else { return t('You do not have any administrative items.'); @@ -82,8 +90,9 @@ function system_admin_config_page() { */ function system_admin_menu_block_page() { $item = menu_get_item(); - if ($content = system_admin_menu_block($item)) { - $output = theme('admin_block_content', array('content' => $content)); + $admin_block_content = array('#theme' => 'admin_block_content'); + if ($admin_block_content['#content'] = system_admin_menu_block($item)) { + $output = drupal_render($admin_block_content); } else { $output = t('You do not have any administrative items.'); @@ -218,7 +227,12 @@ function system_themes_page() { drupal_alter('system_themes_page', $theme_groups); $admin_form = drupal_get_form('system_themes_admin_form', $admin_theme_options); - return theme('system_themes_page', array('theme_groups' => $theme_groups, 'theme_group_titles' => $theme_group_titles)) . drupal_render($admin_form); + $system_themes_page = array( + '#theme' => 'system_themes_page', + '#theme_groups' => $theme_groups, + '#theme_group_titles' => $theme_group_titles, + ); + return drupal_render($system_themes_page) . drupal_render($admin_form); } /** @@ -614,9 +628,15 @@ function _system_modules_build_row($info, $extra) { } else { $form['enable'] = array( - '#markup' => theme('image', array('uri' => 'core/misc/watchdog-error.png', 'alt' => $status_short, 'title' => $status_short)), + '#theme' => 'image', + '#uri' => 'core/misc/watchdog-error.png', + '#alt' => $status_short, + '#title' => $status_short, + ); + $form['description'] = array( + '#theme' => 'system_modules_incompatible', + '#message' => $status_long, ); - $form['description']['#markup'] .= theme('system_modules_incompatible', array('message' => $status_long)); } // Build operation links. @@ -983,7 +1003,11 @@ function theme_admin_page($variables) { $container = array(); foreach ($blocks as $block) { - if ($block_output = theme('admin_block', array('block' => $block))) { + $admin_block = array( + '#theme' => 'admin_block', + '#block' => $block, + ); + if ($block_output = drupal_render($admin_block)) { if (empty($block['position'])) { // perform automatic striping. $block['position'] = ++$stripe % 2 ? 'left' : 'right'; @@ -995,8 +1019,9 @@ function theme_admin_page($variables) { } } + $system_compact_link = array('#theme' => 'system_compact_link'); $output = '
'; - $output .= theme('system_compact_link'); + $output .= drupal_render($system_compact_link); foreach ($container as $id => $data) { $output .= '
'; @@ -1027,16 +1052,24 @@ function theme_system_admin_index($variables) { // Iterate over all modules. foreach ($menu_items as $module => $block) { list($description, $items) = $block; + $admin_block_content = array( + '#theme' => 'admin_block_content', + '#content' => $items, + ); + $admin_block = array( + '#theme' => 'admin_block', + '#block' => $block, + ); // Output links. if (count($items)) { $block = array(); $block['title'] = $module; - $block['content'] = theme('admin_block_content', array('content' => $items)); + $block['content'] = drupal_render($admin_block_content); $block['description'] = t($description); $block['show'] = TRUE; - if ($block_output = theme('admin_block', array('block' => $block))) { + if ($block_output = drupal_render($admin_block)) { if (!isset($block['position'])) { // Perform automatic striping. $block['position'] = $position; @@ -1047,8 +1080,9 @@ function theme_system_admin_index($variables) { } } + $system_compact_link = array('#theme' => 'system_compact_link'); $output = '
'; - $output .= theme('system_compact_link'); + $output .= drupal_render($system_compact_link); foreach ($container as $id => $data) { $output .= '
'; $output .= $data; @@ -1281,7 +1315,19 @@ function theme_system_themes_page($variables) { foreach ($theme_groups[$state] as $theme) { // Theme the screenshot. - $screenshot = $theme->screenshot ? theme('image', $theme->screenshot) : '
' . t('no screenshot') . '
'; + if ($theme->screenshot) { + $image = array( + '#theme' => 'image', + '#uri' => $theme->screenshot['uri'], + '#alt' => $theme->screenshot['alt'], + '#title' => $theme->screenshot['title'], + '#attributes' => $theme->screenshot['attributes'], + ); + $screenshot = drupal_render($image); + } + else { + $screenshot = '
' . t('no screenshot') . '
'; + } // Localize the theme description. $description = t($theme->info['description']); @@ -1309,7 +1355,14 @@ function theme_system_themes_page($variables) { $output .= '
' . t('This theme requires the theme engine @theme_engine to operate correctly.', array('@theme_engine' => $theme->info['engine'])) . '
'; } else { - $output .= theme('links', array('links' => $theme->operations, 'attributes' => array('class' => array('operations', 'clearfix')))); + $links = array( + '#theme' => 'links', + '#links' => $theme->operations, + '#attributes' => array( + 'class' => array('operations', 'clearfix'), + ), + ); + $output .= drupal_render($links); } $output .= '
'; } diff --git a/core/modules/system/system.api.php b/core/modules/system/system.api.php index 1e1bae3..d4388b2 100644 --- a/core/modules/system/system.api.php +++ b/core/modules/system/system.api.php @@ -410,7 +410,8 @@ function hook_css_alter(&$css) { */ function hook_ajax_render_alter($commands) { // Inject any new status messages into the content area. - $commands[] = ajax_command_prepend('#block-system-main .content', theme('status_messages')); + $status_messages = array('#theme' => 'status_messages'); + $commands[] = ajax_command_prepend('#block-system-main .content', drupal_render($status_messages)); } /** diff --git a/core/modules/system/system.install b/core/modules/system/system.install index f10d86b..2fa9930 100644 --- a/core/modules/system/system.install +++ b/core/modules/system/system.install @@ -130,7 +130,11 @@ function system_requirements($phase) { '@system_requirements' => 'http://drupal.org/requirements', )); - $description .= theme('item_list', array('items' => $missing_extensions)); + $item_list = array( + '#theme' => 'item_list', + '#items' => $missing_extensions, + ); + $description .= drupal_render($item_list); $requirements['php_extensions']['value'] = t('Disabled'); $requirements['php_extensions']['severity'] = REQUIREMENT_ERROR; @@ -245,7 +249,11 @@ function system_requirements($phase) { $description = $conf_errors[0]; } else { - $description = theme('item_list', array('items' => $conf_errors)); + $item_list = array( + '#theme' => 'item_list', + '#items' => $conf_errors, + ); + $description = drupal_render($item_list); } $requirements['settings.php'] = array( 'value' => t('Not protected'), diff --git a/core/modules/system/system.module b/core/modules/system/system.module index 0df34a0..6f6b2bc 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -3592,7 +3592,12 @@ function theme_exposed_filters($variables) { foreach (element_children($form['current']) as $key) { $items[] = $form['current'][$key]; } - $output .= theme('item_list', array('items' => $items, 'attributes' => array('class' => array('clearfix', 'current-filters')))); + $item_list = array( + '#theme' => 'item_list', + '#items' => $items, + '#attributes' => array('class' => array('clearfix', 'current-filters')), + ); + $output .= drupal_render($item_list); } $output .= drupal_render_children($form); 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 bea8b13..3bfe755 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 @@ -34,7 +34,12 @@ 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')); + $more_link = array( + '#theme' => 'more_link', + '#url' => 'user', + '#title' => 'Themed output generated in a KernelEvents::REQUEST listener', + ); + $GLOBALS['theme_test_output'] = drupal_render($more_link); } if (strpos($current_path, 'user/autocomplete') === 0) { // Register a fake registry loading callback. If it gets called by diff --git a/core/modules/system/tests/modules/theme_test/theme_test.module b/core/modules/system/tests/modules/theme_test/theme_test.module index ca8439d..17dedaf 100644 --- a/core/modules/system/tests/modules/theme_test/theme_test.module +++ b/core/modules/system/tests/modules/theme_test/theme_test.module @@ -93,7 +93,8 @@ function theme_test_request_listener_page_callback() { * Menu callback for testing template overridding based on filename. */ function theme_test_template_test_page_callback() { - return theme('theme_test_template_test'); + $theme_test_template_test = array('#theme' => 'theme_test_template_test'); + return drupal_render($theme_test_template_test); } /** 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 ef5fb70..5299481 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 @@ -26,7 +26,8 @@ public static function create(ContainerInterface $container) { * 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/modules/system/theme.api.php b/core/modules/system/theme.api.php index aedc6b0..169e1aa 100644 --- a/core/modules/system/theme.api.php +++ b/core/modules/system/theme.api.php @@ -186,7 +186,13 @@ function hook_process(&$variables, $hook) { 'variable_name' => $variable_name, 'variables' => $variables, ); - $variables[$variable_name] = theme('rdf_template_variable_wrapper', array('content' => $variables[$variable_name], 'attributes' => $attributes, 'context' => $context)); + $rdf_template_variable_wrapper = array( + '#theme' => 'rdf_template_variable_manager', + '#content' => $variables[$variable_name], + '#attributes' => $attributes, + '#context' => $context, + ); + $variables[$variable_name] = drupal_render($rdf_template_variable_wrapper); } } }