By dimitriskr on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
10.3.x
Introduced in version:
10.3.0
Issue links:
Description:
\Drupal\Core\Render\RendererInterface::renderPlain() is deprecated. Use \Drupal\Core\Render\RendererInterface::renderInIsolation() instead.
Before
\Drupal::service('renderer')->renderPlain($elements);
After
\Drupal::service('renderer')->renderInIsolation($elements);
Via the DeprecationHelper
@see DeprecationHelper helps modules support multiple versions of core
/** @var \Drupal\Core\Render\RendererInterface $renderer */
$renderer = \Drupal::service('renderer');
$output = DeprecationHelper::backwardsCompatibleCall(
currentVersion: \Drupal::VERSION,
deprecatedVersion: '10.3',
currentCallable: fn() => $renderer->renderInIsolation($elements),
deprecatedCallable: fn() => $renderer->renderPlain($elements),
);
Impacts:
Module developers
Comments
Using the DeprecationHelper to maintain backward compatibility
Below is how to use the DeprecationHelper to maintain backward compatibility.
/** @var \Drupal\Core\Render
Use below code block for backward compatibility as suggested above has missing closing bracket.
Added this to the change
Added this to the change record itself.