Rename SafeStringInterface to MarkupInterface and move related classes

Created on 29 September 2015, over 9 years ago
Updated 22 March 2025, 15 days ago

Problem/Motivation

SafeStringInterface is badly named for two reasons:

  1. The output is not necessarily safe
  2. The output is more than just a string - it is a string formatted for output in the HTML context

Proposed resolution

Rename SafeStringInterface to MarkupInterface and move it to Drupal\Component\Render and do quite a few other changes to make this consistent:

  • Drupal\Component\Utility\FormattableString to Drupal\Component\Render\FormattableMarkup
  • Drupal\Core\StringTranslation\TranslatableString to Drupal\Core\StringTranslation\TranslatableMarkup
  • Drupal\Component\Utility\PlainTextOutput to Drupal\Component\Render\PlainTextOutput
  • Drupal\Component\Utility\SafeStringTrait to Drupal\Component\Render\MarkupTrait
  • Drupal\Core\Render\SafeString to Drupal\Core\Render\Markup
  • Drupal\Core\Field\FieldFilteredString to Drupal\Core\Field\FieldFilteredMarkup
  • Drupal\filter\Render\FilteredString to Drupal\filter\Render\FilteredMarkup
  • Drupal\views\Render\ViewsRenderPipelineSafeString to Drupal\views\Render\ViewsRenderPipelineMarkup

The basic reason why this change makes sense is that it clarifies that the purpose of the entire render system is to produce markup. Another reason is that aligns the names with Twig_Markup a class that Twig provides something similar.

Is the disruption worth it? @alexpott thinks so - the more clarity this system has the better.

Remaining tasks

Commit

User interface changes

No

API changes

Yes, some recently introduced classes will be renamed, as well as some classes that had existed for longer but are confusingly/harmfully named.
MarkupInterface is not @internal anymore

πŸ“Œ Task
Status

Fixed

Version

8.0 ⚰️

Component

base system

Created by

πŸ‡¬πŸ‡§United Kingdom alexpott πŸ‡ͺπŸ‡ΊπŸŒ

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • First commit to issue fork.
Production build 0.71.5 2024