Parent issue #2393329: Replace all drupal_render calls with the service, and inject it, if possible.

Problem/Motivation

drupal_render() was marked as deprecated, though its still called in quite some places.

Proposed resolution

  1. Avoid rendering manually by letting the template who is printing the variable render it.
  2. Inject the renderer service into service, which uses drupal_render()
  3. Use \Drupal::service('renderer')->render() for old prodecural code.

Remaining tasks

  1. Find all the actionable fixes: Search for drupal_render(
  2. Create a Patch
  3. Review

User interface changes

None

API changes

None

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

keopx’s picture

Assigned: keopx » Unassigned
Status: Active » Needs review
FileSize
3.38 KB
cilefen’s picture

Status: Needs review » Needs work
keopx’s picture

Assigned: Unassigned » keopx
keopx’s picture

Assigned: keopx » Unassigned
Status: Needs work » Needs review
FileSize
1.73 KB
3.42 KB
Mile23’s picture

Status: Needs review » Needs work

There are a couple of references to drupal_render() in doc blocks in AggregatorController.php.

There's also a use of drupal_render_root() in Rss.php, but that might be out of scope of this issue.

keopx’s picture

Assigned: Unassigned » keopx
keopx’s picture

Assigned: keopx » Unassigned
Status: Needs work » Needs review
FileSize
4.92 KB
1.24 KB

Status: Needs review » Needs work

The last submitted patch, 7: aggregator_replace_drupal_render-2473161-7.patch, failed testing.

keopx’s picture

Assigned: Unassigned » keopx
keopx’s picture

Assigned: keopx » Unassigned
Status: Needs work » Needs review
FileSize
4.93 KB
445 bytes
cilefen’s picture

Status: Needs review » Needs work
+++ b/core/modules/aggregator/src/Plugin/views/row/Rss.php
@@ -79,7 +79,7 @@ public function render($row) {
-    return drupal_render_root($build);
+    return  \Drupal::service('renderer')->renderRoot($build);

You could inject the render into RssPluginBase.

cilefen’s picture

Status: Needs work » Closed (duplicate)