From 7f27bbaba141ff4073a89bb602cee141f2fefe1e Mon Sep 17 00:00:00 2001 From: Lauri Eskola Date: Mon, 3 Jul 2017 18:35:13 +0300 Subject: [PATCH] Issue #2704871 by pepegarciag, Mile23, Manuel Garcia, ieguskiza, snehi, gaurav.pahuja, dimaro, rajeshwari10, gargsuchi, pashupathi nath gajawada, penyaskito, xjm, ZeiP, Wim Leers, alexpott: Replace usages of deprecated method drupal_render() --- core/includes/common.inc | 2 +- core/includes/tablesort.inc | 2 +- core/lib/Drupal/Core/Render/Element/Tableselect.php | 2 +- core/lib/Drupal/Core/Theme/ThemeManager.php | 2 +- core/modules/action/action.views_execution.inc | 2 +- core/modules/book/book.module | 2 +- core/modules/book/src/Form/BookAdminEditForm.php | 2 +- core/modules/comment/comment.module | 4 ++-- .../modules/comment/src/Plugin/views/field/EntityLink.php | 2 +- .../src/Plugin/views/field/StatisticsLastCommentName.php | 2 +- .../content_translation/content_translation.admin.inc | 4 ++-- .../contextual/src/Plugin/views/field/ContextualLinks.php | 2 +- core/modules/file/file.field.inc | 2 +- core/modules/filter/src/Plugin/Filter/FilterCaption.php | 2 +- core/modules/filter/src/Plugin/Filter/FilterHtml.php | 4 ++-- core/modules/forum/forum.module | 8 ++++---- .../src/Plugin/views/field/HistoryUserTimestamp.php | 2 +- core/modules/image/src/Form/ImageStyleEditForm.php | 2 +- core/modules/node/node.admin.inc | 2 +- core/modules/node/node.module | 4 ++-- core/modules/node/src/NodeListBuilder.php | 2 +- .../node/src/Plugin/Action/UnpublishByKeywordNode.php | 2 +- core/modules/rdf/rdf.module | 4 ++-- .../src/Plugin/Search/SearchExtraTypeSearch.php | 2 +- core/modules/simpletest/simpletest.module | 6 +++--- .../system/tests/modules/theme_test/theme_test.module | 2 +- core/modules/taxonomy/src/Form/OverviewTerms.php | 2 +- core/modules/update/src/Form/UpdateManagerUpdate.php | 2 +- core/modules/update/update.manager.inc | 2 +- core/modules/views/src/Analyzer.php | 2 +- core/modules/views/src/Plugin/views/area/Result.php | 2 +- .../views/src/Plugin/views/field/PrerenderList.php | 2 +- core/modules/views/views.module | 4 ++-- core/modules/views_ui/src/Form/BreakLockForm.php | 2 +- core/modules/views_ui/src/ViewEditForm.php | 2 +- .../Drupal/Tests/Core/Render/RendererBubblingTest.php | 4 ++-- .../Drupal/Tests/Core/Render/RendererPlaceholdersTest.php | 4 ++-- 37 files changed, 50 insertions(+), 50 deletions(-) diff --git a/core/includes/common.inc b/core/includes/common.inc index 323a666b89e8..f40565ab1c78 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -896,7 +896,7 @@ function drupal_render_children(&$element, $children_keys = NULL) { $output = ''; foreach ($children_keys as $key) { if (!empty($element[$key])) { - $output .= drupal_render($element[$key]); + $output .= \Drupal::service('renderer')->render($element[$key]); } } return Markup::create($output); diff --git a/core/includes/tablesort.inc b/core/includes/tablesort.inc index d8f16243138b..b948fea69ef8 100644 --- a/core/includes/tablesort.inc +++ b/core/includes/tablesort.inc @@ -53,7 +53,7 @@ function tablesort_header(&$cell_content, array &$cell_attributes, array $header '#theme' => 'tablesort_indicator', '#style' => $ts['sort'], ]; - $image = drupal_render($tablesort_indicator); + $image = \Drupal::service('renderer')->render($tablesort_indicator); } else { // If the user clicks a different header, we want to sort ascending initially. diff --git a/core/lib/Drupal/Core/Render/Element/Tableselect.php b/core/lib/Drupal/Core/Render/Element/Tableselect.php index a8f0e9596c4a..24eb431713ba 100644 --- a/core/lib/Drupal/Core/Render/Element/Tableselect.php +++ b/core/lib/Drupal/Core/Render/Element/Tableselect.php @@ -159,7 +159,7 @@ class Tableselect extends Table { $row += $element['#options'][$key]['#attributes']; } // Render the checkbox / radio element. - $row['data'][] = drupal_render($element[$key]); + $row['data'][] = \Drupal::service('renderer')->render($element[$key]); // As table.html.twig only maps header and row columns by order, create // the correct order by iterating over the header fields. diff --git a/core/lib/Drupal/Core/Theme/ThemeManager.php b/core/lib/Drupal/Core/Theme/ThemeManager.php index c58d176d4510..61f0483363e7 100644 --- a/core/lib/Drupal/Core/Theme/ThemeManager.php +++ b/core/lib/Drupal/Core/Theme/ThemeManager.php @@ -303,7 +303,7 @@ class ThemeManager implements ThemeManagerInterface { unset($preprocess_bubbleable['#cache']['keys']); if ($preprocess_bubbleable) { // @todo Inject the Renderer in https://www.drupal.org/node/2529438. - drupal_render($preprocess_bubbleable); + \Drupal::service('renderer')->render($preprocess_bubbleable); } } diff --git a/core/modules/action/action.views_execution.inc b/core/modules/action/action.views_execution.inc index 71b8eebe428b..b9acfe9fc244 100644 --- a/core/modules/action/action.views_execution.inc +++ b/core/modules/action/action.views_execution.inc @@ -15,6 +15,6 @@ function action_views_form_substitutions() { '#attributes' => ['class' => ['action-table-select-all']], ]; return [ - '' => drupal_render($select_all), + '' => \Drupal::service('renderer')->render($select_all), ]; } diff --git a/core/modules/book/book.module b/core/modules/book/book.module index 988201ee1e54..d0aa9b0fefd8 100644 --- a/core/modules/book/book.module +++ b/core/modules/book/book.module @@ -437,7 +437,7 @@ function template_preprocess_book_navigation(&$variables) { } if (!empty($build)) { - drupal_render($build); + \Drupal::service('renderer')->render($build); } $variables['has_links'] = FALSE; diff --git a/core/modules/book/src/Form/BookAdminEditForm.php b/core/modules/book/src/Form/BookAdminEditForm.php index e91f52ea8b25..1e7cdb4b95a4 100644 --- a/core/modules/book/src/Form/BookAdminEditForm.php +++ b/core/modules/book/src/Form/BookAdminEditForm.php @@ -220,7 +220,7 @@ class BookAdminEditForm extends FormBase { } $form[$id]['title'] = [ - '#prefix' => !empty($indentation) ? drupal_render($indentation) : '', + '#prefix' => !empty($indentation) ? \Drupal::service('renderer')->render($indentation) : '', '#type' => 'textfield', '#default_value' => $data['link']['title'], '#maxlength' => 255, diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index 48e2ae9a3ca1..16949ffd9e78 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -627,7 +627,7 @@ function template_preprocess_comment(&$variables) { '#theme' => 'username', '#account' => $account, ]; - $variables['author'] = drupal_render($username); + $variables['author'] = \Drupal::service('renderer')->render($username); $variables['author_id'] = $comment->getOwnerId(); $variables['new_indicator_timestamp'] = $comment->getChangedTime(); $variables['created'] = format_date($comment->getCreatedTime()); @@ -673,7 +673,7 @@ function template_preprocess_comment(&$variables) { '#theme' => 'username', '#account' => $account_parent, ]; - $variables['parent_author'] = drupal_render($username); + $variables['parent_author'] = \Drupal::service('renderer')->render($username); $variables['parent_created'] = format_date($comment_parent->getCreatedTime()); // Avoid calling format_date() twice on the same timestamp. if ($comment_parent->getChangedTime() == $comment_parent->getCreatedTime()) { diff --git a/core/modules/comment/src/Plugin/views/field/EntityLink.php b/core/modules/comment/src/Plugin/views/field/EntityLink.php index 03e6f6c84348..a2c69119425f 100644 --- a/core/modules/comment/src/Plugin/views/field/EntityLink.php +++ b/core/modules/comment/src/Plugin/views/field/EntityLink.php @@ -72,7 +72,7 @@ class EntityLink extends FieldPluginBase { $entity = $this->getEntity($values); // Only render the links, if they are defined. - return !empty($this->build[$entity->id()]['links']['comment__comment']) ? drupal_render($this->build[$entity->id()]['links']['comment__comment']) : ''; + return !empty($this->build[$entity->id()]['links']['comment__comment']) ? \Drupal::service('renderer')->render($this->build[$entity->id()]['links']['comment__comment']) : ''; } } diff --git a/core/modules/comment/src/Plugin/views/field/StatisticsLastCommentName.php b/core/modules/comment/src/Plugin/views/field/StatisticsLastCommentName.php index fa24c3ffe823..f88c0498d3d0 100644 --- a/core/modules/comment/src/Plugin/views/field/StatisticsLastCommentName.php +++ b/core/modules/comment/src/Plugin/views/field/StatisticsLastCommentName.php @@ -70,7 +70,7 @@ class StatisticsLastCommentName extends FieldPluginBase { '#theme' => 'username', '#account' => $account, ]; - return drupal_render($username); + return \Drupal::service('renderer')->render($username); } else { return $this->sanitizeValue($this->getValue($values)); diff --git a/core/modules/content_translation/content_translation.admin.inc b/core/modules/content_translation/content_translation.admin.inc index f29a7e655637..bf33ba0af05d 100644 --- a/core/modules/content_translation/content_translation.admin.inc +++ b/core/modules/content_translation/content_translation.admin.inc @@ -209,7 +209,7 @@ function _content_translation_preprocess_language_content_settings_table(&$varia $rows[] = [ 'data' => [ [ - 'data' => drupal_render($field_element), + 'data' => \Drupal::service('renderer')->render($field_element), 'class' => ['translatable'], ], [ @@ -243,7 +243,7 @@ function _content_translation_preprocess_language_content_settings_table(&$varia $rows[] = [ 'data' => [ [ - 'data' => drupal_render($column_element[$key]), + 'data' => \Drupal::service('renderer')->render($column_element[$key]), 'class' => ['translatable'], ], [ diff --git a/core/modules/contextual/src/Plugin/views/field/ContextualLinks.php b/core/modules/contextual/src/Plugin/views/field/ContextualLinks.php index 6bd5c01a4397..09e4505953bb 100644 --- a/core/modules/contextual/src/Plugin/views/field/ContextualLinks.php +++ b/core/modules/contextual/src/Plugin/views/field/ContextualLinks.php @@ -138,7 +138,7 @@ class ContextualLinks extends FieldPluginBase { '#type' => 'contextual_links_placeholder', '#id' => _contextual_links_to_id($contextual_links), ]; - return drupal_render($element); + return \Drupal::service('renderer')->render($element); } else { return ''; diff --git a/core/modules/file/file.field.inc b/core/modules/file/file.field.inc index 80ffbe997947..a3b8868cd021 100644 --- a/core/modules/file/file.field.inc +++ b/core/modules/file/file.field.inc @@ -73,7 +73,7 @@ function template_preprocess_file_widget_multiple(&$variables) { // Render everything else together in a column, without the normal wrappers. $widget['#theme_wrappers'] = []; - $information = drupal_render($widget); + $information = \Drupal::service('renderer')->render($widget); $display = ''; if ($element['#display_field']) { unset($widget['display']['#title']); diff --git a/core/modules/filter/src/Plugin/Filter/FilterCaption.php b/core/modules/filter/src/Plugin/Filter/FilterCaption.php index 62c83950369b..03cddb790051 100644 --- a/core/modules/filter/src/Plugin/Filter/FilterCaption.php +++ b/core/modules/filter/src/Plugin/Filter/FilterCaption.php @@ -64,7 +64,7 @@ class FilterCaption extends FilterBase { '#caption' => $caption, '#classes' => $classes, ]; - $altered_html = drupal_render($filter_caption); + $altered_html = \Drupal::service('renderer')->render($filter_caption); // Load the altered HTML into a new DOMDocument and retrieve the element. $updated_nodes = Html::load($altered_html)->getElementsByTagName('body') diff --git a/core/modules/filter/src/Plugin/Filter/FilterHtml.php b/core/modules/filter/src/Plugin/Filter/FilterHtml.php index 882bcc0e166e..6e800c3a5283 100644 --- a/core/modules/filter/src/Plugin/Filter/FilterHtml.php +++ b/core/modules/filter/src/Plugin/Filter/FilterHtml.php @@ -422,7 +422,7 @@ class FilterHtml extends FilterBase { '#header' => $header, '#rows' => $rows, ]; - $output .= drupal_render($table); + $output .= \Drupal::service('renderer')->render($table); $output .= '

