Update to drupal 8.0.0-rc1. For more information, see https://www.drupal.org/node/2582663
This commit is contained in:
parent
eb34d130a8
commit
f32e58e4b1
8476 changed files with 211648 additions and 170042 deletions
61
core/lib/Drupal/Component/Render/HtmlEscapedText.php
Normal file
61
core/lib/Drupal/Component/Render/HtmlEscapedText.php
Normal file
|
@ -0,0 +1,61 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Component\Render\HtmlEscapedText.
|
||||
*/
|
||||
|
||||
namespace Drupal\Component\Render;
|
||||
|
||||
use Drupal\Component\Utility\Html;
|
||||
use Drupal\Component\Utility\Unicode;
|
||||
|
||||
/**
|
||||
* Escapes HTML syntax characters to HTML entities for display in markup.
|
||||
*
|
||||
* This class can be used to provide theme engine-like late escaping
|
||||
* functionality.
|
||||
*
|
||||
* @ingroup sanitization
|
||||
*/
|
||||
class HtmlEscapedText implements MarkupInterface {
|
||||
|
||||
/**
|
||||
* 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();
|
||||
}
|
||||
|
||||
}
|
Reference in a new issue