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.
By ParisLiakos on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
8.0.x
Introduced in version:
8.x
Issue links:
Description:
Drupal 7
$string = format_string($string, $params);
$safe_string = check_plain($string);
$placeholder_string = drupal_placeholder($string);
Drupal 8
use Drupal\Component\Render\FormattableMarkup;
use Drupal\Component\Utility\Html;
$string = new FormattableMarkup($string, $params);
$safe_string = Html::escape($string);
// Note that the 'placeholder' class should not be used only to italicize text, and
// therefore there are few valid usecases for the code below.
$placeholder_string = new FormattableMarkup('%text', ['%text' => $string]);
Related change records
SafeMarkup methods are removed
See Twig autoescape enabled and text sanitization APIs updated for a full list of related change records.
Impacts:
Module developers