' . $this->t('Most unusual characters can be directly entered without any problems.') . '

'; $output .= '

' . $this->t('If you do encounter problems, try using HTML character entities. A common example looks like & for an ampersand & character. For a full list of entities see HTML\'s entities page. Some of the available characters include:', [':html-entities' => 'http://www.w3.org/TR/html4/sgml/entities.html']) . '

'; @@ -461,7 +461,7 @@ class FilterHtml extends FilterBase { '#header' => $header, '#rows' => $rows, ]; - $output .= drupal_render($table); + $output .= \Drupal::service('renderer')->render($table); return $output; } diff --git a/core/modules/forum/forum.module b/core/modules/forum/forum.module index c2de3c9e0bde..51472cf8c52a 100644 --- a/core/modules/forum/forum.module +++ b/core/modules/forum/forum.module @@ -460,12 +460,12 @@ function template_preprocess_forums(&$variables) { 'name' => $topic->getOwner()->getDisplayName(), 'created' => $topic->getCreatedTime(), ]]; - $variables['topics'][$id]->submitted = drupal_render($forum_submitted); + $variables['topics'][$id]->submitted = \Drupal::service('renderer')->render($forum_submitted); $forum_submitted = [ '#theme' => 'forum_submitted', '#topic' => isset($topic->last_reply) ? $topic->last_reply : NULL, ]; - $variables['topics'][$id]->last_reply = drupal_render($forum_submitted); + $variables['topics'][$id]->last_reply = \Drupal::service('renderer')->render($forum_submitted); $variables['topics'][$id]->new_text = ''; $variables['topics'][$id]->new_url = ''; @@ -569,7 +569,7 @@ function template_preprocess_forum_list(&$variables) { $variables['forums'][$id]->old_topics = $forum->num_topics - $variables['forums'][$id]->new_topics; } $forum_submitted = ['#theme' => 'forum_submitted', '#topic' => $forum->last_post]; - $variables['forums'][$id]->last_reply = drupal_render($forum_submitted); + $variables['forums'][$id]->last_reply = \Drupal::service('renderer')->render($forum_submitted); } $variables['pager'] = [ @@ -636,7 +636,7 @@ function template_preprocess_forum_submitted(&$variables) { $variables['author'] = ''; if (isset($variables['topic']->uid)) { $username = ['#theme' => 'username', '#account' => User::load($variables['topic']->uid)]; - $variables['author'] = drupal_render($username); + $variables['author'] = \Drupal::service('renderer')->render($username); } $variables['time'] = isset($variables['topic']->created) ? \Drupal::service('date.formatter')->formatTimeDiffSince($variables['topic']->created) : ''; } diff --git a/core/modules/history/src/Plugin/views/field/HistoryUserTimestamp.php b/core/modules/history/src/Plugin/views/field/HistoryUserTimestamp.php index f33dab25aa52..3a8b22d00ecb 100644 --- a/core/modules/history/src/Plugin/views/field/HistoryUserTimestamp.php +++ b/core/modules/history/src/Plugin/views/field/HistoryUserTimestamp.php @@ -96,7 +96,7 @@ class HistoryUserTimestamp extends Node { '#theme' => 'mark', '#status' => $mark, ]; - return $this->renderLink(drupal_render($build), $values); + return $this->renderLink(\Drupal::service('renderer')->render($build), $values); } } diff --git a/core/modules/image/src/Form/ImageStyleEditForm.php b/core/modules/image/src/Form/ImageStyleEditForm.php index 574d9145a8b9..1e242954b580 100644 --- a/core/modules/image/src/Form/ImageStyleEditForm.php +++ b/core/modules/image/src/Form/ImageStyleEditForm.php @@ -58,7 +58,7 @@ class ImageStyleEditForm extends ImageStyleFormBase { $form['preview'] = [ '#type' => 'item', '#title' => $this->t('Preview'), - '#markup' => drupal_render($preview_arguments), + '#markup' => \Drupal::service('renderer')->render($preview_arguments), // Render preview above parent elements. '#weight' => -5, ]; diff --git a/core/modules/node/node.admin.inc b/core/modules/node/node.admin.inc index 6c3bb5fd3dd5..b96ee5aff620 100644 --- a/core/modules/node/node.admin.inc +++ b/core/modules/node/node.admin.inc @@ -173,7 +173,7 @@ function _node_mass_update_batch_finished($success, $results, $operations) { '#theme' => 'item_list', '#items' => $results, ]; - $message .= drupal_render($item_list); + $message .= \Drupal::service('renderer')->render($item_list); drupal_set_message($message); } } diff --git a/core/modules/node/node.module b/core/modules/node/node.module index 466f5100018e..4e76edddd2f5 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -593,9 +593,9 @@ function template_preprocess_node(&$variables) { $variables['node'] = $variables['elements']['#node']; /** @var \Drupal\node\NodeInterface $node */ $node = $variables['node']; - $variables['date'] = drupal_render($variables['elements']['created']); + $variables['date'] = \Drupal::service('renderer')->render($variables['elements']['created']); unset($variables['elements']['created']); - $variables['author_name'] = drupal_render($variables['elements']['uid']); + $variables['author_name'] = \Drupal::service('renderer')->render($variables['elements']['uid']); unset($variables['elements']['uid']); $variables['url'] = $node->url('canonical', [ diff --git a/core/modules/node/src/NodeListBuilder.php b/core/modules/node/src/NodeListBuilder.php index 62666497e877..4dbdf27bf213 100644 --- a/core/modules/node/src/NodeListBuilder.php +++ b/core/modules/node/src/NodeListBuilder.php @@ -110,7 +110,7 @@ class NodeListBuilder extends EntityListBuilder { $row['title']['data'] = [ '#type' => 'link', '#title' => $entity->label(), - '#suffix' => ' ' . drupal_render($mark), + '#suffix' => ' ' . \Drupal::service('renderer')->render($mark), '#url' => $uri, ]; $row['type'] = node_get_type_label($entity); diff --git a/core/modules/node/src/Plugin/Action/UnpublishByKeywordNode.php b/core/modules/node/src/Plugin/Action/UnpublishByKeywordNode.php index c0081882ce78..3709853335a2 100644 --- a/core/modules/node/src/Plugin/Action/UnpublishByKeywordNode.php +++ b/core/modules/node/src/Plugin/Action/UnpublishByKeywordNode.php @@ -24,7 +24,7 @@ class UnpublishByKeywordNode extends ConfigurableActionBase { public function execute($node = NULL) { foreach ($this->configuration['keywords'] as $keyword) { $elements = node_view(clone $node); - if (strpos(drupal_render($elements), $keyword) !== FALSE || strpos($node->label(), $keyword) !== FALSE) { + if (strpos(\Drupal::service('renderer')->render($elements), $keyword) !== FALSE || strpos($node->label(), $keyword) !== FALSE) { $node->setPublished(FALSE); $node->save(); break; diff --git a/core/modules/rdf/rdf.module b/core/modules/rdf/rdf.module index 0afcb09186c3..8d4329884d60 100644 --- a/core/modules/rdf/rdf.module +++ b/core/modules/rdf/rdf.module @@ -329,7 +329,7 @@ function rdf_preprocess_node(&$variables) { '#theme' => 'rdf_metadata', '#metadata' => [$date_attributes], ]; - $variables['metadata'] = drupal_render($rdf_metadata); + $variables['metadata'] = \Drupal::service('renderer')->render($rdf_metadata); } // Adds RDFa markup annotating the number of comments a node has. @@ -534,7 +534,7 @@ function rdf_preprocess_comment(&$variables) { if (!empty($variables['content']['comment_body']['#prefix'])) { $rdf_metadata['#suffix'] = $variables['content']['comment_body']['#prefix']; } - $variables['content']['comment_body']['#prefix'] = drupal_render($rdf_metadata); + $variables['content']['comment_body']['#prefix'] = \Drupal::service('renderer')->render($rdf_metadata); } } diff --git a/core/modules/search/tests/modules/search_extra_type/src/Plugin/Search/SearchExtraTypeSearch.php b/core/modules/search/tests/modules/search_extra_type/src/Plugin/Search/SearchExtraTypeSearch.php index d18ff1c9254a..899986ae60a5 100644 --- a/core/modules/search/tests/modules/search_extra_type/src/Plugin/Search/SearchExtraTypeSearch.php +++ b/core/modules/search/tests/modules/search_extra_type/src/Plugin/Search/SearchExtraTypeSearch.php @@ -81,7 +81,7 @@ class SearchExtraTypeSearch extends ConfigurableSearchPluginBase { $pager = [ '#type' => 'pager', ]; - $output['suffix']['#markup'] = '' . drupal_render($pager); + $output['suffix']['#markup'] = '' . \Drupal::service('renderer')->render($pager); return $output; } diff --git a/core/modules/simpletest/simpletest.module b/core/modules/simpletest/simpletest.module index e5c67d395423..83d7feb69908 100644 --- a/core/modules/simpletest/simpletest.module +++ b/core/modules/simpletest/simpletest.module @@ -445,20 +445,20 @@ function _simpletest_batch_operation($test_list_init, $test_id, &$context) { '#theme' => 'simpletest_result_summary', '#label' => t($test_results[$class]['#name'] . ':'), ]; - array_unshift($items, drupal_render($class_test_result)); + array_unshift($items, \Drupal::service('renderer')->render($class_test_result)); } $context['message'] = t('Processed test @num of @max - %test.', ['%test' => $info['name'], '@num' => $max - $size, '@max' => $max]); $overall_results = $test_results + [ '#theme' => 'simpletest_result_summary', '#label' => t('Overall results:'), ]; - $context['message'] .= drupal_render($overall_results); + $context['message'] .= \Drupal::service('renderer')->render($overall_results); $item_list = [ '#theme' => 'item_list', '#items' => $items, ]; - $context['message'] .= drupal_render($item_list); + $context['message'] .= \Drupal::service('renderer')->render($item_list); // Save working values for the next iteration. $context['sandbox']['tests'] = $test_list; 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 2e6f1647335a..6a701abee915 100644 --- a/core/modules/system/tests/modules/theme_test/theme_test.module +++ b/core/modules/system/tests/modules/theme_test/theme_test.module @@ -153,7 +153,7 @@ function template_preprocess_theme_test_render_element(&$variables) { * - element: An associative array containing the properties of the element. */ function theme_theme_test_render_element_children($variables) { - return drupal_render($variables['element']); + return \Drupal::service('renderer')->render($variables['element']); } /** diff --git a/core/modules/taxonomy/src/Form/OverviewTerms.php b/core/modules/taxonomy/src/Form/OverviewTerms.php index 0ccb24b49b98..3811ee5fd8ae 100644 --- a/core/modules/taxonomy/src/Form/OverviewTerms.php +++ b/core/modules/taxonomy/src/Form/OverviewTerms.php @@ -227,7 +227,7 @@ class OverviewTerms extends FormBase { ]; } $form['terms'][$key]['term'] = [ - '#prefix' => !empty($indentation) ? drupal_render($indentation) : '', + '#prefix' => !empty($indentation) ? \Drupal::service('renderer')->render($indentation) : '', '#type' => 'link', '#title' => $term->getName(), '#url' => $term->urlInfo(), diff --git a/core/modules/update/src/Form/UpdateManagerUpdate.php b/core/modules/update/src/Form/UpdateManagerUpdate.php index 62572d60d343..60f506af0405 100644 --- a/core/modules/update/src/Form/UpdateManagerUpdate.php +++ b/core/modules/update/src/Form/UpdateManagerUpdate.php @@ -69,7 +69,7 @@ class UpdateManagerUpdate extends FormBase { '#last' => $this->state->get('update.last_check') ?: 0, ]; $form['last_check'] = [ - '#markup' => drupal_render($last_markup), + '#markup' => \Drupal::service('renderer')->render($last_markup), ]; if (!_update_manager_check_backends($form, 'update')) { diff --git a/core/modules/update/update.manager.inc b/core/modules/update/update.manager.inc index d9067f4a1252..399694f2c7ab 100644 --- a/core/modules/update/update.manager.inc +++ b/core/modules/update/update.manager.inc @@ -53,7 +53,7 @@ function update_manager_download_batch_finished($success, $results) { '#title' => t('Downloading updates failed:'), '#items' => $results['errors'], ]; - drupal_set_message(drupal_render($item_list), 'error'); + drupal_set_message(\Drupal::service('renderer')->render($item_list), 'error'); } elseif ($success) { drupal_set_message(t('Updates downloaded successfully.')); diff --git a/core/modules/views/src/Analyzer.php b/core/modules/views/src/Analyzer.php index a5de193deda9..a6a8d56bf496 100644 --- a/core/modules/views/src/Analyzer.php +++ b/core/modules/views/src/Analyzer.php @@ -77,7 +77,7 @@ class Analyzer { '#theme' => 'item_list', '#items' => $messages, ]; - $message = drupal_render($item_list); + $message = \Drupal::service('renderer')->render($item_list); } elseif ($messages) { $message = array_shift($messages); diff --git a/core/modules/views/src/Plugin/views/area/Result.php b/core/modules/views/src/Plugin/views/area/Result.php index d2f1b01ab613..2bbd23bb2498 100644 --- a/core/modules/views/src/Plugin/views/area/Result.php +++ b/core/modules/views/src/Plugin/views/area/Result.php @@ -47,7 +47,7 @@ class Result extends AreaPluginBase { '@page_count -- the total page count', ], ]; - $list = drupal_render($item_list); + $list = \Drupal::service('renderer')->render($item_list); $form['content'] = [ '#title' => $this->t('Display'), '#type' => 'textarea', diff --git a/core/modules/views/src/Plugin/views/field/PrerenderList.php b/core/modules/views/src/Plugin/views/field/PrerenderList.php index f851cbb6a005..f27973ebbfed 100644 --- a/core/modules/views/src/Plugin/views/field/PrerenderList.php +++ b/core/modules/views/src/Plugin/views/field/PrerenderList.php @@ -90,7 +90,7 @@ abstract class PrerenderList extends FieldPluginBase implements MultiItemsFieldH '#list_type' => $this->options['type'], ]; } - return drupal_render($render); + return \Drupal::service('renderer')->render($render); } } diff --git a/core/modules/views/views.module b/core/modules/views/views.module index f6b4f79f9e54..453c90bd7968 100644 --- a/core/modules/views/views.module +++ b/core/modules/views/views.module @@ -614,7 +614,7 @@ function views_pre_render_views_form_views_form($element) { $row_id = $substitution['row_id']; $search[] = $substitution['placeholder']; - $replace[] = isset($element[$field_name][$row_id]) ? drupal_render($element[$field_name][$row_id]) : ''; + $replace[] = isset($element[$field_name][$row_id]) ? \Drupal::service('renderer')->render($element[$field_name][$row_id]) : ''; } // Add in substitutions from hook_views_form_substitutions(). $substitutions = \Drupal::moduleHandler()->invokeAll('views_form_substitutions'); @@ -628,7 +628,7 @@ function views_pre_render_views_form_views_form($element) { } // Apply substitutions to the rendered output. - $output = str_replace($search, $replace, drupal_render($element['output'])); + $output = str_replace($search, $replace, \Drupal::service('renderer')->render($element['output'])); $element['output'] = ['#markup' => ViewsRenderPipelineMarkup::create($output)]; return $element; diff --git a/core/modules/views_ui/src/Form/BreakLockForm.php b/core/modules/views_ui/src/Form/BreakLockForm.php index 94a626f2734e..b73e618cc2d2 100644 --- a/core/modules/views_ui/src/Form/BreakLockForm.php +++ b/core/modules/views_ui/src/Form/BreakLockForm.php @@ -74,7 +74,7 @@ class BreakLockForm extends EntityConfirmFormBase { '#theme' => 'username', '#account' => $account, ]; - return $this->t('By breaking this lock, any unsaved changes made by @user will be lost.', ['@user' => drupal_render($username)]); + return $this->t('By breaking this lock, any unsaved changes made by @user will be lost.', ['@user' => \Drupal::service('renderer')->render($username)]); } /** diff --git a/core/modules/views_ui/src/ViewEditForm.php b/core/modules/views_ui/src/ViewEditForm.php index 67d1229555d2..fe3d86fc6629 100644 --- a/core/modules/views_ui/src/ViewEditForm.php +++ b/core/modules/views_ui/src/ViewEditForm.php @@ -129,7 +129,7 @@ class ViewEditForm extends ViewFormBase { '#account' => $this->entityManager->getStorage('user')->load($view->lock->owner), ]; $lock_message_substitutions = [ - '@user' => drupal_render($username), + '@user' => \Drupal::service('renderer')->render($username), '@age' => $this->dateFormatter->formatTimeDiffSince($view->lock->updated), ':url' => $view->url('break-lock-form'), ]; diff --git a/core/tests/Drupal/Tests/Core/Render/RendererBubblingTest.php b/core/tests/Drupal/Tests/Core/Render/RendererBubblingTest.php index 3e1ee407ecb7..0666367c218b 100644 --- a/core/tests/Drupal/Tests/Core/Render/RendererBubblingTest.php +++ b/core/tests/Drupal/Tests/Core/Render/RendererBubblingTest.php @@ -46,7 +46,7 @@ class RendererBubblingTest extends RendererTestBase { $element = [ '#type' => 'container', '#cache' => [ - 'keys' => ['simpletest', 'drupal_render', 'children_attached'], + 'keys' => ['simpletest', 'renderer', 'children_attached'], ], '#attached' => ['library' => ['test/parent']], '#title' => 'Parent', @@ -68,7 +68,7 @@ class RendererBubblingTest extends RendererTestBase { // Load the element from cache and verify the presence of the #attached // JavaScript. - $element = ['#cache' => ['keys' => ['simpletest', 'drupal_render', 'children_attached']]]; + $element = ['#cache' => ['keys' => ['simpletest', 'renderer', 'children_attached']]]; $this->assertTrue(strlen($this->renderer->renderRoot($element)) > 0, 'The element was retrieved from cache.'); $this->assertEquals($element['#attached']['library'], $expected_libraries, 'The element, child and subchild #attached libraries are included.'); } diff --git a/core/tests/Drupal/Tests/Core/Render/RendererPlaceholdersTest.php b/core/tests/Drupal/Tests/Core/Render/RendererPlaceholdersTest.php index 00426c252d72..a92c363619d7 100644 --- a/core/tests/Drupal/Tests/Core/Render/RendererPlaceholdersTest.php +++ b/core/tests/Drupal/Tests/Core/Render/RendererPlaceholdersTest.php @@ -996,7 +996,7 @@ HTML; $this->assertSame($element['#attached']['drupalSettings'], $expected_js_settings, '#attached is modified; both the original JavaScript setting and the ones added by each placeholder #lazy_builder callback exist.'); // GET request: validate cached data. - $cached_element = $this->memoryCache->get('simpletest:drupal_render:children_placeholders')->data; + $cached_element = $this->memoryCache->get('simpletest:renderer:children_placeholders')->data; $expected_element = [ '#attached' => [ 'drupalSettings' => [ @@ -1066,7 +1066,7 @@ HTML; $test_element = [ '#type' => 'details', '#cache' => [ - 'keys' => ['simpletest', 'drupal_render', 'children_placeholders'], + 'keys' => ['simpletest', 'renderer', 'children_placeholders'], ], '#title' => 'Parent', '#attached' => [