Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
- Avoid rendering manually by letting the template who is printing the variable render it.
- Inject the renderer service into service, which uses drupal_render()
- Use \Drupal::service('renderer')->render() for old prodecural code.
Remaining tasks
- Find all the actionable fixes: Search for
drupal_render(
- Create a Patch
- Review
User interface changes
None
API changes
None
Comments
Comment #1
keopxComment #2
cilefen CreditAttribution: cilefen commentedThe comment in #2472975-5: Replace all drupal_render calls in core/modules/ckeditor applies here.
Comment #3
keopxComment #4
keopxComment #5
Mile23There are a couple of references to
drupal_render()
in doc blocks inAggregatorController.php
.There's also a use of
drupal_render_root()
inRss.php
, but that might be out of scope of this issue.Comment #6
keopxComment #7
keopxComment #9
keopxComment #10
keopxComment #11
cilefen CreditAttribution: cilefen commentedYou could inject the render into RssPluginBase.
Comment #12
cilefen CreditAttribution: cilefen commentedThis is a duplicate as per #2393329-41: Replace all drupal_render calls with the service, and inject it, if possible.