You are here

class PlainTextOutput in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Component/Render/PlainTextOutput.php \Drupal\Component\Render\PlainTextOutput
  2. 9 core/lib/Drupal/Component/Render/PlainTextOutput.php \Drupal\Component\Render\PlainTextOutput

Provides an output strategy for transforming HTML into simple plain text.

Use this when rendering a given HTML string into a plain text string that does not need special formatting, such as a label or an email subject.

Returns a string with HTML tags stripped and HTML entities decoded suitable for email or other non-HTML contexts.

Hierarchy

  • class \Drupal\Component\Render\PlainTextOutput implements \Drupal\Component\Render\OutputStrategyInterface

Expanded class hierarchy of PlainTextOutput

13 files declare their use of PlainTextOutput
Attribute.php in core/lib/Drupal/Core/Template/Attribute.php
EmailAction.php in core/lib/Drupal/Core/Action/Plugin/Action/EmailAction.php
FileUpload.php in core/modules/jsonapi/src/Controller/FileUpload.php
FileUploadResourceTestBase.php in core/modules/rest/tests/src/Functional/FileUploadResourceTestBase.php
FileUploadTest.php in core/modules/jsonapi/tests/src/Functional/FileUploadTest.php

... See full list

File

core/lib/Drupal/Component/Render/PlainTextOutput.php, line 16

Namespace

Drupal\Component\Render
View source
class PlainTextOutput implements OutputStrategyInterface {

  /**
   * {@inheritdoc}
   */
  public static function renderFromHtml($string) {
    return Html::decodeEntities(strip_tags((string) $string));
  }

}

Members