Mercurial > hg > isophonics-drupal-site
comparison core/lib/Drupal/Component/Render/PlainTextOutput.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\Component\Render; | |
4 | |
5 use Drupal\Component\Utility\Html; | |
6 | |
7 /** | |
8 * Provides an output strategy for transforming HTML into simple plain text. | |
9 * | |
10 * Use this when rendering a given HTML string into a plain text string that | |
11 * does not need special formatting, such as a label or an email subject. | |
12 * | |
13 * Returns a string with HTML tags stripped and HTML entities decoded suitable | |
14 * for email or other non-HTML contexts. | |
15 */ | |
16 class PlainTextOutput implements OutputStrategyInterface { | |
17 | |
18 /** | |
19 * {@inheritdoc} | |
20 */ | |
21 public static function renderFromHtml($string) { | |
22 return Html::decodeEntities(strip_tags((string) $string)); | |
23 } | |
24 | |
25 } |