class HtmlEscapedText in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/lib/Drupal/Component/Render/HtmlEscapedText.php \Drupal\Component\Render\HtmlEscapedText
Escapes HTML syntax characters to HTML entities for display in markup.
This class can be used to provide theme engine-like late escaping functionality.
Hierarchy
- class \Drupal\Component\Render\HtmlEscapedText implements \Drupal\Component\Render\Countable, MarkupInterface
Expanded class hierarchy of HtmlEscapedText
Related topics
4 files declare their use of HtmlEscapedText
- HtmlEscapedTextTest.php in core/
tests/ Drupal/ Tests/ Component/ Render/ HtmlEscapedTextTest.php - Contains \Drupal\Tests\Component\Render\HtmlEscapedTextTest.
- SafeMarkup.php in core/
lib/ Drupal/ Component/ Utility/ SafeMarkup.php - Contains \Drupal\Component\Utility\SafeMarkup.
- SafeMarkupTest.php in core/
tests/ Drupal/ Tests/ Component/ Utility/ SafeMarkupTest.php - Contains \Drupal\Tests\Component\Utility\SafeMarkupTest.
- Token.php in core/
lib/ Drupal/ Core/ Utility/ Token.php - Contains \Drupal\Core\Utility\Token.
File
- core/
lib/ Drupal/ Component/ Render/ HtmlEscapedText.php, line 21 - Contains \Drupal\Component\Render\HtmlEscapedText.
Namespace
Drupal\Component\RenderView source
class HtmlEscapedText implements MarkupInterface, \Countable {
/**
* The string to escape.
*
* @var string
*/
protected $string;
/**
* Constructs an HtmlEscapedText object.
*
* @param $string
* The string to escape. This value will be cast to a string.
*/
public function __construct($string) {
$this->string = (string) $string;
}
/**
* {@inheritdoc}
*/
public function __toString() {
return Html::escape($this->string);
}
/**
* {@inheritdoc}
*/
public function count() {
return Unicode::strlen($this->string);
}
/**
* {@inheritdoc}
*/
public function jsonSerialize() {
return $this
->__toString();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
HtmlEscapedText:: |
protected | property | The string to escape. | |
HtmlEscapedText:: |
public | function | ||
HtmlEscapedText:: |
public | function | ||
HtmlEscapedText:: |
public | function | Constructs an HtmlEscapedText object. | |
HtmlEscapedText:: |
public | function |
Returns markup. Overrides MarkupInterface:: |