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
Beta phase evaluation
Issue category | Task because this removes usages of a deprecated function. |
---|---|
Issue priority | Not critical because the function in question is not to be removed in this release cycle. |
Comment | File | Size | Author |
---|---|---|---|
#1 | replace_drupal_render-2472795-1.patch | 586 bytes | mitrpaka |
Comments
Comment #1
mitrpaka CreditAttribution: mitrpaka commented\Drupal::service('renderer')->render() used for old prodecural code.
Comment #2
cilefen CreditAttribution: cilefen commentedThis looks ok to me. @mitrpaka Can you see if there is a test covering this render?
Comment #3
Mile23Comment #4
xjmThanks for your work on this issue! Per discussion with @alexpott and @webchick, we should do these conversions in a single patch in #2393329: Replace all drupal_render calls with the service, and inject it, if possible.. The change will need to be postponed to 8.1.x at least since it is no longer an allowed change during the Drupal 8 beta. See #2393329-39: Replace all drupal_render calls with the service, and inject it, if possible..