By claudiu.cristea on
Change record status:
Draft (View all draft change records)
Project:
Introduced in branch:
11.4.x
Introduced in version:
11.4.0
Issue links:
Description:
The check_markup() function is deprecated and no replacement is provided. It's always recommended to return a renderable array, when possible, without flattening as markup, to preserve the cacheability metadata.
Before
$formatted_text = check_markup($text, 'basic_html', $langcode, $filter_types_to_skip);
After
$formatted_text = [
'#type' => 'processed_text',
'#text' => $text,
'#format' => 'basic_html',
'#filter_types_to_skip' => $filter_types_to_skip,
'#langcode' => $langcode,
];
Particular cases:
- Mail: Future Drupal mail system development will pipe the mail preparation through Twig (for both, plain and HTML messages). This will remove the need to manually render the renderable array (see #3539651: Introduce email plugins). Until that API is available, 3rd-party code could render the above array build, but only cases such as email body, where the cache metadata makes no sense.
- Tests: Many tests are only asserting that a text has been formatted correctly. For convenience, Drupal is providing the
\Drupal\Tests\filter\Traits\ProcessedTextTestTraittrait with a helper method, facilitating the testing.
Impacts:
Module developers
Site templates, recipes and distribution developers