diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index b7178416649e0e2780c94d117fee24b6c2d3c73b..adc29235a282fd886a00293706785c1a462c0414 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -13,7 +13,7 @@ use Drupal\Core\DrupalKernel; use Drupal\Core\Extension\ExtensionDiscovery; use Drupal\Core\Logger\RfcLogLevel; -use Drupal\Core\Render\SafeString; +use Drupal\Core\Render\Markup; use Drupal\Core\Session\AccountInterface; use Drupal\Core\Site\Settings; use Drupal\Core\Utility\Error; @@ -403,7 +403,7 @@ function watchdog_exception($type, Exception $exception, $message = NULL, $varia * drupal_set_message(t('An error occurred and processing did not complete.'), 'error'); * @endcode * - * @param string|\Drupal\Component\Utility\SafeStringInterface $message + * @param string|\Drupal\Component\Render\MarkupInterface $message * (optional) The translated message to be displayed to the user. For * consistency with other messages, it should begin with a capital letter and * end with a period. @@ -450,13 +450,13 @@ function drupal_set_message($message = NULL, $type = 'status', $repeat = FALSE) $_SESSION['messages'][$type] = array(); } - // Convert strings which are safe to the simplest SafeString objects. - if (!($message instanceof SafeString) && SafeMarkup::isSafe($message)) { - $message = SafeString::create((string) $message); + // Convert strings which are safe to the simplest Markup objects. + if (!($message instanceof Markup) && SafeMarkup::isSafe($message)) { + $message = Markup::create((string) $message); } // Do not use strict type checking so that equivalent string and - // SafeStringInterface objects are detected. + // MarkupInterface objects are detected. if ($repeat || !in_array($message, $_SESSION['messages'][$type])) { $_SESSION['messages'][$type][] = $message; } diff --git a/core/includes/common.inc b/core/includes/common.inc index e66261e447e4870d44c54ac7f2c62500528ac805..cb5d8b01a1c8d9f50d732d372c61a6e44f907f57 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -22,10 +22,10 @@ use Drupal\Core\Asset\AttachedAssets; use Drupal\Core\Cache\Cache; use Drupal\Core\Language\LanguageInterface; -use Drupal\Core\Render\SafeString; +use Drupal\Core\Render\Markup; use Drupal\Core\Render\Renderer; use Drupal\Core\Site\Settings; -use Drupal\Core\StringTranslation\TranslatableString; +use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\Core\Url; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Request; @@ -33,7 +33,7 @@ use Drupal\Component\Utility\NestedArray; use Drupal\Core\Datetime\DrupalDateTime; use Drupal\Core\Routing\GeneratorNotInitializedException; -use Drupal\Core\StringTranslation\PluralTranslatableString; +use Drupal\Core\StringTranslation\PluralTranslatableMarkup; use Drupal\Core\Template\Attribute; use Drupal\Core\Render\BubbleableMetadata; use Drupal\Core\Render\Element; @@ -144,10 +144,10 @@ * The delimiter used to split plural strings. * * @deprecated in Drupal 8.0.x-dev, will be removed before Drupal 9.0.0. - * Use \Drupal\Core\StringTranslation\PluralTranslatableString::DELIMITER + * Use \Drupal\Core\StringTranslation\PluralTranslatableMarkup::DELIMITER * instead. */ -const LOCALE_PLURAL_DELIMITER = PluralTranslatableString::DELIMITER; +const LOCALE_PLURAL_DELIMITER = PluralTranslatableMarkup::DELIMITER; /** * Prepares a 'destination' URL query parameter for use with url(). @@ -262,7 +262,7 @@ function check_url($uri) { * Optional language code to translate to a language other than what is used * to display the page. * - * @return \Drupal\Core\StringTranslation\TranslatableString + * @return \Drupal\Core\StringTranslation\TranslatableMarkup * A translated string representation of the size. */ function format_size($size, $langcode = NULL) { @@ -284,21 +284,21 @@ function format_size($size, $langcode = NULL) { $options = ['langcode' => $langcode]; switch ($unit) { case 'KB': - return new TranslatableString('@size KB', $args, $options); + return new TranslatableMarkup('@size KB', $args, $options); case 'MB': - return new TranslatableString('@size MB', $args, $options); + return new TranslatableMarkup('@size MB', $args, $options); case 'GB': - return new TranslatableString('@size GB', $args, $options); + return new TranslatableMarkup('@size GB', $args, $options); case 'TB': - return new TranslatableString('@size TB', $args, $options); + return new TranslatableMarkup('@size TB', $args, $options); case 'PB': - return new TranslatableString('@size PB', $args, $options); + return new TranslatableMarkup('@size PB', $args, $options); case 'EB': - return new TranslatableString('@size EB', $args, $options); + return new TranslatableMarkup('@size EB', $args, $options); case 'ZB': - return new TranslatableString('@size ZB', $args, $options); + return new TranslatableMarkup('@size ZB', $args, $options); case 'YB': - return new TranslatableString('@size YB', $args, $options); + return new TranslatableMarkup('@size YB', $args, $options); } } } @@ -967,7 +967,7 @@ function drupal_render(&$elements, $is_recursive_call = FALSE) { * can be passed in to save another run of * \Drupal\Core\Render\Element::children(). * - * @return string|\Drupal\Component\Utility\SafeStringInterface + * @return string|\Drupal\Component\Render\MarkupInterface * The rendered HTML of all children of the element. * * @see drupal_render() @@ -982,7 +982,7 @@ function drupal_render_children(&$element, $children_keys = NULL) { $output .= drupal_render($element[$key]); } } - return SafeString::create($output); + return Markup::create($output); } /** diff --git a/core/includes/errors.inc b/core/includes/errors.inc index 1757acd6e000f6c231b6a22a27f4cf9cb07969bc..47954806561597e35215ca36a43bf0b6fdce0aa8 100644 --- a/core/includes/errors.inc +++ b/core/includes/errors.inc @@ -8,7 +8,7 @@ use Drupal\Component\Utility\SafeMarkup; use Drupal\Component\Utility\Xss; use Drupal\Core\Logger\RfcLogLevel; -use Drupal\Core\Render\SafeString; +use Drupal\Core\Render\Markup; use Drupal\Core\Utility\Error; use Symfony\Component\HttpFoundation\Response; @@ -74,7 +74,7 @@ function _drupal_error_handler_real($error_level, $message, $filename, $line, $c '%type' => isset($types[$error_level]) ? $severity_msg : 'Unknown error', // The standard PHP error handler considers that the error messages // are HTML. We mimick this behavior here. - '@message' => SafeString::create(Xss::filterAdmin($message)), + '@message' => Markup::create(Xss::filterAdmin($message)), '%function' => $caller['function'], '%file' => $caller['file'], '%line' => $caller['line'], diff --git a/core/includes/theme.inc b/core/includes/theme.inc index 61bc83f1b783d66cf9c4c8ad3160add202b3a378..a9a88265e33a1784e438f5b1db80763451013274 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -12,7 +12,7 @@ use Drupal\Component\Utility\Crypt; use Drupal\Component\Utility\Html; use Drupal\Component\Utility\SafeMarkup; -use Drupal\Component\Utility\SafeStringInterface; +use Drupal\Component\Render\MarkupInterface; use Drupal\Component\Utility\Unicode; use Drupal\Component\Utility\Xss; use Drupal\Core\Config\Config; @@ -22,7 +22,7 @@ use Drupal\Core\Theme\ThemeSettings; use Drupal\Component\Utility\NestedArray; use Drupal\Core\Render\Element; -use Drupal\Core\Render\SafeString; +use Drupal\Core\Render\Markup; /** * @defgroup content_flags Content markers @@ -386,7 +386,7 @@ function theme_get_setting($setting_name, $theme = NULL) { * https://www.drupal.org/node/2575065 */ function theme_render_and_autoescape($arg) { - if ($arg instanceOf SafeStringInterface) { + if ($arg instanceOf MarkupInterface) { return (string) $arg; } $return = NULL; @@ -1292,7 +1292,7 @@ function template_preprocess_html(&$variables) { if (!empty($variables['page']['#title'])) { $head_title = array( // Marking the title as safe since it has had the tags stripped. - 'title' => SafeString::create(trim(strip_tags($variables['page']['#title']))), + 'title' => Markup::create(trim(strip_tags($variables['page']['#title']))), 'name' => $site_config->get('name'), ); } diff --git a/core/lib/Drupal/Component/Utility/FormattableString.php b/core/lib/Drupal/Component/Render/FormattableMarkup.php similarity index 84% rename from core/lib/Drupal/Component/Utility/FormattableString.php rename to core/lib/Drupal/Component/Render/FormattableMarkup.php index c069da2d4dfe7ac1134f1fa128e0415280431242..c8b9ae42079b471151f809238966de7ba7d1d9a9 100644 --- a/core/lib/Drupal/Component/Utility/FormattableString.php +++ b/core/lib/Drupal/Component/Render/FormattableMarkup.php @@ -2,10 +2,15 @@ /** * @file - * Contains Drupal\Component\Utility\FormattableString. + * Contains Drupal\Component\Render\FormattableMarkup. */ -namespace Drupal\Component\Utility; +namespace Drupal\Component\Render; + +use Drupal\Component\Utility\Html; +use Drupal\Component\Utility\SafeMarkup; +use Drupal\Component\Utility\Unicode; +use Drupal\Component\Utility\UrlHelper; /** * Formats a string for HTML display by replacing variable placeholders. @@ -13,11 +18,11 @@ * When cast to a string, this object replaces variable placeholders in the * string with the arguments passed in during construction and escapes the * values so they can be safely displayed as HTML. See the documentation of - * \Drupal\Component\Utility\FormattableString::placeholderFormat() for - * details on the supported placeholders and how to use them securely. Incorrect - * use of this class can result in security vulnerabilities. + * \Drupal\Component\Render\FormattableMarkup::placeholderFormat() for details + * on the supported placeholders and how to use them securely. Incorrect use of + * this class can result in security vulnerabilities. * - * In most cases, you should use TranslatableString or PluralTranslatableString + * In most cases, you should use TranslatableMarkup or PluralTranslatableMarkup * rather than this object, since they will translate the text (on * non-English-only sites) in addition to formatting it. Variables concatenated * without the insertion of language-specific words or punctuation are some @@ -56,11 +61,11 @@ * * @ingroup sanitization * - * @see \Drupal\Core\StringTranslation\TranslatableString - * @see \Drupal\Core\StringTranslation\PluralTranslatableString - * @see \Drupal\Component\Utility\FormattableString::placeholderFormat() + * @see \Drupal\Core\StringTranslation\TranslatableMarkup + * @see \Drupal\Core\StringTranslation\PluralTranslatableMarkup + * @see \Drupal\Component\Render\FormattableMarkup::placeholderFormat() */ -class FormattableString implements SafeStringInterface { +class FormattableMarkup implements MarkupInterface { /** * The arguments to replace placeholders with. @@ -75,12 +80,12 @@ class FormattableString implements SafeStringInterface { * @param string $string * A string containing placeholders. The string itself will not be escaped, * any unsafe content must be in $args and inserted via placeholders. - * @param array $args + * @param array $arguments * An array with placeholder replacements, keyed by placeholder. See - * \Drupal\Component\Utility\FormattableString::placeholderFormat() for + * \Drupal\Component\Render\FormattableMarkup::placeholderFormat() for * additional information about placeholders. * - * @see \Drupal\Component\Utility\FormattableString::placeholderFormat() + * @see \Drupal\Component\Render\FormattableMarkup::placeholderFormat() */ public function __construct($string, array $arguments) { $this->string = (string) $string; @@ -125,17 +130,17 @@ public function jsonSerialize() { * An associative array of replacements. Each array key should be the same * as a placeholder in $string. The corresponding value should be a string * or an object that implements - * \Drupal\Component\Utility\SafeStringInterface. The value replaces the + * \Drupal\Component\Render\MarkupInterface. The value replaces the * placeholder in $string. Sanitization and formatting will be done before * replacement. The type of sanitization and formatting depends on the first * character of the key: * - @variable: When the placeholder replacement value is: * - A string, the replaced value in the returned string will be sanitized * using \Drupal\Component\Utility\Html::escape(). - * - A SafeStringInterface object, the replaced value in the returned - * string will not be sanitized. - * - A SafeStringInterface object cast to a string, the replaced value in - * the returned string be forcibly sanitized using + * - A MarkupInterface object, the replaced value in the returned string + * will not be sanitized. + * - A MarkupInterface object cast to a string, the replaced value in the + * returned string be forcibly sanitized using * \Drupal\Component\Utility\Html::escape(). * @code * $this->placeholderFormat('This will force HTML-escaping of the replacement value: @text', ['@text' => (string) $safe_string_interface_object)); @@ -180,8 +185,8 @@ public function jsonSerialize() { * * @ingroup sanitization * - * @see \Drupal\Core\StringTranslation\TranslatableString - * @see \Drupal\Core\StringTranslation\PluralTranslatableString + * @see \Drupal\Core\StringTranslation\TranslatableMarkup + * @see \Drupal\Core\StringTranslation\PluralTranslatableMarkup * @see \Drupal\Component\Utility\Html::escape() * @see \Drupal\Component\Utility\UrlHelper::stripDangerousProtocols() * @see \Drupal\Core\Url::fromUri() @@ -192,8 +197,8 @@ protected static function placeholderFormat($string, array $args) { switch ($key[0]) { case '@': // Escape if the value is not an object from a class that implements - // \Drupal\Component\Utility\SafeStringInterface, for example strings - // will be escaped. + // \Drupal\Component\Render\MarkupInterface, for example strings will + // be escaped. // \Drupal\Component\Utility\SafeMarkup\SafeMarkup::isSafe() may // return TRUE for content that is safe within HTML fragments, but not // within other contexts, so this placeholder type must not be used @@ -210,7 +215,7 @@ protected static function placeholderFormat($string, array $args) { // attribute to be encoded. If a caller wants to pass a value that is // extracted from HTML and therefore is already HTML encoded, it must // invoke - // \Drupal\Component\Utility\OutputStrategyInterface::renderFromHtml() + // \Drupal\Component\Render\OutputStrategyInterface::renderFromHtml() // on it prior to passing it in as a placeholder value of this type. // @todo Add some advice and stronger warnings. // https://www.drupal.org/node/2569041. @@ -235,7 +240,7 @@ protected static function placeholderFormat($string, array $args) { /** * Escapes a placeholder replacement value if needed. * - * @param string|\Drupal\Component\Utility\SafeStringInterface $value + * @param string|\Drupal\Component\Render\MarkupInterface $value * A placeholder replacement value. * * @return string diff --git a/core/lib/Drupal/Component/Render/MarkupInterface.php b/core/lib/Drupal/Component/Render/MarkupInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..2da4e13b7b26c75471db1b1119308632324b1184 --- /dev/null +++ b/core/lib/Drupal/Component/Render/MarkupInterface.php @@ -0,0 +1,45 @@ +get(); } else { diff --git a/core/lib/Drupal/Core/Annotation/Translation.php b/core/lib/Drupal/Core/Annotation/Translation.php index 0f1d743b1d10e1f153e30fa1fcecf6fc09b806fc..83cd6f643e0b4eed78e3e4dd262b6b51b9b59510 100644 --- a/core/lib/Drupal/Core/Annotation/Translation.php +++ b/core/lib/Drupal/Core/Annotation/Translation.php @@ -8,7 +8,7 @@ namespace Drupal\Core\Annotation; use Drupal\Component\Annotation\AnnotationBase; -use Drupal\Core\StringTranslation\TranslatableString; +use Drupal\Core\StringTranslation\TranslatableMarkup; /** * @defgroup plugin_translatable Annotation for translatable text @@ -60,7 +60,7 @@ class Translation extends AnnotationBase { /** * The string translation object. * - * @var \Drupal\Core\StringTranslation\TranslatableString + * @var \Drupal\Core\StringTranslation\TranslatableMarkup */ protected $translation; @@ -86,7 +86,7 @@ public function __construct(array $values) { 'context' => $values['context'], ); } - $this->translation = new TranslatableString($string, $arguments, $options); + $this->translation = new TranslatableMarkup($string, $arguments, $options); } /** diff --git a/core/lib/Drupal/Core/Block/BlockBase.php b/core/lib/Drupal/Core/Block/BlockBase.php index 5684e3d1c79d4b1f541c693a922f826bf27994dc..fe5c12e1761f8c5a6218c47088249984ab8ee943 100644 --- a/core/lib/Drupal/Core/Block/BlockBase.php +++ b/core/lib/Drupal/Core/Block/BlockBase.php @@ -48,7 +48,7 @@ public function label() { $definition = $this->getPluginDefinition(); // Cast the admin label to a string since it is an object. - // @see \Drupal\Core\StringTranslation\TranslatableString + // @see \Drupal\Core\StringTranslation\TranslatableMarkup return (string) $definition['admin_label']; } diff --git a/core/lib/Drupal/Core/Config/ConfigBase.php b/core/lib/Drupal/Core/Config/ConfigBase.php index b9a4e6145e2411a0b6f3b4a83be0eef815d4e4e1..0d66c66bd9915affaca9cbfe5a13c5804107849a 100644 --- a/core/lib/Drupal/Core/Config/ConfigBase.php +++ b/core/lib/Drupal/Core/Config/ConfigBase.php @@ -8,7 +8,7 @@ namespace Drupal\Core\Config; use Drupal\Component\Utility\NestedArray; -use Drupal\Component\Utility\SafeStringInterface; +use Drupal\Component\Render\MarkupInterface; use Drupal\Core\Cache\Cache; use Drupal\Core\Cache\RefinableCacheableDependencyInterface; use Drupal\Core\Cache\RefinableCacheableDependencyTrait; @@ -278,7 +278,7 @@ public function getCacheMaxAge() { } /** - * Casts any objects that implement SafeStringInterface to string. + * Casts any objects that implement MarkupInterface to string. * * @param mixed $data * The configuration data. @@ -287,12 +287,12 @@ public function getCacheMaxAge() { * The data with any safe strings cast to string. */ protected function castSafeStrings($data) { - if ($data instanceof SafeStringInterface) { + if ($data instanceof MarkupInterface) { $data = (string) $data; } else if (is_array($data)) { array_walk_recursive($data, function (&$value) { - if ($value instanceof SafeStringInterface) { + if ($value instanceof MarkupInterface) { $value = (string) $value; } }); diff --git a/core/lib/Drupal/Core/Entity/Annotation/ConfigEntityType.php b/core/lib/Drupal/Core/Entity/Annotation/ConfigEntityType.php index 5d4c3da115428ef1359428a8c53452e5d2cd3d14..4c7524bc147e6615c30e9edf058c2a046cdc6e3a 100644 --- a/core/lib/Drupal/Core/Entity/Annotation/ConfigEntityType.php +++ b/core/lib/Drupal/Core/Entity/Annotation/ConfigEntityType.php @@ -6,7 +6,7 @@ */ namespace Drupal\Core\Entity\Annotation; -use Drupal\Core\StringTranslation\TranslatableString; +use Drupal\Core\StringTranslation\TranslatableMarkup; /** * Defines a config entity type annotation object. @@ -37,7 +37,7 @@ class ConfigEntityType extends EntityType { * {@inheritdoc} */ public function get() { - $this->definition['group_label'] = new TranslatableString('Configuration', array(), array('context' => 'Entity type group')); + $this->definition['group_label'] = new TranslatableMarkup('Configuration', array(), array('context' => 'Entity type group')); return parent::get(); } diff --git a/core/lib/Drupal/Core/Entity/Annotation/ContentEntityType.php b/core/lib/Drupal/Core/Entity/Annotation/ContentEntityType.php index 9c59a6436332997f32fd0194e9c9b84d27e3300d..a879704f9f6df35c23d55bb3bf4901d3a8a31a2b 100644 --- a/core/lib/Drupal/Core/Entity/Annotation/ContentEntityType.php +++ b/core/lib/Drupal/Core/Entity/Annotation/ContentEntityType.php @@ -6,7 +6,7 @@ */ namespace Drupal\Core\Entity\Annotation; -use Drupal\Core\StringTranslation\TranslatableString; +use Drupal\Core\StringTranslation\TranslatableMarkup; /** * Defines a content entity type annotation object. @@ -37,7 +37,7 @@ class ContentEntityType extends EntityType { * {@inheritdoc} */ public function get() { - $this->definition['group_label'] = new TranslatableString('Content', array(), array('context' => 'Entity type group')); + $this->definition['group_label'] = new TranslatableMarkup('Content', array(), array('context' => 'Entity type group')); return parent::get(); } diff --git a/core/lib/Drupal/Core/Field/AllowedTagsXssTrait.php b/core/lib/Drupal/Core/Field/AllowedTagsXssTrait.php index c58096a1779f135874364202e9b8086639a25473..c889615233c55eb8123fdfec103387f1741374cb 100644 --- a/core/lib/Drupal/Core/Field/AllowedTagsXssTrait.php +++ b/core/lib/Drupal/Core/Field/AllowedTagsXssTrait.php @@ -10,9 +10,9 @@ * Useful methods when dealing with displaying allowed tags. * * @deprecated in Drupal 8.0.x, will be removed before Drupal 9.0.0. Use - * \Drupal\Core\Field\FieldFilteredString instead. + * \Drupal\Core\Field\FieldFilteredMarkup instead. * - * @see \Drupal\Core\Field\FieldFilteredString + * @see \Drupal\Core\Field\FieldFilteredMarkup */ trait AllowedTagsXssTrait { @@ -34,21 +34,21 @@ trait AllowedTagsXssTrait { * valid UTF-8. */ public function fieldFilterXss($string) { - return FieldFilteredString::create($string); + return FieldFilteredMarkup::create($string); } /** * Returns a list of tags allowed by AllowedTagsXssTrait::fieldFilterXss(). */ public function allowedTags() { - return FieldFilteredString::allowedTags(); + return FieldFilteredMarkup::allowedTags(); } /** * Returns a human-readable list of allowed tags for display in help texts. */ public function displayAllowedTags() { - return FieldFilteredString::displayAllowedTags(); + return FieldFilteredMarkup::displayAllowedTags(); } } diff --git a/core/lib/Drupal/Core/Field/FieldFilteredString.php b/core/lib/Drupal/Core/Field/FieldFilteredMarkup.php similarity index 80% rename from core/lib/Drupal/Core/Field/FieldFilteredString.php rename to core/lib/Drupal/Core/Field/FieldFilteredMarkup.php index 1a513c9adf91d152c5c671b3667611177b194179..78900a924598001b768f208b864f5f61ac2705d3 100644 --- a/core/lib/Drupal/Core/Field/FieldFilteredString.php +++ b/core/lib/Drupal/Core/Field/FieldFilteredMarkup.php @@ -2,14 +2,14 @@ /** * @file - * Contains \Drupal\Core\Field\FieldFilteredString. + * Contains \Drupal\Core\Field\FieldFilteredMarkup. */ namespace Drupal\Core\Field; use Drupal\Component\Utility\Html; -use Drupal\Component\Utility\SafeStringInterface; -use Drupal\Component\Utility\SafeStringTrait; +use Drupal\Component\Render\MarkupInterface; +use Drupal\Component\Render\MarkupTrait; use Drupal\Component\Utility\Unicode; use Drupal\Component\Utility\Xss; @@ -23,18 +23,18 @@ * This object is marked as internal because it should only be used by the * Field module and field-related plugins. * - * @see \Drupal\Core\Render\SafeString + * @see \Drupal\Core\Render\Markup */ -final class FieldFilteredString implements SafeStringInterface, \Countable { - use SafeStringTrait; +final class FieldFilteredMarkup implements MarkupInterface, \Countable { + use MarkupTrait; /** - * Overrides \Drupal\Component\Utility\SafeStringTrait::create(). + * Overrides \Drupal\Component\Render\MarkupTrait::create(). * - * @return string|\Drupal\Component\Utility\SafeStringInterface + * @return string|\Drupal\Component\Render\MarkupInterface * A safe string filtered with the allowed tag list and normalized. * - * @see \Drupal\Core\Field\FieldFilteredString::allowedTags() + * @see \Drupal\Core\Field\FieldFilteredMarkup::allowedTags() * @see \Drupal\Component\Utility\Xss::filter() * @see \Drupal\Component\Utility\Html::normalize() */ diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/NumericFormatterBase.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/NumericFormatterBase.php index 0320cd51f8d500b86bf6d130853a219e3b5f149f..28b0159875c3bd564283dd5ab5ded0206fbc32f3 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/NumericFormatterBase.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/NumericFormatterBase.php @@ -75,8 +75,8 @@ public function viewElements(FieldItemListInterface $items, $langcode) { // Account for prefix and suffix. if ($this->getSetting('prefix_suffix')) { - $prefixes = isset($settings['prefix']) ? array_map(array('Drupal\Core\Field\FieldFilteredString', 'create'), explode('|', $settings['prefix'])) : array(''); - $suffixes = isset($settings['suffix']) ? array_map(array('Drupal\Core\Field\FieldFilteredString', 'create'), explode('|', $settings['suffix'])) : array(''); + $prefixes = isset($settings['prefix']) ? array_map(array('Drupal\Core\Field\FieldFilteredMarkup', 'create'), explode('|', $settings['prefix'])) : array(''); + $suffixes = isset($settings['suffix']) ? array_map(array('Drupal\Core\Field\FieldFilteredMarkup', 'create'), explode('|', $settings['suffix'])) : array(''); $prefix = (count($prefixes) > 1) ? $this->formatPlural($item->value, $prefixes[0], $prefixes[1]) : $prefixes[0]; $suffix = (count($suffixes) > 1) ? $this->formatPlural($item->value, $suffixes[0], $suffixes[1]) : $suffixes[0]; $output = $prefix . $output . $suffix; diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/BooleanItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/BooleanItem.php index b0831111c3eafe41435340c2f1628f5a773691e2..71288384db73d6d2de9d7bef38aa5c045844e2cb 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/BooleanItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/BooleanItem.php @@ -12,7 +12,7 @@ use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Session\AccountInterface; -use Drupal\Core\StringTranslation\TranslatableString; +use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\Core\TypedData\OptionsProviderInterface; use Drupal\Core\TypedData\DataDefinition; @@ -34,8 +34,8 @@ class BooleanItem extends FieldItemBase implements OptionsProviderInterface { */ public static function defaultFieldSettings() { return array( - 'on_label' => new TranslatableString('On'), - 'off_label' => new TranslatableString('Off'), + 'on_label' => new TranslatableMarkup('On'), + 'off_label' => new TranslatableMarkup('Off'), ) + parent::defaultFieldSettings(); } diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php index 70397fa1e64523e748ce27b9ea8dc04a03f64f20..5904d35066e55d7435631d0494f9282693f9c398 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php @@ -13,7 +13,7 @@ use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FieldItemBase; use Drupal\Core\Field\FieldStorageDefinitionInterface; -use Drupal\Core\StringTranslation\TranslatableString; +use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\Core\TypedData\DataReferenceDefinition; use Drupal\Core\TypedData\DataReferenceTargetDefinition; @@ -75,19 +75,19 @@ public static function propertyDefinitions(FieldStorageDefinitionInterface $fiel if ($target_id_data_type === 'integer') { $target_id_definition = DataReferenceTargetDefinition::create('integer') - ->setLabel(new TranslatableString('@label ID', ['@label' => $target_type_info->getLabel()])) + ->setLabel(new TranslatableMarkup('@label ID', ['@label' => $target_type_info->getLabel()])) ->setSetting('unsigned', TRUE); } else { $target_id_definition = DataReferenceTargetDefinition::create('string') - ->setLabel(new TranslatableString('@label ID', ['@label' => $target_type_info->getLabel()])); + ->setLabel(new TranslatableMarkup('@label ID', ['@label' => $target_type_info->getLabel()])); } $target_id_definition->setRequired(TRUE); $properties['target_id'] = $target_id_definition; $properties['entity'] = DataReferenceDefinition::create('entity') ->setLabel($target_type_info->getLabel()) - ->setDescription(new TranslatableString('The referenced entity')) + ->setDescription(new TranslatableMarkup('The referenced entity')) // The entity object is computed out of the entity ID. ->setComputed(TRUE) ->setReadOnly(FALSE) diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/PasswordItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/PasswordItem.php index e99b5d1fff54bb4d104ce711266daac3dbe07154..7caa26fa4558391b9044fbec9eb568f4511861ae 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/PasswordItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/PasswordItem.php @@ -9,7 +9,7 @@ use Drupal\Core\Entity\EntityMalformedException; use Drupal\Core\Field\FieldStorageDefinitionInterface; -use Drupal\Core\StringTranslation\TranslatableString; +use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\Core\TypedData\DataDefinition; /** @@ -29,10 +29,10 @@ class PasswordItem extends StringItem { */ public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) { $properties['value'] = DataDefinition::create('string') - ->setLabel(new TranslatableString('The hashed password')) + ->setLabel(new TranslatableMarkup('The hashed password')) ->setSetting('case_sensitive', TRUE); $properties['existing'] = DataDefinition::create('string') - ->setLabel(new TranslatableString('Existing password')); + ->setLabel(new TranslatableMarkup('Existing password')); return $properties; } diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringItemBase.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringItemBase.php index c71bd4cae0cb16c50e29171a9d04583edf0cbcb4..e8567182d0147e0387c65497098727d33d9a89d3 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringItemBase.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringItemBase.php @@ -9,7 +9,7 @@ use Drupal\Core\Field\FieldItemBase; use Drupal\Core\Field\FieldStorageDefinitionInterface; -use Drupal\Core\StringTranslation\TranslatableString; +use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\Core\TypedData\DataDefinition; /** @@ -31,9 +31,9 @@ public static function defaultStorageSettings() { */ public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) { // This is called very early by the user entity roles field. Prevent - // early t() calls by using the TranslatableString. + // early t() calls by using the TranslatableMarkup. $properties['value'] = DataDefinition::create('string') - ->setLabel(new TranslatableString('Text value')) + ->setLabel(new TranslatableMarkup('Text value')) ->setSetting('case_sensitive', $field_definition->getSetting('case_sensitive')) ->setRequired(TRUE); diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/NumberWidget.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/NumberWidget.php index 86c17b6362ba16f05fd86d04e98269b4e6c64314..57abc604120c8c262b6001160dd0146e0c9810a4 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/NumberWidget.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/NumberWidget.php @@ -7,7 +7,7 @@ namespace Drupal\Core\Field\Plugin\Field\FieldWidget; -use Drupal\Core\Field\FieldFilteredString; +use Drupal\Core\Field\FieldFilteredMarkup; use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Field\WidgetBase; use Drupal\Core\Form\FormStateInterface; @@ -102,11 +102,11 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen // Add prefix and suffix. if ($field_settings['prefix']) { $prefixes = explode('|', $field_settings['prefix']); - $element['#field_prefix'] = FieldFilteredString::create(array_pop($prefixes)); + $element['#field_prefix'] = FieldFilteredMarkup::create(array_pop($prefixes)); } if ($field_settings['suffix']) { $suffixes = explode('|', $field_settings['suffix']); - $element['#field_suffix'] = FieldFilteredString::create(array_pop($suffixes)); + $element['#field_suffix'] = FieldFilteredMarkup::create(array_pop($suffixes)); } return array('value' => $element); diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/OptionsWidgetBase.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/OptionsWidgetBase.php index cde56849cd2ffc474e6f0ef57459208ce0ff255c..0235f3f6e8af8ca3d7131cdb85ca6eb86a27bd0d 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/OptionsWidgetBase.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/OptionsWidgetBase.php @@ -9,7 +9,7 @@ use Drupal\Core\Entity\FieldableEntityInterface; use Drupal\Core\Field\FieldDefinitionInterface; -use Drupal\Core\Field\FieldFilteredString; +use Drupal\Core\Field\FieldFilteredMarkup; use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Field\WidgetBase; use Drupal\Core\Form\FormStateInterface; @@ -191,7 +191,7 @@ protected function supportsGroups() { */ protected function sanitizeLabel(&$label) { // Allow a limited set of HTML tags. - $label = FieldFilteredString::create($label); + $label = FieldFilteredMarkup::create($label); } /** diff --git a/core/lib/Drupal/Core/Field/WidgetBase.php b/core/lib/Drupal/Core/Field/WidgetBase.php index 575daf925308cb72d29a26cd2b0d92bcacada3e1..6aa4012f03a655d9a9e3066148fbf93e7df4e3b9 100644 --- a/core/lib/Drupal/Core/Field/WidgetBase.php +++ b/core/lib/Drupal/Core/Field/WidgetBase.php @@ -85,7 +85,7 @@ public function form(FieldItemListInterface $items, array &$form, FormStateInter $delta = isset($get_delta) ? $get_delta : 0; $element = array( '#title' => $this->fieldDefinition->getLabel(), - '#description' => FieldFilteredString::create(\Drupal::token()->replace($this->fieldDefinition->getDescription())), + '#description' => FieldFilteredMarkup::create(\Drupal::token()->replace($this->fieldDefinition->getDescription())), ); $element = $this->formSingleElement($items, $delta, $element, $form, $form_state); @@ -164,7 +164,7 @@ protected function formMultipleElements(FieldItemListInterface $items, array &$f } $title = $this->fieldDefinition->getLabel(); - $description = FieldFilteredString::create(\Drupal::token()->replace($this->fieldDefinition->getDescription())); + $description = FieldFilteredMarkup::create(\Drupal::token()->replace($this->fieldDefinition->getDescription())); $elements = array(); diff --git a/core/lib/Drupal/Core/GeneratedLink.php b/core/lib/Drupal/Core/GeneratedLink.php index bfd97690a81c00f32f6649983c9947550517694b..d7e96e1297a0e461a69c56903470ea9b0fdd65d4 100644 --- a/core/lib/Drupal/Core/GeneratedLink.php +++ b/core/lib/Drupal/Core/GeneratedLink.php @@ -7,7 +7,7 @@ namespace Drupal\Core; -use Drupal\Component\Utility\SafeStringInterface; +use Drupal\Component\Render\MarkupInterface; use Drupal\Core\Render\BubbleableMetadata; /** @@ -16,7 +16,7 @@ * Note: not to be confused with \Drupal\Core\Link, which is for passing around * ungenerated links (typically link text + route name + route parameters). */ -class GeneratedLink extends BubbleableMetadata implements SafeStringInterface { +class GeneratedLink extends BubbleableMetadata implements MarkupInterface { /** * The HTML string value containing a link. diff --git a/core/lib/Drupal/Core/Language/LanguageManager.php b/core/lib/Drupal/Core/Language/LanguageManager.php index b8f5aeffb944359bb22cf5ad6fedeaa5048ceecd..092e9fe2f0f099d3b08d3135418f7a8c46a047a3 100644 --- a/core/lib/Drupal/Core/Language/LanguageManager.php +++ b/core/lib/Drupal/Core/Language/LanguageManager.php @@ -8,7 +8,7 @@ namespace Drupal\Core\Language; use Drupal\Core\DependencyInjection\DependencySerializationTrait; -use Drupal\Core\StringTranslation\TranslatableString; +use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\Core\Url; /** @@ -84,13 +84,13 @@ public function getLanguageTypes() { public function getDefinedLanguageTypesInfo() { $this->definedLanguageTypesInfo = array( LanguageInterface::TYPE_INTERFACE => array( - 'name' => new TranslatableString('Interface text'), - 'description' => new TranslatableString('Order of language detection methods for interface text. If a translation of interface text is available in the detected language, it will be displayed.'), + 'name' => new TranslatableMarkup('Interface text'), + 'description' => new TranslatableMarkup('Order of language detection methods for interface text. If a translation of interface text is available in the detected language, it will be displayed.'), 'locked' => TRUE, ), LanguageInterface::TYPE_CONTENT => array( - 'name' => new TranslatableString('Content'), - 'description' => new TranslatableString('Order of language detection methods for content. If a version of content is available in the detected language, it will be displayed.'), + 'name' => new TranslatableMarkup('Content'), + 'description' => new TranslatableMarkup('Order of language detection methods for content. If a version of content is available in the detected language, it will be displayed.'), 'locked' => TRUE, ), LanguageInterface::TYPE_URL => array( @@ -162,15 +162,15 @@ public function getLanguage($langcode) { */ public function getLanguageName($langcode) { if ($langcode == LanguageInterface::LANGCODE_NOT_SPECIFIED) { - return new TranslatableString('None'); + return new TranslatableMarkup('None'); } if ($language = $this->getLanguage($langcode)) { return $language->getName(); } if (empty($langcode)) { - return new TranslatableString('Unknown'); + return new TranslatableMarkup('Unknown'); } - return new TranslatableString('Unknown (@langcode)', array('@langcode' => $langcode)); + return new TranslatableMarkup('Unknown (@langcode)', array('@langcode' => $langcode)); } /** @@ -185,16 +185,16 @@ public function getDefaultLockedLanguages($weight = 0) { 'direction' => LanguageInterface::DIRECTION_LTR, ); // This is called very early while initializing the language system. Prevent - // early t() calls by using the TranslatableString. + // early t() calls by using the TranslatableMarkup. $languages[LanguageInterface::LANGCODE_NOT_SPECIFIED] = new Language(array( 'id' => LanguageInterface::LANGCODE_NOT_SPECIFIED, - 'name' => new TranslatableString('Not specified'), + 'name' => new TranslatableMarkup('Not specified'), 'weight' => ++$weight, ) + $locked_language); $languages[LanguageInterface::LANGCODE_NOT_APPLICABLE] = new Language(array( 'id' => LanguageInterface::LANGCODE_NOT_APPLICABLE, - 'name' => new TranslatableString('Not applicable'), + 'name' => new TranslatableMarkup('Not applicable'), 'weight' => ++$weight, ) + $locked_language); @@ -383,7 +383,7 @@ protected function filterLanguages(array $languages, $flags = LanguageInterface: $default = new Language( array( 'id' => $defaultLanguage->getId(), - 'name' => new TranslatableString("Site's default language (@lang_name)", + 'name' => new TranslatableMarkup("Site's default language (@lang_name)", array('@lang_name' => $defaultLanguage->getName())), 'direction' => $defaultLanguage->getDirection(), 'weight' => $defaultLanguage->getWeight(), diff --git a/core/lib/Drupal/Core/Logger/RfcLogLevel.php b/core/lib/Drupal/Core/Logger/RfcLogLevel.php index c7139b05866c481500aba0b58816eb258ff28084..ba3193848d07d7b6db2f7f449a4c6df085bfbb41 100644 --- a/core/lib/Drupal/Core/Logger/RfcLogLevel.php +++ b/core/lib/Drupal/Core/Logger/RfcLogLevel.php @@ -7,7 +7,7 @@ namespace Drupal\Core\Logger; -use Drupal\Core\StringTranslation\TranslatableString; +use Drupal\Core\StringTranslation\TranslatableMarkup; /** * @defgroup logging_severity_levels Logging severity levels @@ -96,14 +96,14 @@ class RfcLogLevel { public static function getLevels() { if (!static::$levels) { static::$levels = [ - static::EMERGENCY => new TranslatableString('Emergency'), - static::ALERT => new TranslatableString('Alert'), - static::CRITICAL => new TranslatableString('Critical'), - static::ERROR => new TranslatableString('Error'), - static::WARNING => new TranslatableString('Warning'), - static::NOTICE => new TranslatableString('Notice'), - static::INFO => new TranslatableString('Info'), - static::DEBUG => new TranslatableString('Debug'), + static::EMERGENCY => new TranslatableMarkup('Emergency'), + static::ALERT => new TranslatableMarkup('Alert'), + static::CRITICAL => new TranslatableMarkup('Critical'), + static::ERROR => new TranslatableMarkup('Error'), + static::WARNING => new TranslatableMarkup('Warning'), + static::NOTICE => new TranslatableMarkup('Notice'), + static::INFO => new TranslatableMarkup('Info'), + static::DEBUG => new TranslatableMarkup('Debug'), ]; } diff --git a/core/lib/Drupal/Core/Mail/MailManager.php b/core/lib/Drupal/Core/Mail/MailManager.php index 22b9a2810e150d9afe630e4a498d8440ac965e8d..663cfd43c2dd902eadff86359389feb8358926f9 100644 --- a/core/lib/Drupal/Core/Mail/MailManager.php +++ b/core/lib/Drupal/Core/Mail/MailManager.php @@ -7,7 +7,7 @@ namespace Drupal\Core\Mail; -use Drupal\Component\Utility\PlainTextOutput; +use Drupal\Component\Render\PlainTextOutput; use Drupal\Core\Logger\LoggerChannelFactoryInterface; use Drupal\Core\Plugin\DefaultPluginManager; use Drupal\Core\Cache\CacheBackendInterface; diff --git a/core/lib/Drupal/Core/Menu/ContextualLinkDefault.php b/core/lib/Drupal/Core/Menu/ContextualLinkDefault.php index 65e43b5534f1e637af2223832dbefa3fecda8d76..8f44d7aecbd809c3f7f35575d74beb4227962f54 100644 --- a/core/lib/Drupal/Core/Menu/ContextualLinkDefault.php +++ b/core/lib/Drupal/Core/Menu/ContextualLinkDefault.php @@ -19,7 +19,7 @@ class ContextualLinkDefault extends PluginBase implements ContextualLinkInterfac * {@inheritdoc} */ public function getTitle(Request $request = NULL) { - // The title from YAML file discovery may be a TranslatableString object. + // The title from YAML file discovery may be a TranslatableMarkup object. return (string) $this->pluginDefinition['title']; } diff --git a/core/lib/Drupal/Core/Menu/LocalActionDefault.php b/core/lib/Drupal/Core/Menu/LocalActionDefault.php index a8ce7ed38ba41110e3d3ef6f56af752110a853a1..4b72af419d03c24d036a71b6d2c27db07f41c183 100644 --- a/core/lib/Drupal/Core/Menu/LocalActionDefault.php +++ b/core/lib/Drupal/Core/Menu/LocalActionDefault.php @@ -71,7 +71,7 @@ public function getRouteName() { */ public function getTitle(Request $request = NULL) { // Subclasses may pull in the request or specific attributes as parameters. - // The title from YAML file discovery may be a TranslatableString object. + // The title from YAML file discovery may be a TranslatableMarkup object. return (string) $this->pluginDefinition['title']; } diff --git a/core/lib/Drupal/Core/Menu/LocalTaskDefault.php b/core/lib/Drupal/Core/Menu/LocalTaskDefault.php index 116546d48c5d95bf3b476ff9d2e7c669cb823d11..252a03aaf002423b35e0128c4bb3e9955789125e 100644 --- a/core/lib/Drupal/Core/Menu/LocalTaskDefault.php +++ b/core/lib/Drupal/Core/Menu/LocalTaskDefault.php @@ -80,7 +80,7 @@ public function getRouteParameters(RouteMatchInterface $route_match) { * {@inheritdoc} */ public function getTitle(Request $request = NULL) { - // The title from YAML file discovery may be a TranslatableString object. + // The title from YAML file discovery may be a TranslatableMarkup object. return (string) $this->pluginDefinition['title']; } diff --git a/core/lib/Drupal/Core/Menu/MenuLinkManager.php b/core/lib/Drupal/Core/Menu/MenuLinkManager.php index c561f6379d9870dd1b932d4696f0369c4882a312..106407b2b7293749d040de97ac5df607688bdce9 100644 --- a/core/lib/Drupal/Core/Menu/MenuLinkManager.php +++ b/core/lib/Drupal/Core/Menu/MenuLinkManager.php @@ -41,10 +41,10 @@ class MenuLinkManager implements MenuLinkManagerInterface { // The external URL if this link has one (required if route_name is empty). 'url' => '', // The static title for the menu link. If this came from a YAML definition - // or other safe source this may be a TranslatableString object. + // or other safe source this may be a TranslatableMarkup object. 'title' => '', // The description. If this came from a YAML definition or other safe source - // this may be be a TranslatableString object. + // this may be be a TranslatableMarkup object. 'description' => '', // The plugin ID of the parent link (or NULL for a top-level link). 'parent' => '', diff --git a/core/lib/Drupal/Core/Menu/MenuTreeStorage.php b/core/lib/Drupal/Core/Menu/MenuTreeStorage.php index 9392fa46aaec1edc960be8ed894f6f71b5edcde3..d639be782f14742f01d38c5fb8ea5d9ee78996a5 100644 --- a/core/lib/Drupal/Core/Menu/MenuTreeStorage.php +++ b/core/lib/Drupal/Core/Menu/MenuTreeStorage.php @@ -1262,14 +1262,14 @@ protected static function schemaDefinition() { 'default' => '', ), 'title' => array( - 'description' => 'The serialized title for the link. May be a TranslatableString.', + 'description' => 'The serialized title for the link. May be a TranslatableMarkup.', 'type' => 'blob', 'size' => 'big', 'not null' => FALSE, 'serialize' => TRUE, ), 'description' => array( - 'description' => 'The serialized description of this link - used for admin pages and title attribute. May be a TranslatableString.', + 'description' => 'The serialized description of this link - used for admin pages and title attribute. May be a TranslatableMarkup.', 'type' => 'blob', 'size' => 'big', 'not null' => FALSE, diff --git a/core/lib/Drupal/Core/Menu/menu.api.php b/core/lib/Drupal/Core/Menu/menu.api.php index a403cda094cca2524b23770b628a5d5c8c130b6d..5d05634d0464b92b3425ffc30fbce8ff8d01776e 100644 --- a/core/lib/Drupal/Core/Menu/menu.api.php +++ b/core/lib/Drupal/Core/Menu/menu.api.php @@ -235,10 +235,10 @@ * The value corresponding to each machine name key is an associative array * that may contain the following key-value pairs: * - title: (required) The title of the menu link. If this should be - * translated, create a \Drupal\Core\StringTranslation\TranslatableString + * translated, create a \Drupal\Core\StringTranslation\TranslatableMarkup * object. * - description: The description of the link. If this should be - * translated, create a \Drupal\Core\StringTranslation\TranslatableString + * translated, create a \Drupal\Core\StringTranslation\TranslatableMarkup * object. * - route_name: (optional) The route name to be used to build the path. * Either the route_name or url element must be provided. @@ -264,13 +264,13 @@ function hook_menu_links_discovered_alter(&$links) { // Change the weight and title of the user.logout link. $links['user.logout']['weight'] = -10; - $links['user.logout']['title'] = new \Drupal\Core\StringTranslation\TranslatableString('Logout'); + $links['user.logout']['title'] = new \Drupal\Core\StringTranslation\TranslatableMarkup('Logout'); // Conditionally add an additional link with a title that's not translated. if (\Drupal::moduleHandler()->moduleExists('search')) { $links['menu.api.search'] = array( 'title' => \Drupal::config('system.site')->get('name'), 'route_name' => 'menu.api.search', - 'description' => new \Drupal\Core\StringTranslation\TranslatableString('View popular search phrases for this site.'), + 'description' => new \Drupal\Core\StringTranslation\TranslatableMarkup('View popular search phrases for this site.'), 'parent' => 'system.admin_reports', ); } diff --git a/core/lib/Drupal/Core/Plugin/Discovery/YamlDiscovery.php b/core/lib/Drupal/Core/Plugin/Discovery/YamlDiscovery.php index fe78de8241c7ef2b8991775fbaca7c928f1180bb..97ea37460b260f322c0612fe6714ab74535302c1 100644 --- a/core/lib/Drupal/Core/Plugin/Discovery/YamlDiscovery.php +++ b/core/lib/Drupal/Core/Plugin/Discovery/YamlDiscovery.php @@ -10,7 +10,7 @@ use Drupal\Component\Plugin\Discovery\DiscoveryInterface; use Drupal\Component\Discovery\YamlDiscovery as ComponentYamlDiscovery; use Drupal\Component\Plugin\Discovery\DiscoveryTrait; -use Drupal\Core\StringTranslation\TranslatableString; +use Drupal\Core\StringTranslation\TranslatableMarkup; /** * Allows YAML files to define plugin definitions. @@ -18,7 +18,7 @@ * If the value of a key (like title) in the definition is translatable then * the addTranslatableProperty() method can be used to mark it as such and also * to add translation context. Then - * \Drupal\Core\StringTranslation\TranslatableString will be used to translate + * \Drupal\Core\StringTranslation\TranslatableMarkup will be used to translate * the string and also to mark it safe. Only strings written in the YAML files * should be marked as safe, strings coming from dynamic plugin definitions * potentially containing user input should not. @@ -83,7 +83,7 @@ public function getDefinitions() { $definitions = array(); foreach ($plugins as $provider => $list) { foreach ($list as $id => $definition) { - // Add TranslatableStrings. + // Add TranslatableMarkup. foreach ($this->translatableProperties as $property => $context_key) { if (isset($definition[$property])) { $options = []; @@ -93,7 +93,7 @@ public function getDefinitions() { $options['context'] = $definition[$context_key]; unset($definition[$context_key]); } - $definition[$property] = new TranslatableString($definition[$property], [], $options); + $definition[$property] = new TranslatableMarkup($definition[$property], [], $options); } } // Add ID and provider. diff --git a/core/lib/Drupal/Core/Render/Element/HtmlTag.php b/core/lib/Drupal/Core/Render/Element/HtmlTag.php index 03e67d1703d1dbbf40454a24501e304b9bb93b02..f2bcacf7eeb24f5d713c92020dad9d07b9e96b20 100644 --- a/core/lib/Drupal/Core/Render/Element/HtmlTag.php +++ b/core/lib/Drupal/Core/Render/Element/HtmlTag.php @@ -9,7 +9,7 @@ use Drupal\Component\Utility\Html as HtmlUtility; use Drupal\Component\Utility\SafeMarkup; -use Drupal\Core\Render\SafeString; +use Drupal\Core\Render\Markup; use Drupal\Component\Utility\Xss; use Drupal\Core\Template\Attribute; @@ -85,7 +85,7 @@ public static function preRenderHtmlTag($element) { if (!empty($element['#noscript'])) { $markup = ""; } - $element['#markup'] = SafeString::create($markup); + $element['#markup'] = Markup::create($markup); return $element; } @@ -166,13 +166,13 @@ public static function preRenderConditionalComments($element) { // filtered if they are unsafe. Thus, all these strings are safe. if (!$browsers['!IE']) { // "downlevel-hidden". - $element['#prefix'] = SafeString::create("\n\n"); + $element['#prefix'] = Markup::create("\n\n"); } else { // "downlevel-revealed". - $element['#prefix'] = SafeString::create("\n\n" . $prefix); - $element['#suffix'] = SafeString::create($suffix . "\n"); + $element['#prefix'] = Markup::create("\n\n" . $prefix); + $element['#suffix'] = Markup::create($suffix . "\n"); } return $element; diff --git a/core/lib/Drupal/Core/Render/Element/Tableselect.php b/core/lib/Drupal/Core/Render/Element/Tableselect.php index 3617b8cff821b01ee089e41cd32a2b99929f83b7..cc6aefd33b2e347aebb5128a1a63a9532ebcfc81 100644 --- a/core/lib/Drupal/Core/Render/Element/Tableselect.php +++ b/core/lib/Drupal/Core/Render/Element/Tableselect.php @@ -10,7 +10,7 @@ use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Render\Element; use Drupal\Component\Utility\Html as HtmlUtility; -use Drupal\Core\StringTranslation\TranslatableString; +use Drupal\Core\StringTranslation\TranslatableMarkup; /** * Provides a form element for a table with radios or checkboxes in left column. @@ -220,7 +220,7 @@ public static function processTableselect(&$element, FormStateInterface $form_st $title = ''; if (isset($element['#options'][$key]['title']) && is_array($element['#options'][$key]['title'])) { if (!empty($element['#options'][$key]['title']['data']['#title'])) { - $title = new TranslatableString('Update @title', array( + $title = new TranslatableMarkup('Update @title', array( '@title' => $element['#options'][$key]['title']['data']['#title'], )); } diff --git a/core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php b/core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php index 6104b0ae512680fa5b9dc423bb6d409898532d3e..196c29076d10a1ef8638eac0823285a63e7d3132 100644 --- a/core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php +++ b/core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php @@ -237,7 +237,7 @@ public function processAttachments(AttachmentsInterface $response) { */ protected function renderPlaceholders(HtmlResponse $response) { $build = [ - '#markup' => SafeString::create($response->getContent()), + '#markup' => Markup::create($response->getContent()), '#attached' => $response->getAttachments(), ]; // RendererInterface::renderRoot() renders the $build render array and diff --git a/core/lib/Drupal/Core/Render/SafeString.php b/core/lib/Drupal/Core/Render/Markup.php similarity index 71% rename from core/lib/Drupal/Core/Render/SafeString.php rename to core/lib/Drupal/Core/Render/Markup.php index 4d968ce9287ce167d569e7d2834421c4e12fbe77..c36d29f0503da97a7d670a3c4cdae22f5be5ac07 100644 --- a/core/lib/Drupal/Core/Render/SafeString.php +++ b/core/lib/Drupal/Core/Render/Markup.php @@ -2,13 +2,13 @@ /** * @file - * Contains \Drupal\Core\Render\SafeString. + * Contains \Drupal\Core\Render\Markup. */ namespace Drupal\Core\Render; -use Drupal\Component\Utility\SafeStringInterface; -use Drupal\Component\Utility\SafeStringTrait; +use Drupal\Component\Render\MarkupInterface; +use Drupal\Component\Render\MarkupTrait; /** * Defines an object that passes safe strings through the render system. @@ -25,6 +25,6 @@ * @see \Twig_Markup * @see \Drupal\Component\Utility\SafeMarkup */ -final class SafeString implements SafeStringInterface, \Countable { - use SafeStringTrait; +final class Markup implements MarkupInterface, \Countable { + use MarkupTrait; } diff --git a/core/lib/Drupal/Core/Render/PlaceholderGenerator.php b/core/lib/Drupal/Core/Render/PlaceholderGenerator.php index 0548901b3a722f225a823a377a8ee2ea092a0533..e0940bf2549369c5ec2132a34bbba81c0a2a4a1c 100644 --- a/core/lib/Drupal/Core/Render/PlaceholderGenerator.php +++ b/core/lib/Drupal/Core/Render/PlaceholderGenerator.php @@ -93,7 +93,7 @@ public function createPlaceholder(array $element) { // Build the placeholder element to return. $placeholder_element = []; - $placeholder_element['#markup'] = SafeString::create($placeholder_markup); + $placeholder_element['#markup'] = Markup::create($placeholder_markup); $placeholder_element['#attached']['placeholders'][$placeholder_markup] = $placeholder_render_array; return $placeholder_element; } diff --git a/core/lib/Drupal/Core/Render/RenderCache.php b/core/lib/Drupal/Core/Render/RenderCache.php index b7fb4f6a80ed6c569c6a9d15bda1fedd3698a902..ac6e34edbd1e533893db42fead7f51e8eef4b958 100644 --- a/core/lib/Drupal/Core/Render/RenderCache.php +++ b/core/lib/Drupal/Core/Render/RenderCache.php @@ -339,10 +339,10 @@ public function getCacheableRenderArray(array $elements) { // the cache entry size. if (!empty($elements['#cache_properties']) && is_array($elements['#cache_properties'])) { $data['#cache_properties'] = $elements['#cache_properties']; - // Ensure that any safe strings are a SafeString object. + // Ensure that any safe strings are a Markup object. foreach (Element::properties(array_flip($elements['#cache_properties'])) as $cache_property) { if (isset($elements[$cache_property]) && is_scalar($elements[$cache_property]) && SafeMarkup::isSafe($elements[$cache_property])) { - $elements[$cache_property] = SafeString::create($elements[$cache_property]); + $elements[$cache_property] = Markup::create($elements[$cache_property]); } } @@ -355,13 +355,13 @@ public function getCacheableRenderArray(array $elements) { // Cache only cacheable children's markup. foreach ($cacheable_children as $key) { // We can assume that #markup is safe at this point. - $cacheable_items[$key] = ['#markup' => SafeString::create($cacheable_items[$key]['#markup'])]; + $cacheable_items[$key] = ['#markup' => Markup::create($cacheable_items[$key]['#markup'])]; } } $data += $cacheable_items; } - $data['#markup'] = SafeString::create($data['#markup']); + $data['#markup'] = Markup::create($data['#markup']); return $data; } diff --git a/core/lib/Drupal/Core/Render/Renderer.php b/core/lib/Drupal/Core/Render/Renderer.php index c2e03c9ebff1274fccd5edf2d3bbdb26ae168079..b1f7c2aea4d91f023156de0c32066fcbceb6a1db 100644 --- a/core/lib/Drupal/Core/Render/Renderer.php +++ b/core/lib/Drupal/Core/Render/Renderer.php @@ -187,7 +187,7 @@ protected function renderPlaceholder($placeholder, array $elements) { // Replace the placeholder with its rendered markup, and merge its // bubbleable metadata with the main elements'. - $elements['#markup'] = SafeString::create(str_replace($placeholder, $markup, $elements['#markup'])); + $elements['#markup'] = Markup::create(str_replace($placeholder, $markup, $elements['#markup'])); $elements = $this->mergeBubbleableMetadata($elements, $placeholder_elements); // Remove the placeholder that we've just rendered. @@ -292,7 +292,7 @@ protected function doRender(&$elements, $is_root_call = FALSE) { } // Mark the element markup as safe if is it a string. if (is_string($elements['#markup'])) { - $elements['#markup'] = SafeString::create($elements['#markup']); + $elements['#markup'] = Markup::create($elements['#markup']); } // The render cache item contains all the bubbleable rendering metadata // for the subtree. @@ -466,7 +466,7 @@ protected function doRender(&$elements, $is_root_call = FALSE) { foreach ($children as $key) { $elements['#children'] .= $this->doRender($elements[$key]); } - $elements['#children'] = SafeString::create($elements['#children']); + $elements['#children'] = Markup::create($elements['#children']); } // If #theme is not implemented and the element has raw #markup as a @@ -477,7 +477,7 @@ protected function doRender(&$elements, $is_root_call = FALSE) { // required. Eventually #theme_wrappers will expect both #markup and // #children to be a single string as #children. if (!$theme_is_implemented && isset($elements['#markup'])) { - $elements['#children'] = SafeString::create($elements['#markup'] . $elements['#children']); + $elements['#children'] = Markup::create($elements['#markup'] . $elements['#children']); } // Let the theme functions in #theme_wrappers add markup around the rendered @@ -530,7 +530,7 @@ protected function doRender(&$elements, $is_root_call = FALSE) { $prefix = isset($elements['#prefix']) ? $this->xssFilterAdminIfUnsafe($elements['#prefix']) : ''; $suffix = isset($elements['#suffix']) ? $this->xssFilterAdminIfUnsafe($elements['#suffix']) : ''; - $elements['#markup'] = SafeString::create($prefix . $elements['#children'] . $suffix); + $elements['#markup'] = Markup::create($prefix . $elements['#children'] . $suffix); // We've rendered this element (and its subtree!), now update the context. $context->update($elements); @@ -685,18 +685,18 @@ public function addCacheableDependency(array &$elements, $dependency) { * Note: This method only filters if $string is not marked safe already. This * ensures that HTML intended for display is not filtered. * - * @param string|\Drupal\Core\Render\SafeString $string + * @param string|\Drupal\Core\Render\Markup $string * A string. * - * @return \Drupal\Core\Render\SafeString - * The escaped string wrapped in a SafeString object. If + * @return \Drupal\Core\Render\Markup + * The escaped string wrapped in a Markup object. If * SafeMarkup::isSafe($string) returns TRUE, it won't be escaped again. */ protected function xssFilterAdminIfUnsafe($string) { if (!SafeMarkup::isSafe($string)) { $string = Xss::filterAdmin($string); } - return SafeString::create($string); + return Markup::create($string); } /** @@ -717,8 +717,8 @@ protected function xssFilterAdminIfUnsafe($string) { * @param array $elements * A render array with #markup set. * - * @return \Drupal\Component\Utility\SafeStringInterface|string - * The escaped markup wrapped in a SafeString object. If + * @return \Drupal\Component\Render\MarkupInterface|string + * The escaped markup wrapped in a Markup object. If * SafeMarkup::isSafe($elements['#markup']) returns TRUE, it won't be * escaped or filtered again. * @@ -732,12 +732,12 @@ protected function ensureMarkupIsSafe(array $elements) { } if (!empty($elements['#plain_text'])) { - $elements['#markup'] = SafeString::create(Html::escape($elements['#plain_text'])); + $elements['#markup'] = Markup::create(Html::escape($elements['#plain_text'])); } elseif (!SafeMarkup::isSafe($elements['#markup'])) { // The default behaviour is to XSS filter using the admin tag list. $tags = isset($elements['#allowed_tags']) ? $elements['#allowed_tags'] : Xss::getAdminTagList(); - $elements['#markup'] = SafeString::create(Xss::filter($elements['#markup'], $tags)); + $elements['#markup'] = Markup::create(Xss::filter($elements['#markup'], $tags)); } return $elements; diff --git a/core/lib/Drupal/Core/Render/RendererInterface.php b/core/lib/Drupal/Core/Render/RendererInterface.php index 649cf989727647c86a5d976ed6768db19268fe04..02269e482a0ea1a429cb489607c9da1183a9c197 100644 --- a/core/lib/Drupal/Core/Render/RendererInterface.php +++ b/core/lib/Drupal/Core/Render/RendererInterface.php @@ -27,7 +27,7 @@ interface RendererInterface { * @param array $elements * The structured array describing the data to be rendered. * - * @return \Drupal\Component\Utility\SafeStringInterface + * @return \Drupal\Component\Render\MarkupInterface * The rendered HTML. * * @see ::render() @@ -58,7 +58,7 @@ public function renderRoot(&$elements); * @param array $elements * The structured array describing the data to be rendered. * - * @return \Drupal\Component\Utility\SafeStringInterface + * @return \Drupal\Component\Render\MarkupInterface * The rendered HTML. * * @see ::renderRoot() @@ -302,7 +302,7 @@ public function renderPlain(&$elements); * (Internal use only.) Whether this is a recursive call or not. See * ::renderRoot(). * - * @return \Drupal\Component\Utility\SafeStringInterface + * @return \Drupal\Component\Render\MarkupInterface * The rendered HTML. * * @throws \LogicException diff --git a/core/lib/Drupal/Core/Session/AccountInterface.php b/core/lib/Drupal/Core/Session/AccountInterface.php index 36b390a7085c78a86414b02de28e5cb88cb66872..ad79ee1501bb9c3b228b3f0a6b1623c67eeee7cf 100644 --- a/core/lib/Drupal/Core/Session/AccountInterface.php +++ b/core/lib/Drupal/Core/Session/AccountInterface.php @@ -143,9 +143,9 @@ public function getAccountName(); * * @see hook_user_format_name_alter() * - * @return string|\Drupal\Component\Utility\SafeStringInterface + * @return string|\Drupal\Component\Render\MarkupInterface * Either a string that will be auto-escaped on output or a - * SafeStringInterface object that is already HTML escaped. Either is safe + * MarkupInterface object that is already HTML escaped. Either is safe * to be printed within HTML fragments. */ public function getDisplayName(); diff --git a/core/lib/Drupal/Core/StringTranslation/PluralTranslatableString.php b/core/lib/Drupal/Core/StringTranslation/PluralTranslatableMarkup.php similarity index 89% rename from core/lib/Drupal/Core/StringTranslation/PluralTranslatableString.php rename to core/lib/Drupal/Core/StringTranslation/PluralTranslatableMarkup.php index f8fb07bfa69fd7108f3dc60243e5375d7ef71d0d..583ab1805abbc0aaebeaf94850959c2628aca0c7 100644 --- a/core/lib/Drupal/Core/StringTranslation/PluralTranslatableString.php +++ b/core/lib/Drupal/Core/StringTranslation/PluralTranslatableMarkup.php @@ -2,15 +2,15 @@ /** * @file - * Contains \Drupal\Core\StringTranslation\PluralTranslatableString. + * Contains \Drupal\Core\StringTranslation\PluralTranslatableMarkup. */ namespace Drupal\Core\StringTranslation; /** - * A class to hold plural translatable strings. + * A class to hold plural translatable markup. */ -class PluralTranslatableString extends TranslatableString { +class PluralTranslatableMarkup extends TranslatableMarkup { /** * The delimiter used to split plural strings. @@ -43,7 +43,7 @@ class PluralTranslatableString extends TranslatableString { protected static $localeEnabled; /** - * Constructs a new PluralTranslatableString object. + * Constructs a new PluralTranslatableMarkup object. * * Parses values passed into this class through the format_plural() function * in Drupal and handles an optional context for the string. @@ -60,7 +60,7 @@ class PluralTranslatableString extends TranslatableString { * "@count new comments". * @param array $args * (optional) An array with placeholder replacements, keyed by placeholder. - * See \Drupal\Component\Utility\FormattableString::placeholderFormat() for + * See \Drupal\Component\Render\FormattableMarkup::placeholderFormat() for * additional information about placeholders. Note that you do not need to * include @count in this array; this replacement is done automatically * for the plural cases. @@ -70,7 +70,7 @@ class PluralTranslatableString extends TranslatableString { * @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation * (optional) The string translation service. * - * @see \Drupal\Component\Utility\FormattableString::placeholderFormat() + * @see \Drupal\Component\Render\FormattableMarkup::placeholderFormat() */ public function __construct($count, $singular, $plural, array $args = [], array $options = [], TranslationInterface $string_translation = NULL) { $this->count = $count; @@ -79,7 +79,7 @@ public function __construct($count, $singular, $plural, array $args = [], array } /** - * Constructs a new class instance from an already translated string. + * Constructs a new class instance from already translated markup. * * This method ensures that the string is pluralized correctly. As opposed * to the __construct() method, this method is designed to be invoked with @@ -99,8 +99,8 @@ public function __construct($count, $singular, $plural, array $args = [], array * @param array $options * An associative array of additional options. See t() for allowed keys. * - * @return \Drupal\Core\StringTranslation\PluralTranslatableString - * A PluralTranslatableString object. + * @return \Drupal\Core\StringTranslation\PluralTranslatableMarkup + * A PluralTranslatableMarkup object. */ public static function createFromTranslatedString($count, $translated_string, array $args = [], array $options = []) { $plural = new static($count, '', '', $args, $options); diff --git a/core/lib/Drupal/Core/StringTranslation/TranslatableString.php b/core/lib/Drupal/Core/StringTranslation/TranslatableMarkup.php similarity index 80% rename from core/lib/Drupal/Core/StringTranslation/TranslatableString.php rename to core/lib/Drupal/Core/StringTranslation/TranslatableMarkup.php index 1368e6f0c736134ab47772930bce61bc652284d3..8b4902a0ad75a2465a857b88b19c618b31dab4be 100644 --- a/core/lib/Drupal/Core/StringTranslation/TranslatableString.php +++ b/core/lib/Drupal/Core/StringTranslation/TranslatableMarkup.php @@ -2,28 +2,28 @@ /** * @file - * Contains \Drupal\Core\StringTranslation\TranslatableString. + * Contains \Drupal\Core\StringTranslation\TranslatableMarkup. */ namespace Drupal\Core\StringTranslation; -use Drupal\Component\Utility\FormattableString; +use Drupal\Component\Render\FormattableMarkup; use Drupal\Component\Utility\ToStringTrait; /** - * Provides translatable string class. + * Provides translatable markup class. * - * This class delays translating strings until rendering them. + * This class delays translation until rendering. * * This is useful for using translation in very low level subsystems like entity * definition and stream wrappers. * - * @see \Drupal\Component\Utility\FormattableString::placeholderFormat() + * @see \Drupal\Component\Render\FormattableMarkup::placeholderFormat() * @see \Drupal\Core\StringTranslation\TranslationManager::translate() * @see \Drupal\Core\StringTranslation\TranslationManager::translateString() * @see \Drupal\Core\Annotation\Translation */ -class TranslatableString extends FormattableString { +class TranslatableMarkup extends FormattableMarkup { use ToStringTrait; @@ -35,11 +35,11 @@ class TranslatableString extends FormattableString { protected $string; /** - * The translated string without placeholder replacements. + * The translated markup without placeholder replacements. * * @var string */ - protected $translatableString; + protected $translatedMarkup; /** * The translation options. @@ -65,14 +65,14 @@ class TranslatableString extends FormattableString { * The string that is to be translated. * @param array $arguments * (optional) An array with placeholder replacements, keyed by placeholder. - * See \Drupal\Component\Utility\FormattableString::placeholderFormat() for + * See \Drupal\Component\Render\FormattableMarkup::placeholderFormat() for * additional information about placeholders. * @param array $options * (optional) An array of additional options. * @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation * (optional) The string translation service. * - * @see \Drupal\Component\Utility\FormattableString::placeholderFormat() + * @see \Drupal\Component\Render\FormattableMarkup::placeholderFormat() */ public function __construct($string, array $arguments = array(), array $options = array(), TranslationInterface $string_translation = NULL) { $this->string = $string; @@ -131,15 +131,15 @@ public function getArguments() { * The translated string. */ public function render() { - if (!isset($this->translatableString)) { - $this->translatableString = $this->getStringTranslation()->translateString($this); + if (!isset($this->translatedMarkup)) { + $this->translatedMarkup = $this->getStringTranslation()->translateString($this); } // Handle any replacements. if ($args = $this->getArguments()) { - return $this->placeholderFormat($this->translatableString, $args); + return $this->placeholderFormat($this->translatedMarkup, $args); } - return $this->translatableString; + return $this->translatedMarkup; } /** diff --git a/core/lib/Drupal/Core/StringTranslation/TranslationInterface.php b/core/lib/Drupal/Core/StringTranslation/TranslationInterface.php index 195a5a1d58ae1c94e4920808c3419a53cc2d0db0..57ed36eb27d5e4f27c745eac9727acb7006e2cc1 100644 --- a/core/lib/Drupal/Core/StringTranslation/TranslationInterface.php +++ b/core/lib/Drupal/Core/StringTranslation/TranslationInterface.php @@ -33,7 +33,7 @@ interface TranslationInterface { * what is used to display the page. * - 'context': The context the source string belongs to. * - * @return \Drupal\Core\StringTranslation\TranslatableString + * @return \Drupal\Core\StringTranslation\TranslatableMarkup * The translated string. * * @see \Drupal\Component\Utility\SafeMarkup::format() @@ -41,15 +41,15 @@ interface TranslationInterface { public function translate($string, array $args = array(), array $options = array()); /** - * Translates a TranslatableString object to a string. + * Translates a TranslatableMarkup object to a string. * - * @param \Drupal\Core\StringTranslation\TranslatableString $translated_string - * A TranslatableString object. + * @param \Drupal\Core\StringTranslation\TranslatableMarkup $translated_string + * A TranslatableMarkup object. * * @return string * The translated string. */ - public function translateString(TranslatableString $translated_string); + public function translateString(TranslatableMarkup $translated_string); /** * Formats a string containing a count of items. @@ -57,7 +57,7 @@ public function translateString(TranslatableString $translated_string); * This function ensures that the string is pluralized correctly. Since * TranslationInterface::translate() is called by this function, make sure not * to pass already-localized strings to it. See - * PluralTranslatableString::createFromTranslatedString() for that. + * PluralTranslatableMarkup::createFromTranslatedString() for that. * * For example: * @code @@ -92,13 +92,13 @@ public function translateString(TranslatableString $translated_string); * @param array $options * An associative array of additional options. See t() for allowed keys. * - * @return \Drupal\Core\StringTranslation\PluralTranslatableString + * @return \Drupal\Core\StringTranslation\PluralTranslatableMarkup * A translated string. * * @see \Drupal\Core\StringTranslation\TranslationInterface::translate() * @see t() * @see \Drupal\Component\Utility\SafeMarkup::format() - * @see \Drupal\Core\StringTranslation\PluralTranslatableString::createFromTranslatedString() + * @see \Drupal\Core\StringTranslation\PluralTranslatableMarkup::createFromTranslatedString() */ public function formatPlural($count, $singular, $plural, array $args = array(), array $options = array()); diff --git a/core/lib/Drupal/Core/StringTranslation/TranslationManager.php b/core/lib/Drupal/Core/StringTranslation/TranslationManager.php index ec16db217ba6d699512d466663af11f2cccc2527..7ccf5a39a1e5185e696a57b3e3e4a82113340a13 100644 --- a/core/lib/Drupal/Core/StringTranslation/TranslationManager.php +++ b/core/lib/Drupal/Core/StringTranslation/TranslationManager.php @@ -110,13 +110,13 @@ public function getStringTranslation($langcode, $string, $context) { * {@inheritdoc} */ public function translate($string, array $args = array(), array $options = array()) { - return new TranslatableString($string, $args, $options, $this); + return new TranslatableMarkup($string, $args, $options, $this); } /** * {@inheritdoc} */ - public function translateString(TranslatableString $translated_string) { + public function translateString(TranslatableMarkup $translated_string) { return $this->doTranslate($translated_string->getUntranslatedString(), $translated_string->getOptions()); } @@ -148,7 +148,7 @@ protected function doTranslate($string, array $options = array()) { * {@inheritdoc} */ public function formatPlural($count, $singular, $plural, array $args = array(), array $options = array()) { - return new PluralTranslatableString($count, $singular, $plural, $args, $options, $this); + return new PluralTranslatableMarkup($count, $singular, $plural, $args, $options, $this); } /** diff --git a/core/lib/Drupal/Core/StringTranslation/TranslationWrapper.php b/core/lib/Drupal/Core/StringTranslation/TranslationWrapper.php index 0a72c23f2e134dbb20c9f22444fb12481a65e2d1..2e43a11800dc714398c5486eecebb4442e9843c4 100644 --- a/core/lib/Drupal/Core/StringTranslation/TranslationWrapper.php +++ b/core/lib/Drupal/Core/StringTranslation/TranslationWrapper.php @@ -11,6 +11,6 @@ * Provides translatable string class. * * @deprecated in Drupal 8.x, will be removed before Drupal 9.0. - * Use the \Drupal\Core\StringTranslation\TranslatableString class instead. + * Use the \Drupal\Core\StringTranslation\TranslatableMarkup class instead. */ -class TranslationWrapper extends TranslatableString {} +class TranslationWrapper extends TranslatableMarkup {} diff --git a/core/lib/Drupal/Core/Template/Attribute.php b/core/lib/Drupal/Core/Template/Attribute.php index 878402512599a65bf7e9dc86ccad9a20bb429fec..a794142798a8381adf39554af66a505099cd3d64 100644 --- a/core/lib/Drupal/Core/Template/Attribute.php +++ b/core/lib/Drupal/Core/Template/Attribute.php @@ -7,9 +7,9 @@ namespace Drupal\Core\Template; -use Drupal\Component\Utility\PlainTextOutput; +use Drupal\Component\Render\PlainTextOutput; use Drupal\Component\Utility\SafeMarkup; -use Drupal\Component\Utility\SafeStringInterface; +use Drupal\Component\Render\MarkupInterface; /** * Collects, sanitizes, and renders HTML attributes. @@ -65,10 +65,10 @@ * @endcode * * @see \Drupal\Component\Utility\Html::escape() - * @see \Drupal\Component\Utility\PlainTextOutput::renderFromHtml() + * @see \Drupal\Component\Render\PlainTextOutput::renderFromHtml() * @see \Drupal\Component\Utility\UrlHelper::stripDangerousProtocols() */ -class Attribute implements \ArrayAccess, \IteratorAggregate, SafeStringInterface { +class Attribute implements \ArrayAccess, \IteratorAggregate, MarkupInterface { /** * Stores the attribute data. @@ -125,7 +125,7 @@ protected function createAttributeValue($name, $value) { // An array value or 'class' attribute name are forced to always be an // AttributeArray value for consistency. if ($name == 'class' && !is_array($value)) { - // Cast the value to string in case it implements SafeStringInterface. + // Cast the value to string in case it implements MarkupInterface. $value = [(string) $value]; } if (is_array($value)) { diff --git a/core/lib/Drupal/Core/Template/TwigEnvironment.php b/core/lib/Drupal/Core/Template/TwigEnvironment.php index 845f219a8ab9327415b7a48e231722589a4dd313..8d3feaae011b07c9daafbe77df323ac2a6d68e09 100644 --- a/core/lib/Drupal/Core/Template/TwigEnvironment.php +++ b/core/lib/Drupal/Core/Template/TwigEnvironment.php @@ -9,7 +9,7 @@ use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Cache\CacheBackendInterface; -use Drupal\Core\Render\SafeString; +use Drupal\Core\Render\Markup; /** * A class that defines a Twig environment for Drupal. @@ -107,15 +107,15 @@ public function getTemplateClass($name, $index = NULL) { * @param array $context * An array of parameters to pass to the template. * - * @return \Drupal\Component\Utility\SafeStringInterface|string - * The rendered inline template as a SafeString object. + * @return \Drupal\Component\Render\MarkupInterface|string + * The rendered inline template as a Markup object. * * @see \Drupal\Core\Template\Loader\StringLoader::exists() */ public function renderInline($template_string, array $context = array()) { // Prefix all inline templates with a special comment. $template_string = '{# inline_template_start #}' . $template_string; - return SafeString::create($this->loadTemplate($template_string, NULL)->render($context)); + return Markup::create($this->loadTemplate($template_string, NULL)->render($context)); } } diff --git a/core/lib/Drupal/Core/Template/TwigExtension.php b/core/lib/Drupal/Core/Template/TwigExtension.php index 552ef547ed033bd33931d525e42738d4a12c33cd..23091d5bbdc35ce497c4dbe46a1df57d62c773b7 100644 --- a/core/lib/Drupal/Core/Template/TwigExtension.php +++ b/core/lib/Drupal/Core/Template/TwigExtension.php @@ -14,7 +14,7 @@ use Drupal\Component\Utility\Html; use Drupal\Component\Utility\SafeMarkup; -use Drupal\Component\Utility\SafeStringInterface; +use Drupal\Component\Render\MarkupInterface; use Drupal\Core\Datetime\DateFormatter; use Drupal\Core\Render\RenderableInterface; use Drupal\Core\Render\RendererInterface; @@ -404,7 +404,7 @@ public function escapeFilter(\Twig_Environment $env, $arg, $strategy = 'html', $ } // Keep Twig_Markup objects intact to support autoescaping. - if ($autoescape && ($arg instanceOf \Twig_Markup || $arg instanceOf SafeStringInterface)) { + if ($autoescape && ($arg instanceOf \Twig_Markup || $arg instanceOf MarkupInterface)) { return $arg; } diff --git a/core/lib/Drupal/Core/Theme/ThemeManager.php b/core/lib/Drupal/Core/Theme/ThemeManager.php index 9958b56347dafbf3aeabe26f24f9311d79455db3..7e0e0b48ca8b3e8db9ead3c83812a29bb876fe0d 100644 --- a/core/lib/Drupal/Core/Theme/ThemeManager.php +++ b/core/lib/Drupal/Core/Theme/ThemeManager.php @@ -7,8 +7,8 @@ namespace Drupal\Core\Theme; -use Drupal\Component\Utility\SafeStringInterface; -use Drupal\Core\Render\SafeString; +use Drupal\Component\Render\MarkupInterface; +use Drupal\Core\Render\Markup; use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Routing\StackedRouteMatchInterface; use Symfony\Component\HttpFoundation\RequestStack; @@ -319,7 +319,7 @@ public function render($hook, array $variables) { // Theme functions do not render via the theme engine, so the output is // not autoescaped. However, we can only presume that the theme function // has been written correctly and that the markup is safe. - $output = SafeString::create($info['function']($variables)); + $output = Markup::create($info['function']($variables)); } } else { @@ -389,7 +389,7 @@ public function render($hook, array $variables) { $output = $render_function($template_file, $variables); } - return ($output instanceof SafeStringInterface) ? $output : (string) $output; + return ($output instanceof MarkupInterface) ? $output : (string) $output; } /** diff --git a/core/lib/Drupal/Core/Theme/ThemeManagerInterface.php b/core/lib/Drupal/Core/Theme/ThemeManagerInterface.php index b61ff84391d524a5013c3d7a721a82724bf5350b..029cda0089e5973ab9ca2f3a3d23eb5e07ebc81d 100644 --- a/core/lib/Drupal/Core/Theme/ThemeManagerInterface.php +++ b/core/lib/Drupal/Core/Theme/ThemeManagerInterface.php @@ -26,8 +26,8 @@ interface ThemeManagerInterface { * @param array $variables * An associative array of theme variables. * - * @return string|\Drupal\Component\Utility\SafeStringInterface - * The rendered output, or a SafeString object. + * @return string|\Drupal\Component\Render\MarkupInterface + * The rendered output, or a Markup object. */ public function render($hook, array $variables); diff --git a/core/lib/Drupal/Core/Utility/LinkGenerator.php b/core/lib/Drupal/Core/Utility/LinkGenerator.php index 6eb473b3b628d891e62661b6aaf6f42a059a4d03..8b453f7eabbaca0c7005c960bc274c78dbf3f34d 100644 --- a/core/lib/Drupal/Core/Utility/LinkGenerator.php +++ b/core/lib/Drupal/Core/Utility/LinkGenerator.php @@ -10,7 +10,7 @@ use Drupal\Component\Serialization\Json; use Drupal\Component\Utility\Html; use Drupal\Component\Utility\SafeMarkup; -use Drupal\Component\Utility\SafeStringInterface; +use Drupal\Component\Render\MarkupInterface; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\GeneratedLink; use Drupal\Core\Link; @@ -114,7 +114,7 @@ public function generate($text, Url $url) { // Ensure that query values are strings. array_walk($variables['options']['query'], function(&$value) { - if ($value instanceof SafeStringInterface) { + if ($value instanceof MarkupInterface) { $value = (string) $value; } }); diff --git a/core/lib/Drupal/Core/Utility/token.api.php b/core/lib/Drupal/Core/Utility/token.api.php index 4bc619f7da7876af93286241e4715d4352238e91..d39d66f10744eac6340872a45943de057061f624 100644 --- a/core/lib/Drupal/Core/Utility/token.api.php +++ b/core/lib/Drupal/Core/Utility/token.api.php @@ -65,7 +65,7 @@ * @return array * An associative array of replacement values, keyed by the raw [type:token] * strings from the original text. The returned values must be either plain - * text strings, or an object implementing SafeStringInterface if they are + * text strings, or an object implementing MarkupInterface if they are * HTML-formatted. * * @see hook_token_info() diff --git a/core/lib/Drupal/Core/Validation/ConstraintManager.php b/core/lib/Drupal/Core/Validation/ConstraintManager.php index 7c61b03bb1bab62ec14731de4cae6046600b6c58..1dd9a031490d29292e6e681ab7b96c02768533a9 100644 --- a/core/lib/Drupal/Core/Validation/ConstraintManager.php +++ b/core/lib/Drupal/Core/Validation/ConstraintManager.php @@ -11,7 +11,7 @@ use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Plugin\DefaultPluginManager; -use Drupal\Core\StringTranslation\TranslatableString; +use Drupal\Core\StringTranslation\TranslatableMarkup; /** * Constraint plugin manager. @@ -91,22 +91,22 @@ public function create($name, $options) { */ public function registerDefinitions() { $this->getDiscovery()->setDefinition('Callback', array( - 'label' => new TranslatableString('Callback'), + 'label' => new TranslatableMarkup('Callback'), 'class' => '\Symfony\Component\Validator\Constraints\Callback', 'type' => FALSE, )); $this->getDiscovery()->setDefinition('Blank', array( - 'label' => new TranslatableString('Blank'), + 'label' => new TranslatableMarkup('Blank'), 'class' => '\Symfony\Component\Validator\Constraints\Blank', 'type' => FALSE, )); $this->getDiscovery()->setDefinition('NotBlank', array( - 'label' => new TranslatableString('Not blank'), + 'label' => new TranslatableMarkup('Not blank'), 'class' => '\Symfony\Component\Validator\Constraints\NotBlank', 'type' => FALSE, )); $this->getDiscovery()->setDefinition('Email', array( - 'label' => new TranslatableString('Email'), + 'label' => new TranslatableMarkup('Email'), 'class' => '\Drupal\Core\Validation\Plugin\Validation\Constraint\EmailConstraint', 'type' => array('string'), )); diff --git a/core/lib/Drupal/Core/Validation/DrupalTranslator.php b/core/lib/Drupal/Core/Validation/DrupalTranslator.php index 4318f9d4d869f4f16f5e67f9ac584256a6d7a707..c7db71cd34d31eec8e34019ad0e1e61130c45545 100644 --- a/core/lib/Drupal/Core/Validation/DrupalTranslator.php +++ b/core/lib/Drupal/Core/Validation/DrupalTranslator.php @@ -7,7 +7,7 @@ namespace Drupal\Core\Validation; -use Drupal\Component\Utility\SafeStringInterface; +use Drupal\Component\Render\MarkupInterface; /** * Translates strings using Drupal's translation system. @@ -77,8 +77,8 @@ protected function processParameters(array $parameters) { foreach ($parameters as $key => $value) { // We allow the values in the parameters to be safe string objects. This // can be useful when we want to use parameter values that are - // TranslatableStrings. - if ($value instanceof SafeStringInterface) { + // TranslatableMarkup. + if ($value instanceof MarkupInterface) { $value = (string) $value; } if (is_object($value)) { diff --git a/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/PrimitiveTypeConstraintValidator.php b/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/PrimitiveTypeConstraintValidator.php index 6fa8771dd39d1a02661c6e423c853ccbd7f0cca0..503825f88109d64603c94e41a7cf712220fa1077 100644 --- a/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/PrimitiveTypeConstraintValidator.php +++ b/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/PrimitiveTypeConstraintValidator.php @@ -16,7 +16,7 @@ use Drupal\Core\TypedData\Type\StringInterface; use Drupal\Core\TypedData\Type\UriInterface; use Drupal\Core\TypedData\Validation\TypedDataAwareValidatorTrait; -use Drupal\Component\Utility\SafeStringInterface; +use Drupal\Component\Render\MarkupInterface; use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidator; @@ -50,7 +50,7 @@ public function validate($value, Constraint $constraint) { if ($typed_data instanceof IntegerInterface && filter_var($value, FILTER_VALIDATE_INT) === FALSE) { $valid = FALSE; } - if ($typed_data instanceof StringInterface && !is_scalar($value) && !($value instanceof SafeStringInterface)) { + if ($typed_data instanceof StringInterface && !is_scalar($value) && !($value instanceof MarkupInterface)) { $valid = FALSE; } // Ensure that URIs comply with http://tools.ietf.org/html/rfc3986, which diff --git a/core/modules/action/src/Plugin/Action/EmailAction.php b/core/modules/action/src/Plugin/Action/EmailAction.php index 4c68e1d0086029a487caa49335c75f629f36dc02..797d8a435c4dbb9dd0f2c687286f0028cfac2ea3 100644 --- a/core/modules/action/src/Plugin/Action/EmailAction.php +++ b/core/modules/action/src/Plugin/Action/EmailAction.php @@ -7,7 +7,7 @@ namespace Drupal\action\Plugin\Action; -use Drupal\Component\Utility\PlainTextOutput; +use Drupal\Component\Render\PlainTextOutput; use Drupal\Core\Access\AccessResult; use Drupal\Core\Action\ConfigurableActionBase; use Drupal\Core\Entity\EntityManagerInterface; diff --git a/core/modules/comment/comment.tokens.inc b/core/modules/comment/comment.tokens.inc index e2d606f5dd4aa5e765f73719dfdf774f90dc303a..73f48b7a06e530512a7acd03f9b14a8437c6f184 100644 --- a/core/modules/comment/comment.tokens.inc +++ b/core/modules/comment/comment.tokens.inc @@ -154,8 +154,8 @@ function comment_tokens($type, $tokens, array $data, array $options, BubbleableM break; case 'body': - // "processed" returns a \Drupal\Component\Utility\SafeStringInterface - // via check_markup(). + // "processed" returns a \Drupal\Component\Render\MarkupInterface via + // check_markup(). $replacements[$original] = $comment->comment_body->processed; break; diff --git a/core/modules/comment/src/Tests/CommentTokenReplaceTest.php b/core/modules/comment/src/Tests/CommentTokenReplaceTest.php index 13c415e7d2db1fc858109097992d310104bbc0b2..b7172e3541aa181ab37edd705680ccbddb1b95c6 100644 --- a/core/modules/comment/src/Tests/CommentTokenReplaceTest.php +++ b/core/modules/comment/src/Tests/CommentTokenReplaceTest.php @@ -7,7 +7,7 @@ namespace Drupal\comment\Tests; -use Drupal\Component\Utility\FormattableString; +use Drupal\Component\Render\FormattableMarkup; use Drupal\Component\Utility\Html; use Drupal\Component\Utility\UrlHelper; use Drupal\Component\Utility\Xss; @@ -118,7 +118,7 @@ function testCommentTokenReplacement() { foreach ($tests as $input => $expected) { $bubbleable_metadata = new BubbleableMetadata(); $output = $token_service->replace($input, array('comment' => $comment), array('langcode' => $language_interface->getId()), $bubbleable_metadata); - $this->assertEqual($output, $expected, new FormattableString('Comment token %token replaced.', ['%token' => $input])); + $this->assertEqual($output, $expected, new FormattableMarkup('Comment token %token replaced.', ['%token' => $input])); $this->assertEqual($bubbleable_metadata, $metadata_tests[$input]); } diff --git a/core/modules/contact/src/Tests/ContactPersonalTest.php b/core/modules/contact/src/Tests/ContactPersonalTest.php index 7028a4806b42998ba3ff097290fc95c69d371031..d13324006d709481819e099d8bc954cca1d593bf 100644 --- a/core/modules/contact/src/Tests/ContactPersonalTest.php +++ b/core/modules/contact/src/Tests/ContactPersonalTest.php @@ -8,7 +8,7 @@ namespace Drupal\contact\Tests; use Drupal\Component\Utility\SafeMarkup; -use Drupal\Component\Utility\PlainTextOutput; +use Drupal\Component\Render\PlainTextOutput; use Drupal\Core\Session\AccountInterface; use Drupal\simpletest\WebTestBase; use Drupal\user\RoleInterface; diff --git a/core/modules/content_translation/content_translation.module b/core/modules/content_translation/content_translation.module index 39ff55149747d91d6513fe0d38c784f561cd88f3..0370367bbf200ef15977c96ab3366a8bc22039ff 100644 --- a/core/modules/content_translation/content_translation.module +++ b/core/modules/content_translation/content_translation.module @@ -13,7 +13,7 @@ use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Routing\RouteMatchInterface; -use Drupal\Core\StringTranslation\TranslatableString; +use Drupal\Core\StringTranslation\TranslatableMarkup; /** * Implements hook_help(). @@ -252,8 +252,8 @@ function content_translation_views_data_alter(array &$data) { */ function content_translation_menu_links_discovered_alter(array &$links) { // Clarify where translation settings are located. - $links['language.content_settings_page']['title'] = new TranslatableString('Content language and translation'); - $links['language.content_settings_page']['description'] = new TranslatableString('Configure language and translation support for content.'); + $links['language.content_settings_page']['title'] = new TranslatableMarkup('Content language and translation'); + $links['language.content_settings_page']['description'] = new TranslatableMarkup('Configure language and translation support for content.'); } /** diff --git a/core/modules/dblog/dblog.module b/core/modules/dblog/dblog.module index 33051784d6dd44842654c471586dc62c74a51429..a42242be4d3282d5273c997fa757ae81c2061af4 100644 --- a/core/modules/dblog/dblog.module +++ b/core/modules/dblog/dblog.module @@ -11,7 +11,7 @@ use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Routing\RouteMatchInterface; -use Drupal\Core\StringTranslation\TranslatableString; +use Drupal\Core\StringTranslation\TranslatableMarkup; /** * Implements hook_help(). @@ -42,9 +42,9 @@ function dblog_help($route_name, RouteMatchInterface $route_match) { function dblog_menu_links_discovered_alter(&$links) { if (\Drupal::moduleHandler()->moduleExists('search')) { $links['dblog.search'] = array( - 'title' => new TranslatableString('Top search phrases'), + 'title' => new TranslatableMarkup('Top search phrases'), 'route_name' => 'dblog.search', - 'description' => new TranslatableString('View most popular search phrases.'), + 'description' => new TranslatableMarkup('View most popular search phrases.'), 'parent' => 'system.admin_reports', ); } diff --git a/core/modules/editor/editor.module b/core/modules/editor/editor.module index 1e645ddde261dff39e4de61564c9b5b6a9701620..0e4f79565fdd88f62606db0cecf4b87cca7f6bc4 100644 --- a/core/modules/editor/editor.module +++ b/core/modules/editor/editor.module @@ -11,7 +11,7 @@ use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Render\Element; use Drupal\Core\Routing\RouteMatchInterface; -use Drupal\Core\StringTranslation\TranslatableString; +use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\Core\Entity\EntityInterface; use Drupal\filter\FilterFormatInterface; use Drupal\filter\Plugin\FilterInterface; @@ -47,8 +47,8 @@ function editor_help($route_name, RouteMatchInterface $route_match) { * of text editors. */ function editor_menu_links_discovered_alter(array &$links) { - $links['filter.admin_overview']['title'] = new TranslatableString('Text formats and editors'); - $links['filter.admin_overview']['description'] = new TranslatableString('Configure how user-contributed content is filtered and formatted, as well as the text editor user interface (WYSIWYGs or toolbars).'); + $links['filter.admin_overview']['title'] = new TranslatableMarkup('Text formats and editors'); + $links['filter.admin_overview']['description'] = new TranslatableMarkup('Configure how user-contributed content is filtered and formatted, as well as the text editor user interface (WYSIWYGs or toolbars).'); } /** diff --git a/core/modules/field/src/Tests/EntityReference/EntityReferenceItemTest.php b/core/modules/field/src/Tests/EntityReference/EntityReferenceItemTest.php index 8d492e5c98e1c1fa6916f7cb6557eb7d01e2e79c..d785696bfb5264c0e4ceac4988effab335c163ab 100644 --- a/core/modules/field/src/Tests/EntityReference/EntityReferenceItemTest.php +++ b/core/modules/field/src/Tests/EntityReference/EntityReferenceItemTest.php @@ -10,7 +10,7 @@ use Drupal\Component\Utility\Unicode; use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Field\FieldItemInterface; -use Drupal\Core\StringTranslation\TranslatableString; +use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\Core\Language\LanguageInterface; use Drupal\entity_test\Entity\EntityTest; use Drupal\entity_reference\Tests\EntityReferenceTestTrait; @@ -114,7 +114,7 @@ public function testContentEntityReferenceItem() { $this->assertEqual($entity->field_test_taxonomy_term->entity->uuid(), $this->term->uuid()); // Verify that the label for the target ID property definition is correct. $label = $entity->field_test_taxonomy_term->getFieldDefinition()->getFieldStorageDefinition()->getPropertyDefinition('target_id')->getLabel(); - $this->assertTrue($label instanceof TranslatableString); + $this->assertTrue($label instanceof TranslatableMarkup); $this->assertEqual($label->render(), 'Taxonomy term ID'); // Change the name of the term via the reference. @@ -185,7 +185,7 @@ public function testContentEntityReferenceItemWithStringId() { $this->assertEqual($this->entityStringId->id(), $storage->load($entity->id())->field_test_entity_test_string_id->target_id); // Verify that the label for the target ID property definition is correct. $label = $entity->field_test_taxonomy_term->getFieldDefinition()->getFieldStorageDefinition()->getPropertyDefinition('target_id')->getLabel(); - $this->assertTrue($label instanceof TranslatableString); + $this->assertTrue($label instanceof TranslatableMarkup); $this->assertEqual($label->render(), 'Taxonomy term ID'); } diff --git a/core/modules/field_ui/src/Form/FieldConfigEditForm.php b/core/modules/field_ui/src/Form/FieldConfigEditForm.php index ba972a9f99763ccbe0484433c5e283fc04e76110..e2d1bce8a7c1697282d77de1d23a92c3008b8696 100644 --- a/core/modules/field_ui/src/Form/FieldConfigEditForm.php +++ b/core/modules/field_ui/src/Form/FieldConfigEditForm.php @@ -9,7 +9,7 @@ use Drupal\Core\Entity\EntityForm; use Drupal\Core\Field\AllowedTagsXssTrait; -use Drupal\Core\Field\FieldFilteredString; +use Drupal\Core\Field\FieldFilteredMarkup; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; use Drupal\field\FieldConfigInterface; @@ -65,7 +65,7 @@ public function form(array $form, FormStateInterface $form_state) { '#title' => $this->t('Help text'), '#default_value' => $this->entity->getDescription(), '#rows' => 5, - '#description' => $this->t('Instructions to present to the user below this field on the editing form.
Allowed HTML tags: @tags', array('@tags' => FieldFilteredString::displayAllowedTags())) . '
' . $this->t('This field supports tokens.'), + '#description' => $this->t('Instructions to present to the user below this field on the editing form.
Allowed HTML tags: @tags', array('@tags' => FieldFilteredMarkup::displayAllowedTags())) . '
' . $this->t('This field supports tokens.'), '#weight' => -10, ); diff --git a/core/modules/file/file.field.inc b/core/modules/file/file.field.inc index 50b913fe644b05019981c582a7a2b41764fc4c0a..aac6bd8ff2d680e0aa601f60bae571ff68b4992c 100644 --- a/core/modules/file/file.field.inc +++ b/core/modules/file/file.field.inc @@ -7,7 +7,7 @@ use Drupal\Component\Utility\Html; use Drupal\Core\Field\FieldDefinitionInterface; -use Drupal\Core\Field\FieldFilteredString; +use Drupal\Core\Field\FieldFilteredMarkup; use Drupal\Core\Render\Element; /** @@ -169,7 +169,7 @@ function template_preprocess_file_upload_help(&$variables) { $descriptions = array(); if (!empty($description)) { - $descriptions[] = FieldFilteredString::create($description); + $descriptions[] = FieldFilteredMarkup::create($description); } if (isset($cardinality)) { if ($cardinality == -1) { diff --git a/core/modules/file/src/Plugin/Field/FieldType/FileItem.php b/core/modules/file/src/Plugin/Field/FieldType/FileItem.php index 8bbe278f78926fd3c89d534355f0cacfb5b5cac6..3d6bfc543025fb45732044cea012c56ce1732cab 100644 --- a/core/modules/file/src/Plugin/Field/FieldType/FileItem.php +++ b/core/modules/file/src/Plugin/Field/FieldType/FileItem.php @@ -8,7 +8,7 @@ namespace Drupal\file\Plugin\Field\FieldType; use Drupal\Component\Utility\Bytes; -use Drupal\Component\Utility\PlainTextOutput; +use Drupal\Component\Render\PlainTextOutput; use Drupal\Component\Utility\Random; use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FieldStorageDefinitionInterface; diff --git a/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php b/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php index 5852ab42c724c760ea1d567cdadfb2ff2779f83b..7d32ce90f93c24862b4ec4bff4af1b04f9f5cbc4 100644 --- a/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php +++ b/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php @@ -9,7 +9,7 @@ use Drupal\Component\Utility\NestedArray; use Drupal\Core\Field\FieldDefinitionInterface; -use Drupal\Core\Field\FieldFilteredString; +use Drupal\Core\Field\FieldFilteredMarkup; use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\Core\Field\WidgetBase; @@ -119,7 +119,7 @@ protected function formMultipleElements(FieldItemListInterface $items, array &$f } $title = $this->fieldDefinition->getLabel(); - $description = FieldFilteredString::create($this->fieldDefinition->getDescription()); + $description = FieldFilteredMarkup::create($this->fieldDefinition->getDescription()); $elements = array(); diff --git a/core/modules/filter/filter.module b/core/modules/filter/filter.module index 6c4db0a56f7d8231123ccc08751f44f6c6a9cf8c..934bda6ce35dbadf335186dfaaf349c197250db6 100644 --- a/core/modules/filter/filter.module +++ b/core/modules/filter/filter.module @@ -286,7 +286,7 @@ function filter_fallback_format() { * FilterInterface::TYPE_HTML_RESTRICTOR is the only type that cannot be * skipped. * - * @return \Drupal\Component\Utility\SafeStringInterface + * @return \Drupal\Component\Render\MarkupInterface * The filtered text. * * @see filter_process_text() diff --git a/core/modules/filter/src/Element/ProcessedText.php b/core/modules/filter/src/Element/ProcessedText.php index de9d5cc0112c7ccdad17953a797b695a7812aa0a..6a3fa4018390b9cc3de2d6f79de0ada3eed1d5f4 100644 --- a/core/modules/filter/src/Element/ProcessedText.php +++ b/core/modules/filter/src/Element/ProcessedText.php @@ -14,7 +14,7 @@ use Drupal\Core\Render\Renderer; use Drupal\filter\Entity\FilterFormat; use Drupal\filter\Plugin\FilterInterface; -use Drupal\filter\Render\FilteredString; +use Drupal\filter\Render\FilteredMarkup; /** * Provides a processed text render element. @@ -127,7 +127,7 @@ public static function preRenderText($element) { // safe, but it has been passed through the filter system and checked with // a text format, so it must be printed as is. (See the note about security // in the method documentation above.) - $element['#markup'] = FilteredString::create($text); + $element['#markup'] = FilteredMarkup::create($text); // Set the updated bubbleable rendering metadata and the text format's // cache tag. diff --git a/core/modules/filter/src/Plugin/Filter/FilterCaption.php b/core/modules/filter/src/Plugin/Filter/FilterCaption.php index 767145229f100a1a56901c93feec15cd7b3e5e9f..37c18cc3bc76d66fc9a7d9838f556b16ca3325b4 100644 --- a/core/modules/filter/src/Plugin/Filter/FilterCaption.php +++ b/core/modules/filter/src/Plugin/Filter/FilterCaption.php @@ -12,7 +12,7 @@ use Drupal\Component\Utility\Xss; use Drupal\filter\FilterProcessResult; use Drupal\filter\Plugin\FilterBase; -use Drupal\filter\Render\FilteredString; +use Drupal\filter\Render\FilteredMarkup; /** * Provides a filter to caption elements. @@ -45,7 +45,7 @@ public function process($text, $langcode) { // Sanitize caption: decode HTML encoding, limit allowed HTML tags; only // allow inline tags that are allowed by default, plus
. $caption = Html::decodeEntities($caption); - $caption = FilteredString::create(Xss::filter($caption, array('a', 'em', 'strong', 'cite', 'code', 'br'))); + $caption = FilteredMarkup::create(Xss::filter($caption, array('a', 'em', 'strong', 'cite', 'code', 'br'))); // The caption must be non-empty. if (Unicode::strlen($caption) === 0) { @@ -62,7 +62,7 @@ public function process($text, $langcode) { // We pass the unsanitized string because this is a text format // filter, and after filtering, we always assume the output is safe. // @see \Drupal\filter\Element\ProcessedText::preRenderText() - '#node' => FilteredString::create($node->C14N()), + '#node' => FilteredMarkup::create($node->C14N()), '#tag' => $node->tagName, '#caption' => $caption, '#classes' => $classes, diff --git a/core/modules/filter/src/Render/FilteredMarkup.php b/core/modules/filter/src/Render/FilteredMarkup.php new file mode 100644 index 0000000000000000000000000000000000000000..2abfac3baf28b0f55d807a50d297f63eb08552ef --- /dev/null +++ b/core/modules/filter/src/Render/FilteredMarkup.php @@ -0,0 +1,29 @@ +getValue(), array(), $options); + return new TranslatableMarkup($element->getValue(), array(), $options); } } return $translatable; @@ -191,10 +191,10 @@ protected function getTranslatableData(TypedDataInterface $element) { * The configuration name. * @param array $active * The active configuration data. - * @param array|\Drupal\Core\StringTranslation\TranslatableString[] $translatable + * @param array|\Drupal\Core\StringTranslation\TranslatableMarkup[] $translatable * The translatable array structure. A nested array matching the exact * structure under of the default configuration for $name with only the - * elements that are translatable wrapped into a TranslatableString. + * elements that are translatable wrapped into a TranslatableMarkup. * @see self::getTranslatableData(). * @param string $langcode * The language code to process the array with. diff --git a/core/modules/locale/src/LocaleConfigSubscriber.php b/core/modules/locale/src/LocaleConfigSubscriber.php index 1c1048017c5fda2e87703a3433b29df6126d5087..bb20102ba20e4b92e1321af54d9599c325cdfa41 100644 --- a/core/modules/locale/src/LocaleConfigSubscriber.php +++ b/core/modules/locale/src/LocaleConfigSubscriber.php @@ -133,7 +133,7 @@ protected function updateLocaleStorage(StorableConfigBase $config, $langcode, ar * The configuration name. * @param array $config * The active configuration data or override data. - * @param array|\Drupal\Core\StringTranslation\TranslatableString[] $translatable + * @param array|\Drupal\Core\StringTranslation\TranslatableMarkup[] $translatable * The translatable array structure. * @see \Drupal\locale\LocaleConfigManager::getTranslatableData() * @param string $langcode @@ -169,9 +169,9 @@ protected function processTranslatableData($name, array $config, array $translat * * @param string $name * The configuration name. - * @param array|\Drupal\Core\StringTranslation\TranslatableString $translatable - * Either a possibly nested array with TranslatableString objects at the - * leaf items or a TranslatableString object directly. + * @param array|\Drupal\Core\StringTranslation\TranslatableMarkup $translatable + * Either a possibly nested array with TranslatableMarkup objects at the + * leaf items or a TranslatableMarkup object directly. * @param array|string $reference_config * Either a possibly nested array with strings at the leaf items or a string * directly. Only those $translatable items that are also present in diff --git a/core/modules/locale/src/Tests/LocalePluralFormatTest.php b/core/modules/locale/src/Tests/LocalePluralFormatTest.php index 386cd5d378eb8e7fe0fa684fdeeb43f544c42d38..ba5cf84a2ee0a69cb39bfb1237ba431a34e7d819 100644 --- a/core/modules/locale/src/Tests/LocalePluralFormatTest.php +++ b/core/modules/locale/src/Tests/LocalePluralFormatTest.php @@ -7,7 +7,7 @@ namespace Drupal\locale\Tests; -use Drupal\Core\StringTranslation\PluralTranslatableString; +use Drupal\Core\StringTranslation\PluralTranslatableMarkup; use Drupal\simpletest\WebTestBase; /** @@ -133,12 +133,12 @@ public function testGetPluralFormat() { $expected_plural_string = str_replace('@count', $count, $plural_strings[$langcode][$expected_plural_index]); $this->assertIdentical(\Drupal::translation()->formatPlural($count, '1 hour', '@count hours', array(), array('langcode' => $langcode))->render(), $expected_plural_string, 'Plural translation of 1 hours / @count hours for count ' . $count . ' in ' . $langcode . ' is ' . $expected_plural_string); // DO NOT use translation to pass translated strings into - // PluralTranslatableString::createFromTranslatedString() this way. It + // PluralTranslatableMarkup::createFromTranslatedString() this way. It // is designed to be used with *already* translated text like settings // from configuration. We use PHP translation here just because we have // the expected result data in that format. - $translated_string = \Drupal::translation()->translate('1 hour' . PluralTranslatableString::DELIMITER . '@count hours', array(), array('langcode' => $langcode)); - $plural = PluralTranslatableString::createFromTranslatedString($count, $translated_string, array(), array('langcode' => $langcode)); + $translated_string = \Drupal::translation()->translate('1 hour' . PluralTranslatableMarkup::DELIMITER . '@count hours', array(), array('langcode' => $langcode)); + $plural = PluralTranslatableMarkup::createFromTranslatedString($count, $translated_string, array(), array('langcode' => $langcode)); $this->assertIdentical($plural->render(), $expected_plural_string); } } diff --git a/core/modules/menu_link_content/src/Tests/MenuLinkContentDeriverTest.php b/core/modules/menu_link_content/src/Tests/MenuLinkContentDeriverTest.php index 554f2ea0655ad2771aa8d8e63611fb48f544b781..b5ae7aeeb8685fcbc22a1b077d10e24df869955e 100644 --- a/core/modules/menu_link_content/src/Tests/MenuLinkContentDeriverTest.php +++ b/core/modules/menu_link_content/src/Tests/MenuLinkContentDeriverTest.php @@ -9,7 +9,7 @@ use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Menu\MenuTreeParameters; -use Drupal\Core\StringTranslation\TranslatableString; +use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\menu_link_content\Entity\MenuLinkContent; use Drupal\simpletest\KernelTestBase; use Symfony\Component\Routing\Route; @@ -71,7 +71,7 @@ public function testRediscover() { $tree_element = reset($menu_tree); $this->assertEqual('route_name_2', $tree_element->link->getRouteName()); $title = $tree_element->link->getTitle(); - $this->assertFalse($title instanceof TranslatableString); + $this->assertFalse($title instanceof TranslatableMarkup); $this->assertIdentical('', $title); $this->assertFalse(SafeMarkup::isSafe($title)); diff --git a/core/modules/node/node.tokens.inc b/core/modules/node/node.tokens.inc index dbe8da29ce897370e96c16e1af269a1243b3edae..81fa3f088e0a57ac6a46b0ac695af053d5066ea2 100644 --- a/core/modules/node/node.tokens.inc +++ b/core/modules/node/node.tokens.inc @@ -155,8 +155,8 @@ function node_tokens($type, $tokens, array $data, array $options, BubbleableMeta $output = text_summary($output, $item->format, $length); } } - // "processed" returns a - // \Drupal\Component\Utility\SafeStringInterface via check_markup(). + // "processed" returns a \Drupal\Component\Render\MarkupInterface + // via check_markup(). $replacements[$original] = $output; } break; diff --git a/core/modules/node/src/Tests/NodeTokenReplaceTest.php b/core/modules/node/src/Tests/NodeTokenReplaceTest.php index a99637f5b7f353d3d37f4ac53f74f7e281b2fa26..bc6a04902ae0fc3c4c08f9cc8bd2086069208bfb 100644 --- a/core/modules/node/src/Tests/NodeTokenReplaceTest.php +++ b/core/modules/node/src/Tests/NodeTokenReplaceTest.php @@ -7,7 +7,7 @@ namespace Drupal\node\Tests; -use Drupal\Component\Utility\FormattableString; +use Drupal\Component\Render\FormattableMarkup; use Drupal\Component\Utility\Html; use Drupal\Core\Render\BubbleableMetadata; use Drupal\system\Tests\System\TokenReplaceUnitTestBase; @@ -127,7 +127,7 @@ function testNodeTokenReplacement() { foreach ($tests as $input => $expected) { $output = $this->tokenService->replace($input, array('node' => $node), array('language' => $this->interfaceLanguage)); - $this->assertEqual($output, $expected, new FormattableString('Node token %token replaced for node without a summary.', ['%token' => $input])); + $this->assertEqual($output, $expected, new FormattableMarkup('Node token %token replaced for node without a summary.', ['%token' => $input])); } } diff --git a/core/modules/options/src/Plugin/Field/FieldFormatter/OptionsDefaultFormatter.php b/core/modules/options/src/Plugin/Field/FieldFormatter/OptionsDefaultFormatter.php index 81b299fe6a441b80069a5fc45c57f9156889d036..9908aac7b2c9e018f22e638ef0dd0d77979a2408 100644 --- a/core/modules/options/src/Plugin/Field/FieldFormatter/OptionsDefaultFormatter.php +++ b/core/modules/options/src/Plugin/Field/FieldFormatter/OptionsDefaultFormatter.php @@ -8,7 +8,7 @@ namespace Drupal\options\Plugin\Field\FieldFormatter; use Drupal\Core\Field\AllowedTagsXssTrait; -use Drupal\Core\Field\FieldFilteredString; +use Drupal\Core\Field\FieldFilteredMarkup; use Drupal\Core\Field\FormatterBase; use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Form\OptGroup; @@ -51,7 +51,7 @@ public function viewElements(FieldItemListInterface $items, $langcode) { $output = isset($options[$value]) ? $options[$value] : $value; $elements[$delta] = array( '#markup' => $output, - '#allowed_tags' => FieldFilteredString::allowedTags(), + '#allowed_tags' => FieldFilteredMarkup::allowedTags(), ); } } diff --git a/core/modules/options/src/Plugin/Field/FieldFormatter/OptionsKeyFormatter.php b/core/modules/options/src/Plugin/Field/FieldFormatter/OptionsKeyFormatter.php index 138d7090fdc0ec48186d83d948aeb547faba0475..586aa882a77f53b8a2e264f7e5d0a63ccdcf1df3 100644 --- a/core/modules/options/src/Plugin/Field/FieldFormatter/OptionsKeyFormatter.php +++ b/core/modules/options/src/Plugin/Field/FieldFormatter/OptionsKeyFormatter.php @@ -8,7 +8,7 @@ namespace Drupal\options\Plugin\Field\FieldFormatter; use Drupal\Core\Field\AllowedTagsXssTrait; -use Drupal\Core\Field\FieldFilteredString; +use Drupal\Core\Field\FieldFilteredMarkup; use Drupal\Core\Field\FormatterBase; use Drupal\Core\Field\FieldItemListInterface; @@ -38,7 +38,7 @@ public function viewElements(FieldItemListInterface $items, $langcode) { foreach ($items as $delta => $item) { $elements[$delta] = array( '#markup' => $item->value, - '#allowed_tags' => FieldFilteredString::allowedTags(), + '#allowed_tags' => FieldFilteredMarkup::allowedTags(), ); } diff --git a/core/modules/options/src/Plugin/views/argument/NumberListField.php b/core/modules/options/src/Plugin/views/argument/NumberListField.php index a96f27ef71f975812de5b2401d548f8464425156..eb75ac31a808ed45c6ce1b9a76f7d5bab1e442a3 100644 --- a/core/modules/options/src/Plugin/views/argument/NumberListField.php +++ b/core/modules/options/src/Plugin/views/argument/NumberListField.php @@ -8,7 +8,7 @@ namespace Drupal\options\Plugin\views\argument; use Drupal\Core\Field\AllowedTagsXssTrait; -use Drupal\Core\Field\FieldFilteredString; +use Drupal\Core\Field\FieldFilteredMarkup; use Drupal\Core\Form\FormStateInterface; use Drupal\views\FieldAPIHandlerTrait; use Drupal\views\ViewExecutable; @@ -80,7 +80,7 @@ public function summaryName($data) { $value = $data->{$this->name_alias}; // If the list element has a human readable name show it. if (isset($this->allowedValues[$value]) && !empty($this->options['summary']['human'])) { - return FieldFilteredString::create($this->allowedValues[$value]); + return FieldFilteredMarkup::create($this->allowedValues[$value]); } // Else, fallback to the key. else { diff --git a/core/modules/options/src/Plugin/views/argument/StringListField.php b/core/modules/options/src/Plugin/views/argument/StringListField.php index ddf764a24a64dbb8f88f87285b34f1722db6cf21..ee26d43b5146e093ab2e1f1095a9c0886bd1e000 100644 --- a/core/modules/options/src/Plugin/views/argument/StringListField.php +++ b/core/modules/options/src/Plugin/views/argument/StringListField.php @@ -8,7 +8,7 @@ namespace Drupal\options\Plugin\views\argument; use Drupal\Core\Field\AllowedTagsXssTrait; -use Drupal\Core\Field\FieldFilteredString; +use Drupal\Core\Field\FieldFilteredMarkup; use Drupal\Core\Form\FormStateInterface; use Drupal\views\FieldAPIHandlerTrait; use Drupal\views\ViewExecutable; @@ -83,7 +83,7 @@ public function summaryName($data) { if (isset($this->allowedValues[$value]) && !empty($this->options['summary']['human'])) { $value = $this->allowedValues[$value]; } - return FieldFilteredString::create($this->caseTransform($value, $this->options['case'])); + return FieldFilteredMarkup::create($this->caseTransform($value, $this->options['case'])); } } diff --git a/core/modules/quickedit/src/QuickEditController.php b/core/modules/quickedit/src/QuickEditController.php index bf0b62d918e452c59803b72d1fd3d19e9f6751f4..ed26a09f8313b72f52a714d77c98a1374fd2e301 100644 --- a/core/modules/quickedit/src/QuickEditController.php +++ b/core/modules/quickedit/src/QuickEditController.php @@ -255,7 +255,7 @@ public function fieldForm(EntityInterface $entity, $field_name, $langcode, $view * The view mode the field should be rerendered in. Either an Entity Display * view mode ID, or a custom one. See hook_quickedit_render_field(). * - * @return \Drupal\Component\Utility\SafeStringInterface + * @return \Drupal\Component\Render\MarkupInterface * Rendered HTML. * * @see hook_quickedit_render_field() diff --git a/core/modules/rest/src/Plugin/views/display/RestExport.php b/core/modules/rest/src/Plugin/views/display/RestExport.php index 2d3a5b0fd77739dd67a79ce2565a3bcfd529ef05..0b0e3c604d7dce5a0607083a473cc5188233f733 100644 --- a/core/modules/rest/src/Plugin/views/display/RestExport.php +++ b/core/modules/rest/src/Plugin/views/display/RestExport.php @@ -14,7 +14,7 @@ use Drupal\Core\Routing\RouteProviderInterface; use Drupal\Core\State\StateInterface; use Drupal\views\Plugin\views\display\ResponseDisplayPluginInterface; -use Drupal\views\Render\ViewsRenderPipelineSafeString; +use Drupal\views\Render\ViewsRenderPipelineMarkup; use Drupal\views\ViewExecutable; use Drupal\views\Plugin\views\display\PathPluginBase; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -335,7 +335,7 @@ public function render() { // executed by an HTML agent. // @todo Decide how to support non-HTML in the render API in // https://www.drupal.org/node/2501313. - $build['#markup'] = ViewsRenderPipelineSafeString::create($build['#markup']); + $build['#markup'] = ViewsRenderPipelineMarkup::create($build['#markup']); } parent::applyDisplayCachablityMetadata($build); diff --git a/core/modules/serialization/serialization.services.yml b/core/modules/serialization/serialization.services.yml index 070a530a29ea8227f4ce4a836ca2b30ec40971f8..0eb4e23627fa83212485a0d48d619ec732b7c59c 100644 --- a/core/modules/serialization/serialization.services.yml +++ b/core/modules/serialization/serialization.services.yml @@ -35,7 +35,7 @@ services: tags: - { name: normalizer, priority: 20 } serializer.normalizer.safe_string: - class: Drupal\serialization\Normalizer\SafeStringNormalizer + class: Drupal\serialization\Normalizer\MarkupNormalizer tags: - { name: normalizer } serializer.normalizer.typed_data: diff --git a/core/modules/serialization/src/Normalizer/SafeStringNormalizer.php b/core/modules/serialization/src/Normalizer/MarkupNormalizer.php similarity index 64% rename from core/modules/serialization/src/Normalizer/SafeStringNormalizer.php rename to core/modules/serialization/src/Normalizer/MarkupNormalizer.php index 16b7fcdd062927bf7727f291641e59d5ee02713d..761ae44d2a196a1f0122a786f6d25312117ad690 100644 --- a/core/modules/serialization/src/Normalizer/SafeStringNormalizer.php +++ b/core/modules/serialization/src/Normalizer/MarkupNormalizer.php @@ -2,22 +2,22 @@ /** * @file - * Contains \Drupal\serialization\Normalizer\SafeStringNormalizer. + * Contains \Drupal\serialization\Normalizer\MarkupNormalizer. */ namespace Drupal\serialization\Normalizer; /** - * Normalizes SafeStringInterface objects into a string. + * Normalizes MarkupInterface objects into a string. */ -class SafeStringNormalizer extends NormalizerBase { +class MarkupNormalizer extends NormalizerBase { /** * The interface or class that this Normalizer supports. * * @var array */ - protected $supportedInterfaceOrClass = array('Drupal\Component\Utility\SafeStringInterface'); + protected $supportedInterfaceOrClass = array('Drupal\Component\Render\MarkupInterface'); /** * {@inheritdoc} diff --git a/core/modules/simpletest/src/AssertContentTrait.php b/core/modules/simpletest/src/AssertContentTrait.php index 9ef0a662bb8d479091555970bca86108944cdae3..3d276875b6ad0806885e922f62c7f99caf8b522a 100644 --- a/core/modules/simpletest/src/AssertContentTrait.php +++ b/core/modules/simpletest/src/AssertContentTrait.php @@ -178,7 +178,7 @@ protected function getUrl() { protected function buildXPathQuery($xpath, array $args = array()) { // Replace placeholders. foreach ($args as $placeholder => $value) { - // Cast SafeStringInterface objects to string. + // Cast MarkupInterface objects to string. if (is_object($value)) { $value = (string) $value; } @@ -285,7 +285,7 @@ protected function getAllOptions(\SimpleXMLElement $element) { * * An optional link index may be passed. * - * @param string|\Drupal\Component\Utility\SafeStringInterface $label + * @param string|\Drupal\Component\Render\MarkupInterface $label * Text between the anchor tags. * @param int $index * Link position counting from zero. @@ -303,7 +303,7 @@ protected function getAllOptions(\SimpleXMLElement $element) { * TRUE if the assertion succeeded, FALSE otherwise. */ protected function assertLink($label, $index = 0, $message = '', $group = 'Other') { - // Cast SafeStringInterface objects to string. + // Cast MarkupInterface objects to string. $label = (string) $label; $links = $this->xpath('//a[normalize-space(text())=:label]', array(':label' => $label)); $message = ($message ? $message : strtr('Link with label %label found.', array('%label' => $label))); @@ -313,7 +313,7 @@ protected function assertLink($label, $index = 0, $message = '', $group = 'Other /** * Passes if a link with the specified label is not found. * - * @param string|\Drupal\Component\Utility\SafeStringInterface $label + * @param string|\Drupal\Component\Render\MarkupInterface $label * Text between the anchor tags. * @param string $message * (optional) A message to display with the assertion. Do not translate @@ -330,7 +330,7 @@ protected function assertLink($label, $index = 0, $message = '', $group = 'Other * TRUE if the assertion succeeded, FALSE otherwise. */ protected function assertNoLink($label, $message = '', $group = 'Other') { - // Cast SafeStringInterface objects to string. + // Cast MarkupInterface objects to string. $label = (string) $label; $links = $this->xpath('//a[normalize-space(text())=:label]', array(':label' => $label)); $message = ($message ? $message : SafeMarkup::format('Link with label %label not found.', array('%label' => $label))); @@ -621,7 +621,7 @@ protected function assertTextHelper($text, $message = '', $group = 'Other', $not * through a web browser. In other words the HTML has been filtered out of * the contents. * - * @param string|\Drupal\Component\Utility\SafeStringInterface $text + * @param string|\Drupal\Component\Render\MarkupInterface $text * Plain text to look for. * @param string $message * (optional) A message to display with the assertion. Do not translate @@ -648,7 +648,7 @@ protected function assertUniqueText($text, $message = '', $group = 'Other') { * through a web browser. In other words the HTML has been filtered out of * the contents. * - * @param string|\Drupal\Component\Utility\SafeStringInterface $text + * @param string|\Drupal\Component\Render\MarkupInterface $text * Plain text to look for. * @param string $message * (optional) A message to display with the assertion. Do not translate @@ -673,7 +673,7 @@ protected function assertNoUniqueText($text, $message = '', $group = 'Other') { * * It is not recommended to call this function directly. * - * @param string|\Drupal\Component\Utility\SafeStringInterface $text + * @param string|\Drupal\Component\Render\MarkupInterface $text * Plain text to look for. * @param string $message * (optional) A message to display with the assertion. Do not translate @@ -693,7 +693,7 @@ protected function assertNoUniqueText($text, $message = '', $group = 'Other') { * TRUE on pass, FALSE on fail. */ protected function assertUniqueTextHelper($text, $message = '', $group = 'Other', $be_unique = FALSE) { - // Cast SafeStringInterface objects to string. + // Cast MarkupInterface objects to string. $text = (string) $text; if (!$message) { $message = '"' . $text . '"' . ($be_unique ? ' found only once' : ' found more than once'); @@ -877,7 +877,7 @@ protected function assertThemeOutput($callback, array $variables = array(), $exp $renderer = \Drupal::service('renderer'); // The string cast is necessary because theme functions return - // SafeStringInterface objects. This means we can assert that $expected + // MarkupInterface objects. This means we can assert that $expected // matches the theme output without having to worry about 0 == ''. $output = (string) $renderer->executeInRenderContext(new RenderContext(), function() use ($callback, $variables) { return \Drupal::theme()->render($callback, $variables); @@ -1116,12 +1116,12 @@ protected function assertNoFieldByName($name, $value = '', $message = '', $group * * @param string $id * ID of field to assert. - * @param string|\Drupal\Component\Utility\SafeStringInterface $value + * @param string|\Drupal\Component\Render\MarkupInterface $value * (optional) Value for the field to assert. You may pass in NULL to skip * checking the value, while still checking that the field exists. * However, the default value ('') asserts that the field value is an empty * string. - * @param string|\Drupal\Component\Utility\SafeStringInterface $message + * @param string|\Drupal\Component\Render\MarkupInterface $message * (optional) A message to display with the assertion. Do not translate * messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed * variables in the message text, not t(). If left blank, a default message @@ -1136,7 +1136,7 @@ protected function assertNoFieldByName($name, $value = '', $message = '', $group * TRUE on pass, FALSE on fail. */ protected function assertFieldById($id, $value = '', $message = '', $group = 'Browser') { - // Cast SafeStringInterface objects to string. + // Cast MarkupInterface objects to string. if (isset($value)) { $value = (string) $value; } diff --git a/core/modules/simpletest/src/AssertHelperTrait.php b/core/modules/simpletest/src/AssertHelperTrait.php index 102b9d9e0da93e92a2573f7d047131c850a71b74..d4770817f16b981b67c30d0f77ca37837612e8a9 100644 --- a/core/modules/simpletest/src/AssertHelperTrait.php +++ b/core/modules/simpletest/src/AssertHelperTrait.php @@ -7,7 +7,7 @@ namespace Drupal\simpletest; -use Drupal\Component\Utility\SafeStringInterface; +use Drupal\Component\Render\MarkupInterface; /** * Provides helper methods for assertions. @@ -15,21 +15,21 @@ trait AssertHelperTrait { /** - * Casts SafeStringInterface objects into strings. + * Casts MarkupInterface objects into strings. * * @param string|array $value * The value to act on. * * @return mixed - * The input value, with SafeStringInterface objects casted to string. + * The input value, with MarkupInterface objects casted to string. */ protected function castSafeStrings($value) { - if ($value instanceof SafeStringInterface) { + if ($value instanceof MarkupInterface) { $value = (string) $value; } if (is_array($value)) { array_walk_recursive($value, function (&$item) { - if ($item instanceof SafeStringInterface) { + if ($item instanceof MarkupInterface) { $item = (string) $item; } }); diff --git a/core/modules/simpletest/src/TestBase.php b/core/modules/simpletest/src/TestBase.php index b94afcf36d7094c4775d0874ca963aad27623fd9..65edaeb792a260fbfb44dbc92946b3b050a581a4 100644 --- a/core/modules/simpletest/src/TestBase.php +++ b/core/modules/simpletest/src/TestBase.php @@ -7,7 +7,7 @@ namespace Drupal\simpletest; -use Drupal\Component\Utility\SafeStringInterface; +use Drupal\Component\Render\MarkupInterface; use Drupal\Component\Utility\Crypt; use Drupal\Component\Utility\Random; use Drupal\Component\Utility\SafeMarkup; @@ -361,7 +361,7 @@ protected function storeAssertion(array $assertion) { * @param $status * Can be 'pass', 'fail', 'exception', 'debug'. * TRUE is a synonym for 'pass', FALSE for 'fail'. - * @param string|\Drupal\Component\Utility\SafeStringInterface $message + * @param string|\Drupal\Component\Render\MarkupInterface $message * (optional) A message to display with the assertion. Do not translate * messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed * variables in the message text, not t(). If left blank, a default message @@ -379,7 +379,7 @@ protected function storeAssertion(array $assertion) { * is the caller function itself. */ protected function assert($status, $message = '', $group = 'Other', array $caller = NULL) { - if ($message instanceof SafeStringInterface) { + if ($message instanceof MarkupInterface) { $message = (string) $message; } // Convert boolean status to string status. @@ -659,7 +659,7 @@ protected function assertNotNull($value, $message = '', $group = 'Other') { * TRUE if the assertion succeeded, FALSE otherwise. */ protected function assertEqual($first, $second, $message = '', $group = 'Other') { - // Cast objects implementing SafeStringInterface to string instead of + // Cast objects implementing MarkupInterface to string instead of // relying on PHP casting them to string depending on what they are being // comparing with. $first = $this->castSafeStrings($first); @@ -694,7 +694,7 @@ protected function assertEqual($first, $second, $message = '', $group = 'Other') * TRUE if the assertion succeeded, FALSE otherwise. */ protected function assertNotEqual($first, $second, $message = '', $group = 'Other') { - // Cast objects implementing SafeStringInterface to string instead of + // Cast objects implementing MarkupInterface to string instead of // relying on PHP casting them to string depending on what they are being // comparing with. $first = $this->castSafeStrings($first); diff --git a/core/modules/simpletest/src/WebTestBase.php b/core/modules/simpletest/src/WebTestBase.php index 2fe6f53f2b76e12f2ec625e87f138b635eeb724d..f5c90cf0b48b241e02e0e1a7badc19a5c9e68d15 100644 --- a/core/modules/simpletest/src/WebTestBase.php +++ b/core/modules/simpletest/src/WebTestBase.php @@ -233,7 +233,7 @@ function __construct($test_id = NULL) { /** * Get a node from the database based on its title. * - * @param string|\Drupal\Component\Utility\SafeStringInterface $title + * @param string|\Drupal\Component\Render\MarkupInterface $title * A node title, usually generated by $this->randomMachineName(). * @param $reset * (optional) Whether to reset the entity cache. @@ -245,7 +245,7 @@ function drupalGetNodeByTitle($title, $reset = FALSE) { if ($reset) { \Drupal::entityManager()->getStorage('node')->resetCache(); } - // Cast SafeStringInterface objects to string. + // Cast MarkupInterface objects to string. $title = (string) $title; $nodes = entity_load_multiple_by_properties('node', array('title' => $title)); // Load the first node returned from the database. @@ -1689,7 +1689,7 @@ protected function drupalGetXHR($path, array $options = array(), array $headers */ protected function drupalPostForm($path, $edit, $submit, array $options = array(), array $headers = array(), $form_html_id = NULL, $extra_post = NULL) { if (is_object($submit)) { - // Cast SafeStringInterface objects to string. + // Cast MarkupInterface objects to string. $submit = (string) $submit; } if (is_array($edit)) { @@ -2413,7 +2413,7 @@ protected function handleForm(&$post, &$edit, &$upload, $submit, $form) { * * If the link is discovered and clicked, the test passes. Fail otherwise. * - * @param string|\Drupal\Component\Utility\SafeStringInterface $label + * @param string|\Drupal\Component\Render\MarkupInterface $label * Text between the anchor tags. * @param int $index * Link position counting from zero. @@ -2431,7 +2431,7 @@ protected function clickLink($label, $index = 0) { * * If the link is discovered and clicked, the test passes. Fail otherwise. * - * @param string|\Drupal\Component\Utility\SafeStringInterface $label + * @param string|\Drupal\Component\Render\MarkupInterface $label * Text between the anchor tags, uses starts-with(). * @param int $index * Link position counting from zero. @@ -2448,7 +2448,7 @@ protected function clickLinkPartialName($label, $index = 0) { /** * Provides a helper for ::clickLink() and ::clickLinkPartialName(). * - * @param string|\Drupal\Component\Utility\SafeStringInterface $label + * @param string|\Drupal\Component\Render\MarkupInterface $label * Text between the anchor tags, uses starts-with(). * @param int $index * Link position counting from zero. @@ -2459,7 +2459,7 @@ protected function clickLinkPartialName($label, $index = 0) { * Page contents on success, or FALSE on failure. */ protected function clickLinkHelper($label, $index, $pattern) { - // Cast SafeStringInterface objects to string. + // Cast MarkupInterface objects to string. $label = (string) $label; $url_before = $this->getUrl(); $urls = $this->xpath($pattern, array(':label' => $label)); @@ -2811,7 +2811,7 @@ protected function assertMail($name, $value = '', $message = '', $group = 'Email protected function assertMailString($field_name, $string, $email_depth, $message = '', $group = 'Other') { $mails = $this->drupalGetMails(); $string_found = FALSE; - // Cast SafeStringInterface objects to string. + // Cast MarkupInterface objects to string. $string = (string) $string; for ($i = count($mails) -1; $i >= count($mails) - $email_depth && $i >= 0; $i--) { $mail = $mails[$i]; diff --git a/core/modules/simpletest/tests/src/Unit/AssertHelperTraitTest.php b/core/modules/simpletest/tests/src/Unit/AssertHelperTraitTest.php index 172474e1b0348e933ace9d7cb34ba0f778d9d7e6..835f5c135168b059791835a87d2907ba505704dc 100644 --- a/core/modules/simpletest/tests/src/Unit/AssertHelperTraitTest.php +++ b/core/modules/simpletest/tests/src/Unit/AssertHelperTraitTest.php @@ -7,7 +7,7 @@ namespace Drupal\Tests\simpletest\Unit; -use Drupal\Core\Render\SafeString; +use Drupal\Core\Render\Markup; use Drupal\simpletest\AssertHelperTrait; use Drupal\Tests\UnitTestCase; @@ -27,7 +27,7 @@ public function testCastSafeStrings($expected, $value) { } public function providerCastSafeStrings() { - $safe_string = SafeString::create('test safe string'); + $safe_string = Markup::create('test safe string'); return [ ['test simple string', 'test simple string'], [['test simple array', 'test simple array'], ['test simple array', 'test simple array']], diff --git a/core/modules/system/src/Tests/Bootstrap/DrupalSetMessageTest.php b/core/modules/system/src/Tests/Bootstrap/DrupalSetMessageTest.php index 1b63324b9ab0b5f42ebce2f6472517c9e31204c4..12ae2aa08fcf4771f718a4fb27dd3c734bbaf074 100644 --- a/core/modules/system/src/Tests/Bootstrap/DrupalSetMessageTest.php +++ b/core/modules/system/src/Tests/Bootstrap/DrupalSetMessageTest.php @@ -37,14 +37,14 @@ function testDrupalSetMessage() { $this->assertUniqueText('Non Duplicated message'); $this->assertNoUniqueText('Duplicated message'); - // Ensure SafeString objects are rendered as expected. - $this->assertRaw('SafeString with markup!'); - $this->assertUniqueText('SafeString with markup!'); + // Ensure Markup objects are rendered as expected. + $this->assertRaw('Markup with markup!'); + $this->assertUniqueText('Markup with markup!'); $this->assertRaw('SafeString2 with markup!'); // Ensure when the same message is of different types it is not duplicated. - $this->assertUniqueText('Non duplicate SafeString / string.'); - $this->assertNoUniqueText('Duplicate SafeString / string.'); + $this->assertUniqueText('Non duplicate Markup / string.'); + $this->assertNoUniqueText('Duplicate Markup / string.'); // Ensure that strings that are not marked as safe are escaped. $this->assertEscaped('Thismarkup will be escaped.'); diff --git a/core/modules/system/src/Tests/Plugin/Discovery/DiscoveryTestBase.php b/core/modules/system/src/Tests/Plugin/Discovery/DiscoveryTestBase.php index a06cb7b034f298f5af26ec78b26e4024252e035b..b6f5cc1549b32c09b76c4bea40ca0f4e9dad2657 100644 --- a/core/modules/system/src/Tests/Plugin/Discovery/DiscoveryTestBase.php +++ b/core/modules/system/src/Tests/Plugin/Discovery/DiscoveryTestBase.php @@ -7,7 +7,7 @@ namespace Drupal\system\Tests\Plugin\Discovery; -use Drupal\Core\StringTranslation\TranslatableString; +use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\simpletest\KernelTestBase; /** @@ -77,7 +77,7 @@ function testDiscoveryInterface() { */ protected function assertDefinitionIdentical(array $definition, array $expected_definition) { $func = function (&$item){ - if ($item instanceof TranslatableString) { + if ($item instanceof TranslatableMarkup) { $item = (string) $item; } }; diff --git a/core/modules/system/src/Tests/System/TokenReplaceUnitTest.php b/core/modules/system/src/Tests/System/TokenReplaceUnitTest.php index c7af02ddf69bd7783e599c797deecf503c350772..f89d1fab9f0c32436d1739c226591d8b46debb06 100644 --- a/core/modules/system/src/Tests/System/TokenReplaceUnitTest.php +++ b/core/modules/system/src/Tests/System/TokenReplaceUnitTest.php @@ -7,7 +7,7 @@ namespace Drupal\system\Tests\System; -use Drupal\Component\Utility\FormattableString; +use Drupal\Component\Render\FormattableMarkup; use Drupal\Component\Utility\Html; use Drupal\Component\Utility\Xss; use Drupal\Core\Render\BubbleableMetadata; @@ -130,7 +130,7 @@ public function testSystemSiteTokenReplacement() { foreach ($tests as $input => $expected) { $bubbleable_metadata = new BubbleableMetadata(); $output = $this->tokenService->replace($input, array(), array('langcode' => $this->interfaceLanguage->getId()), $bubbleable_metadata); - $this->assertEqual($output, $expected, new FormattableString('System site information token %token replaced.', ['%token' => $input])); + $this->assertEqual($output, $expected, new FormattableMarkup('System site information token %token replaced.', ['%token' => $input])); $this->assertEqual($bubbleable_metadata, $metadata_tests[$input]); } } diff --git a/core/modules/system/src/Tests/Theme/ThemeTest.php b/core/modules/system/src/Tests/Theme/ThemeTest.php index 4aafc4f1ec5529b786110e5516a841ebf70a16ed..c47e022c132c3475a735a0801d546e747f45ac12 100644 --- a/core/modules/system/src/Tests/Theme/ThemeTest.php +++ b/core/modules/system/src/Tests/Theme/ThemeTest.php @@ -13,7 +13,7 @@ use Symfony\Cmf\Component\Routing\RouteObjectInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\Route; -use Drupal\Component\Utility\SafeStringInterface; +use Drupal\Component\Render\MarkupInterface; /** * Tests low-level theme functions. @@ -61,13 +61,13 @@ function testAttributeMerging() { */ function testThemeDataTypes() { // theme_test_false is an implemented theme hook so \Drupal::theme() service - // should return a string or an object that implements SafeStringInterface, + // should return a string or an object that implements MarkupInterface, // even though the theme function itself can return anything. $foos = array('null' => NULL, 'false' => FALSE, 'integer' => 1, 'string' => 'foo', 'empty_string' => ''); foreach ($foos as $type => $example) { $output = \Drupal::theme()->render('theme_test_foo', array('foo' => $example)); - $this->assertTrue($output instanceof SafeStringInterface || is_string($output), format_string('\Drupal::theme() returns an object that implements SafeStringInterface or a string for data type @type.', array('@type' => $type))); - if ($output instanceof SafeStringInterface) { + $this->assertTrue($output instanceof MarkupInterface || is_string($output), format_string('\Drupal::theme() returns an object that implements MarkupInterface or a string for data type @type.', array('@type' => $type))); + if ($output instanceof MarkupInterface) { $this->assertIdentical((string) $example, $output->__toString()); } elseif (is_string($output)) { diff --git a/core/modules/system/src/Tests/Update/MenuTreeSerializationTitleTest.php b/core/modules/system/src/Tests/Update/MenuTreeSerializationTitleTest.php index 5aaa7722f31968f99d8b24700b3e1c0666b22220..1b3ad2cc2b11df8b1f831b8db3796bf32fe78c60 100644 --- a/core/modules/system/src/Tests/Update/MenuTreeSerializationTitleTest.php +++ b/core/modules/system/src/Tests/Update/MenuTreeSerializationTitleTest.php @@ -7,7 +7,7 @@ namespace Drupal\system\Tests\Update; -use Drupal\Core\StringTranslation\TranslatableString; +use Drupal\Core\StringTranslation\TranslatableMarkup; /** * Tests system_update_8001(). @@ -54,11 +54,11 @@ public function testUpdate() { $title = unserialize($link->title); $description = unserialize($link->description); // Verify that all the links from system module have a been updated with - // a TranslatableString as title and description due to the rebuild. + // a TranslatableMarkup as title and description due to the rebuild. if (strpos($link->id, 'system.') === 0) { - $this->assertTrue($title instanceof TranslatableString, get_class($title)); + $this->assertTrue($title instanceof TranslatableMarkup, get_class($title)); if ($description) { - $this->assertTrue($description instanceof TranslatableString, get_class($description)); + $this->assertTrue($description instanceof TranslatableMarkup, get_class($description)); } } } diff --git a/core/modules/system/system.install b/core/modules/system/system.install index 6ece8ce7bad85c76e1d18205bc67443e47d44d68..47f6dca3a93045dbd42ac8d0b3f1211c7a2e3316 100644 --- a/core/modules/system/system.install +++ b/core/modules/system/system.install @@ -1236,7 +1236,7 @@ function system_update_8001(&$sandbox = NULL) { $schema->changeField('menu_tree', $name, 'system_update_8001_' . $name, $spec); } $spec = array( - 'description' => 'The title for the link. May be a serialized TranslatableString.', + 'description' => 'The title for the link. May be a serialized TranslatableMarkup.', 'type' => 'blob', 'size' => 'big', 'not null' => FALSE, diff --git a/core/modules/system/system.module b/core/modules/system/system.module index e21c2c8d268bcdc69a21bad0ff83d637d6cc328c..7ec8d0f1bdd34f38bd8ef0f54ea6923d4dbfb6e5 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -5,7 +5,7 @@ * Configuration system that lets administrators modify the workings of the site. */ -use Drupal\Component\Utility\PlainTextOutput; +use Drupal\Component\Render\PlainTextOutput; use Drupal\Component\Utility\UrlHelper; use Drupal\Core\Asset\AttachedAssetsInterface; use Drupal\Core\Cache\Cache; diff --git a/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/FieldTestItem.php b/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/FieldTestItem.php index f248191b6c3f54a17d884c59938089aede6f1025..2a91375872ffdf2f8a26a4376cf56f9aab343fce 100644 --- a/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/FieldTestItem.php +++ b/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/FieldTestItem.php @@ -9,7 +9,7 @@ use Drupal\Core\Field\FieldItemBase; use Drupal\Core\Field\FieldStorageDefinitionInterface; -use Drupal\Core\StringTranslation\TranslatableString; +use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\Core\TypedData\DataDefinition; use Drupal\Core\TypedData\DataDefinitionInterface; use Drupal\Core\TypedData\TypedDataInterface; @@ -39,9 +39,9 @@ class FieldTestItem extends FieldItemBase { */ public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) { // This is called very early by the user entity roles field. Prevent - // early t() calls by using the TranslatableString. + // early t() calls by using the TranslatableMarkup. $properties['value'] = DataDefinition::create('string') - ->setLabel(new TranslatableString('Test value')) + ->setLabel(new TranslatableMarkup('Test value')) ->setRequired(TRUE); return $properties; diff --git a/core/modules/system/tests/modules/plugin_test/src/Plugin/MockBlockManager.php b/core/modules/system/tests/modules/plugin_test/src/Plugin/MockBlockManager.php index ec913f38b5533d97559f8cbd3f04542bc0edddf2..b31a2bffd0851b3a20a0bc2fd7e29cbeaab5f70e 100644 --- a/core/modules/system/tests/modules/plugin_test/src/Plugin/MockBlockManager.php +++ b/core/modules/system/tests/modules/plugin_test/src/Plugin/MockBlockManager.php @@ -133,9 +133,9 @@ public function __construct() { */ protected function createContextDefinition($data_type, $label, $required = TRUE) { // We cast the label to string for testing purposes only, as it may be - // a TranslatableString and we will do assertEqual() checks on arrays that + // a TranslatableMarkup and we will do assertEqual() checks on arrays that // include ContextDefinition objects, and var_export() has problems - // printing TranslatableString objects. + // printing TranslatableMarkup objects. return new ContextDefinition($data_type, (string) $label, $required); } } diff --git a/core/modules/system/tests/modules/system_test/src/Controller/SystemTestController.php b/core/modules/system/tests/modules/system_test/src/Controller/SystemTestController.php index 15ab47814162a1438463cb8927d1192d22f91e25..2b020df220ad9ef46bdf8853d981a5065acfac1b 100644 --- a/core/modules/system/tests/modules/system_test/src/Controller/SystemTestController.php +++ b/core/modules/system/tests/modules/system_test/src/Controller/SystemTestController.php @@ -10,7 +10,7 @@ use Drupal\Core\Access\AccessResult; use Drupal\Core\Controller\ControllerBase; use Drupal\Core\Render\RendererInterface; -use Drupal\Core\Render\SafeString; +use Drupal\Core\Render\Markup; use Drupal\Core\Session\AccountInterface; use Drupal\Core\Url; use Symfony\Component\HttpFoundation\RedirectResponse; @@ -114,18 +114,18 @@ public function drupalSetMessageTest() { drupal_set_message('Duplicated message', 'status', TRUE); drupal_set_message('Duplicated message', 'status', TRUE); - // Add a SafeString message. - drupal_set_message(SafeString::create('SafeString with markup!')); - // Test duplicate SafeString messages. - drupal_set_message(SafeString::create('SafeString with markup!')); - // Ensure that multiple SafeString messages work. - drupal_set_message(SafeString::create('SafeString2 with markup!')); + // Add a Markup message. + drupal_set_message(Markup::create('Markup with markup!')); + // Test duplicate Markup messages. + drupal_set_message(Markup::create('Markup with markup!')); + // Ensure that multiple Markup messages work. + drupal_set_message(Markup::create('SafeString2 with markup!')); // Test mixing of types. - drupal_set_message(SafeString::create('Non duplicate SafeString / string.')); - drupal_set_message('Non duplicate SafeString / string.'); - drupal_set_message(SafeString::create('Duplicate SafeString / string.'), 'status', TRUE); - drupal_set_message('Duplicate SafeString / string.', 'status', TRUE); + drupal_set_message(Markup::create('Non duplicate Markup / string.')); + drupal_set_message('Non duplicate Markup / string.'); + drupal_set_message(Markup::create('Duplicate Markup / string.'), 'status', TRUE); + drupal_set_message('Duplicate Markup / string.', 'status', TRUE); // Test auto-escape of non safe strings. drupal_set_message('Thismarkup will be escaped.'); diff --git a/core/modules/taxonomy/taxonomy.tokens.inc b/core/modules/taxonomy/taxonomy.tokens.inc index aac7acbbf5dc5fc4d4aaf7e672243e6be4d9835f..20251f224c69af7a42d859776160343dc2d6989c 100644 --- a/core/modules/taxonomy/taxonomy.tokens.inc +++ b/core/modules/taxonomy/taxonomy.tokens.inc @@ -110,8 +110,8 @@ function taxonomy_tokens($type, $tokens, array $data, array $options, Bubbleable break; case 'description': - // "processed" returns a \Drupal\Component\Utility\SafeStringInterface - // via check_markup(). + // "processed" returns a \Drupal\Component\Render\MarkupInterface via + // check_markup(). $replacements[$original] = $term->description->processed; break; diff --git a/core/modules/user/src/Tests/UserTokenReplaceTest.php b/core/modules/user/src/Tests/UserTokenReplaceTest.php index fd2f0329ce98bf76b623478bfcc22f3be9fefa98..5a472f453ecd42ffa8a9777afd6352f2b5f6d1a4 100644 --- a/core/modules/user/src/Tests/UserTokenReplaceTest.php +++ b/core/modules/user/src/Tests/UserTokenReplaceTest.php @@ -7,7 +7,7 @@ namespace Drupal\user\Tests; -use Drupal\Component\Utility\FormattableString; +use Drupal\Component\Render\FormattableMarkup; use Drupal\Core\Render\BubbleableMetadata; use Drupal\language\Entity\ConfigurableLanguage; use Drupal\simpletest\WebTestBase; @@ -107,7 +107,7 @@ function testUserTokenReplacement() { foreach ($tests as $input => $expected) { $bubbleable_metadata = new BubbleableMetadata(); $output = $token_service->replace($input, ['user' => $account], ['langcode' => $language_interface->getId()], $bubbleable_metadata); - $this->assertEqual($output, $expected, new FormattableString('User token %token replaced.', ['%token' => $input])); + $this->assertEqual($output, $expected, new FormattableMarkup('User token %token replaced.', ['%token' => $input])); $this->assertEqual($bubbleable_metadata, $metadata_tests[$input]); } @@ -167,6 +167,6 @@ function testUserTokenReplacement() { $input = '[user:display-name] [current-user:display-name]'; $expected = "{$user1->id()} {$user2->id()}"; $output = $token_service->replace($input, ['user' => $user1]); - $this->assertEqual($output, $expected, new FormattableString('User token %token does not escape safe markup.', ['%token' => 'display-name'])); + $this->assertEqual($output, $expected, new FormattableMarkup('User token %token does not escape safe markup.', ['%token' => 'display-name'])); } } diff --git a/core/modules/user/tests/src/Unit/PermissionHandlerTest.php b/core/modules/user/tests/src/Unit/PermissionHandlerTest.php index 1b155e0a716b20550799700d150f36c637aed130..e252b494aaa92b2b49bf1ffbfa1296fb7e001967 100644 --- a/core/modules/user/tests/src/Unit/PermissionHandlerTest.php +++ b/core/modules/user/tests/src/Unit/PermissionHandlerTest.php @@ -8,8 +8,8 @@ namespace Drupal\Tests\user\Unit; use Drupal\Core\Extension\Extension; -use Drupal\Core\StringTranslation\PluralTranslatableString; -use Drupal\Core\StringTranslation\TranslatableString; +use Drupal\Core\StringTranslation\PluralTranslatableMarkup; +use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\Core\StringTranslation\TranslationInterface; use Drupal\Tests\UnitTestCase; use Drupal\user\PermissionHandler; @@ -420,13 +420,13 @@ class TestTranslationManager implements TranslationInterface { * {@inheritdoc} */ public function translate($string, array $args = array(), array $options = array()) { - return new TranslatableString($string, $args, $options, $this); + return new TranslatableMarkup($string, $args, $options, $this); } /** * {@inheritdoc} */ - public function translateString(TranslatableString $translated_string) { + public function translateString(TranslatableMarkup $translated_string) { return $translated_string->getUntranslatedString(); } @@ -434,7 +434,7 @@ public function translateString(TranslatableString $translated_string) { * {@inheritdoc} */ public function formatPlural($count, $singular, $plural, array $args = array(), array $options = array()) { - return new PluralTranslatableString($count, $singular, $plural, $args, $options, $this); + return new PluralTranslatableMarkup($count, $singular, $plural, $args, $options, $this); } } diff --git a/core/modules/user/user.module b/core/modules/user/user.module index a7f752a880a50fc667e4042e759ab28d304c0c93..7782954f183bb84aae4747f2f3a0ddf9417778f0 100644 --- a/core/modules/user/user.module +++ b/core/modules/user/user.module @@ -1,7 +1,7 @@ $plugin_id, 'id' => $id, // Cast the display title to a string since it is an object. - // @see \Drupal\Core\StringTranslation\TranslatableString + // @see \Drupal\Core\StringTranslation\TranslatableMarkup 'display_title' => (string) $title, 'position' => $id === 'default' ? 0 : count($this->display), 'display_options' => array(), diff --git a/core/modules/views/src/Plugin/Derivative/ViewsBlock.php b/core/modules/views/src/Plugin/Derivative/ViewsBlock.php index e3e5165fa0e81b3deca79c2ba86c23b367b2709c..3e02fe88c5ef64fe70b293bec059312999bb0812 100644 --- a/core/modules/views/src/Plugin/Derivative/ViewsBlock.php +++ b/core/modules/views/src/Plugin/Derivative/ViewsBlock.php @@ -9,7 +9,7 @@ use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface; -use Drupal\Core\StringTranslation\TranslatableString; +use Drupal\Core\StringTranslation\TranslatableMarkup; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -98,10 +98,10 @@ public function getDerivativeDefinitions($base_plugin_definition) { } else { // Allow translators to control the punctuation. Plugin - // definitions get cached, so use TranslatableString() instead of + // definitions get cached, so use TranslatableMarkup() instead of // t() to avoid double escaping when $admin_label is rendered // during requests that use the cached definition. - $admin_label = new TranslatableString('@view: @display', ['@view' => $view->label(), '@display' => $display->display['display_title']]); + $admin_label = new TranslatableMarkup('@view: @display', ['@view' => $view->label(), '@display' => $display->display['display_title']]); } } diff --git a/core/modules/views/src/Plugin/views/HandlerBase.php b/core/modules/views/src/Plugin/views/HandlerBase.php index c6ae4b7ae2858a318a4fa8763e24b64f06b560d4..5f9842fd1a1b9ea3246d1bf1a749f6c198fe50fa 100644 --- a/core/modules/views/src/Plugin/views/HandlerBase.php +++ b/core/modules/views/src/Plugin/views/HandlerBase.php @@ -16,7 +16,7 @@ use Drupal\Core\Render\Element; use Drupal\Core\Session\AccountInterface; use Drupal\views\Plugin\views\display\DisplayPluginBase; -use Drupal\views\Render\ViewsRenderPipelineSafeString; +use Drupal\views\Render\ViewsRenderPipelineMarkup; use Drupal\views\ViewExecutable; use Drupal\Core\Database\Database; use Drupal\views\Views; @@ -236,7 +236,7 @@ public function sanitizeValue($value, $type = NULL) { $value = Html::escape($value); break; } - return ViewsRenderPipelineSafeString::create($value); + return ViewsRenderPipelineMarkup::create($value); } /** diff --git a/core/modules/views/src/Plugin/views/PluginBase.php b/core/modules/views/src/Plugin/views/PluginBase.php index 449cc235ba4abc58eb58bd2ac20b8eb524c3154c..cf00382376ef6b34d3a9f9427ebeb7e589e180e7 100644 --- a/core/modules/views/src/Plugin/views/PluginBase.php +++ b/core/modules/views/src/Plugin/views/PluginBase.php @@ -14,7 +14,7 @@ use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Plugin\PluginBase as ComponentPluginBase; use Drupal\Core\Render\Element; -use Drupal\Core\StringTranslation\TranslatableString; +use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\views\Plugin\views\display\DisplayPluginBase; use Drupal\views\ViewExecutable; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -566,7 +566,7 @@ protected function listLanguages($flags = LanguageInterface::STATE_ALL, array $c // The language name may have already been translated, no need to // translate it again. // @see Drupal\Core\Language::filterLanguages(). - if (!$name instanceof TranslatableString) { + if (!$name instanceof TranslatableMarkup) { $name = $this->t($name); } $list[PluginBase::VIEWS_QUERY_LANGUAGE_SITE_DEFAULT] = $name; diff --git a/core/modules/views/src/Plugin/views/ViewsHandlerInterface.php b/core/modules/views/src/Plugin/views/ViewsHandlerInterface.php index 8a230863b98cf524fddf78bddb7ed9ff392283da..ac8aeb2d826c35f34b7486a42ec91b1f4cd71977 100644 --- a/core/modules/views/src/Plugin/views/ViewsHandlerInterface.php +++ b/core/modules/views/src/Plugin/views/ViewsHandlerInterface.php @@ -75,7 +75,7 @@ public function getJoin(); * The type of sanitization needed. If not provided, * \Drupal\Component\Utility\Html::escape() is used. * - * @return \Drupal\views\Render\ViewsRenderPipelineSafeString + * @return \Drupal\views\Render\ViewsRenderPipelineMarkup * Returns the safe value. */ public function sanitizeValue($value, $type = NULL); diff --git a/core/modules/views/src/Plugin/views/argument/FieldList.php b/core/modules/views/src/Plugin/views/argument/FieldList.php index 54b7883d95bd537dfd44e6b2d6855d85c982f517..854fd4dc75c76dd7a6512cf18d63f29e32c27936 100644 --- a/core/modules/views/src/Plugin/views/argument/FieldList.php +++ b/core/modules/views/src/Plugin/views/argument/FieldList.php @@ -8,7 +8,7 @@ namespace Drupal\views\Plugin\views\argument; use Drupal\Core\Field\AllowedTagsXssTrait; -use Drupal\Core\Field\FieldFilteredString; +use Drupal\Core\Field\FieldFilteredMarkup; use Drupal\Core\Form\FormStateInterface; use Drupal\views\ViewExecutable; use Drupal\views\Plugin\views\display\DisplayPluginBase; @@ -70,7 +70,7 @@ public function summaryName($data) { $value = $data->{$this->name_alias}; // If the list element has a human readable name show it, if (isset($this->allowed_values[$value]) && !empty($this->options['summary']['human'])) { - return FieldFilteredString::create($this->allowed_values[$value]); + return FieldFilteredMarkup::create($this->allowed_values[$value]); } // else fallback to the key. else { diff --git a/core/modules/views/src/Plugin/views/argument/ListString.php b/core/modules/views/src/Plugin/views/argument/ListString.php index 5b101322f8965c07d117898c06ee4a73b9549936..775ccdb127a6fc1fa153e9837f933cb06ba5ec58 100644 --- a/core/modules/views/src/Plugin/views/argument/ListString.php +++ b/core/modules/views/src/Plugin/views/argument/ListString.php @@ -9,7 +9,7 @@ use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Field\AllowedTagsXssTrait; -use Drupal\Core\Field\FieldFilteredString; +use Drupal\Core\Field\FieldFilteredMarkup; use Drupal\Core\Form\FormStateInterface; use Drupal\views\ViewExecutable; use Drupal\views\Plugin\views\display\DisplayPluginBase; @@ -75,7 +75,7 @@ public function summaryName($data) { if (isset($this->allowed_values[$value]) && !empty($this->options['summary']['human'])) { $value = $this->allowed_values[$value]; } - return FieldFilteredString::create($this->caseTransform($value, $this->options['case'])); + return FieldFilteredMarkup::create($this->caseTransform($value, $this->options['case'])); } } diff --git a/core/modules/views/src/Plugin/views/field/Boolean.php b/core/modules/views/src/Plugin/views/field/Boolean.php index 3a0740d7a896058070d52b8edcba6dd18d7d142b..b4f14051ee13af1f516db4932bf49ccd4434c608 100644 --- a/core/modules/views/src/Plugin/views/field/Boolean.php +++ b/core/modules/views/src/Plugin/views/field/Boolean.php @@ -9,7 +9,7 @@ use Drupal\Component\Utility\Xss as UtilityXss; use Drupal\Core\Form\FormStateInterface; -use Drupal\views\Render\ViewsRenderPipelineSafeString; +use Drupal\views\Render\ViewsRenderPipelineMarkup; use Drupal\views\ResultRow; use Drupal\views\ViewExecutable; use Drupal\views\Plugin\views\display\DisplayPluginBase; @@ -120,7 +120,7 @@ public function render(ResultRow $values) { if ($this->options['type'] == 'custom') { $custom_value = $value ? $this->options['type_custom_true'] : $this->options['type_custom_false']; - return ViewsRenderPipelineSafeString::create(UtilityXss::filterAdmin($custom_value)); + return ViewsRenderPipelineMarkup::create(UtilityXss::filterAdmin($custom_value)); } elseif (isset($this->formats[$this->options['type']])) { return $value ? $this->formats[$this->options['type']][0] : $this->formats[$this->options['type']][1]; diff --git a/core/modules/views/src/Plugin/views/field/FieldHandlerInterface.php b/core/modules/views/src/Plugin/views/field/FieldHandlerInterface.php index 975c10db058a3ab7d0c0a3bc5d27cd2dc7cc5515..6836c73f14d8dcd1f6058c971df956d5b6654e64 100644 --- a/core/modules/views/src/Plugin/views/field/FieldHandlerInterface.php +++ b/core/modules/views/src/Plugin/views/field/FieldHandlerInterface.php @@ -167,9 +167,9 @@ public function preRender(&$values); * @param \Drupal\views\ResultRow $values * The values retrieved from a single row of a view's query result. * - * @return string|\Drupal\Component\Utility\SafeStringInterface + * @return string|\Drupal\Component\Render\MarkupInterface * The rendered output. If the output is safe it will be wrapped in an - * object that implements SafeStringInterface. If it is empty or unsafe it + * object that implements MarkupInterface. If it is empty or unsafe it * will be a string. * */ @@ -204,9 +204,9 @@ public function postRender(ResultRow $row, $output); * @param \Drupal\views\ResultRow $values * The values retrieved from a single row of a view's query result. * - * @return string|\Drupal\Component\Utility\SafeStringInterface + * @return string|\Drupal\Component\Render\MarkupInterface * The advanced rendered output. If the output is safe it will be wrapped in - * an object that implements SafeStringInterface. If it is empty or unsafe + * an object that implements MarkupInterface. If it is empty or unsafe * it will be a string. * */ @@ -240,9 +240,9 @@ public function isValueEmpty($value, $empty_zero, $no_skip_empty = TRUE); * - ellipsis: Show an ellipsis (…) at the end of the trimmed string. * - html: Make sure that the html is correct. * - * @return string|\Drupal\Component\Utility\SafeStringInterface + * @return string|\Drupal\Component\Render\MarkupInterface * The rendered output. If the output is safe it will be wrapped in an - * object that implements SafeStringInterface. If it is empty or unsafe it + * object that implements MarkupInterface. If it is empty or unsafe it * will be a string. */ public function renderText($alter); @@ -268,10 +268,10 @@ public function getRenderTokens($item); * @param \Drupal\views\ResultRow $values * Holds single row of a view's result set. * - * @return string|\Drupal\Component\Utility\SafeStringInterface + * @return string|\Drupal\Component\Render\MarkupInterface * Returns rendered output of the given theme implementation. If the output * is safe it will be wrapped in an object that implements - * SafeStringInterface. If it is empty or unsafe it will be a string. + * MarkupInterface. If it is empty or unsafe it will be a string. */ function theme(ResultRow $values); diff --git a/core/modules/views/src/Plugin/views/field/FieldPluginBase.php b/core/modules/views/src/Plugin/views/field/FieldPluginBase.php index 23eccf27bfeea81f10a25286cb482b3ed7cb2879..cc2a151781683c61400998716feb24c49deaf2de 100644 --- a/core/modules/views/src/Plugin/views/field/FieldPluginBase.php +++ b/core/modules/views/src/Plugin/views/field/FieldPluginBase.php @@ -10,7 +10,7 @@ use Drupal\Component\Utility\Html; use Drupal\Component\Utility\NestedArray; use Drupal\Component\Utility\SafeMarkup; -use Drupal\Component\Utility\SafeStringInterface; +use Drupal\Component\Render\MarkupInterface; use Drupal\Component\Utility\Unicode; use Drupal\Component\Utility\UrlHelper; use Drupal\Component\Utility\Xss; @@ -20,7 +20,7 @@ use Drupal\Core\Url as CoreUrl; use Drupal\views\Plugin\views\HandlerBase; use Drupal\views\Plugin\views\display\DisplayPluginBase; -use Drupal\views\Render\ViewsRenderPipelineSafeString; +use Drupal\views\Render\ViewsRenderPipelineMarkup; use Drupal\views\ResultRow; use Drupal\views\ViewExecutable; @@ -1177,7 +1177,7 @@ public function advancedRender(ResultRow $values) { $this->last_render = $value; } - // String cast is necessary to test emptiness of SafeStringInterface + // String cast is necessary to test emptiness of MarkupInterface // objects. if (empty((string) $this->last_render)) { if ($this->isValueEmpty($this->last_render, $this->options['empty_zero'], FALSE)) { @@ -1196,8 +1196,8 @@ public function advancedRender(ResultRow $values) { * {@inheritdoc} */ public function isValueEmpty($value, $empty_zero, $no_skip_empty = TRUE) { - // Convert SafeStringInterface to a string for checking. - if ($value instanceof SafeStringInterface) { + // Convert MarkupInterface to a string for checking. + if ($value instanceof MarkupInterface) { $value = (string) $value; } if (!isset($value)) { @@ -1251,7 +1251,7 @@ public function renderText($alter) { // If we got here then $alter contains the value of "No results text" // and so there is nothing left to do. if ($value_is_safe) { - $value = ViewsRenderPipelineSafeString::create($value); + $value = ViewsRenderPipelineMarkup::create($value); } return $value; } @@ -1293,7 +1293,7 @@ public function renderText($alter) { // Preserve whether or not the string is safe. Since $suffix comes from // \Drupal::l(), it is safe to append. if ($value_is_safe) { - $value = ViewsRenderPipelineSafeString::create($value . $suffix); + $value = ViewsRenderPipelineMarkup::create($value . $suffix); } $this->last_render_text = $value; @@ -1308,7 +1308,7 @@ public function renderText($alter) { // \Drupal::l(), it is safe to append. Use SafeMarkup::isSafe() here because // renderAsLink() can return both safe and unsafe values. if (SafeMarkup::isSafe($value)) { - return ViewsRenderPipelineSafeString::create($value . $suffix); + return ViewsRenderPipelineMarkup::create($value . $suffix); } else { // If the string is not already marked safe, it is still OK to return it diff --git a/core/modules/views/src/Plugin/views/field/NumericField.php b/core/modules/views/src/Plugin/views/field/NumericField.php index e558de3b348d104d0106bcd113e2236b1e187500..06f4a66b48d22ece9d33fb9aa44530a183b83a11 100644 --- a/core/modules/views/src/Plugin/views/field/NumericField.php +++ b/core/modules/views/src/Plugin/views/field/NumericField.php @@ -8,7 +8,7 @@ namespace Drupal\views\Plugin\views\field; use Drupal\Core\Form\FormStateInterface; -use Drupal\Core\StringTranslation\PluralTranslatableString; +use Drupal\Core\StringTranslation\PluralTranslatableMarkup; use Drupal\views\ResultRow; /** @@ -175,7 +175,7 @@ public function render(ResultRow $values) { // If we should format as plural, take the (possibly) translated plural // setting and format with the current language. if (!empty($this->options['format_plural'])) { - $value = PluralTranslatableString::createFromTranslatedString($value, $this->options['format_plural_string']); + $value = PluralTranslatableMarkup::createFromTranslatedString($value, $this->options['format_plural_string']); } return $this->sanitizeValue($this->options['prefix'], 'xss') diff --git a/core/modules/views/src/Plugin/views/filter/FilterPluginBase.php b/core/modules/views/src/Plugin/views/filter/FilterPluginBase.php index c60df58f24c30a0cdc6d75043be582610237b6c3..1e401ff0d3cbcfcdfd6a5cffc3c2cc33be5c0cc4 100644 --- a/core/modules/views/src/Plugin/views/filter/FilterPluginBase.php +++ b/core/modules/views/src/Plugin/views/filter/FilterPluginBase.php @@ -1179,7 +1179,7 @@ protected function prepareFilterSelectOptions(&$options) { } else { // Cast the label to a string since it can be an object. - // @see \Drupal\Core\StringTranslation\TranslatableString + // @see \Drupal\Core\StringTranslation\TranslatableMarkup $options[$value] = strip_tags(Html::decodeEntities((string) $label)); } } diff --git a/core/modules/views/src/Plugin/views/relationship/RelationshipPluginBase.php b/core/modules/views/src/Plugin/views/relationship/RelationshipPluginBase.php index 544ba0ed020c5f5ccfcee9772ea1bdb9a04d2824..7ca2cc90f28d345ea6550bc325776e6d36c259a5 100644 --- a/core/modules/views/src/Plugin/views/relationship/RelationshipPluginBase.php +++ b/core/modules/views/src/Plugin/views/relationship/RelationshipPluginBase.php @@ -97,7 +97,7 @@ protected function defineOptions() { // aren't get another default value. if (!empty($this->definition['label'])) { // Cast the label to a string since it is an object. - // @see \Drupal\Core\StringTranslation\TranslatableString + // @see \Drupal\Core\StringTranslation\TranslatableMarkup $label = (string) $this->definition['label']; } else { diff --git a/core/modules/views/src/Plugin/views/style/StylePluginBase.php b/core/modules/views/src/Plugin/views/style/StylePluginBase.php index 75c8bc78ae0773d3c4d293a63fed8bd3325489bb..8614de1be51d3ccb257127d1d165f14e5b7b9fb9 100644 --- a/core/modules/views/src/Plugin/views/style/StylePluginBase.php +++ b/core/modules/views/src/Plugin/views/style/StylePluginBase.php @@ -14,7 +14,7 @@ use Drupal\views\Plugin\views\display\DisplayPluginBase; use Drupal\views\Plugin\views\PluginBase; use Drupal\views\Plugin\views\wizard\WizardInterface; -use Drupal\views\Render\ViewsRenderPipelineSafeString; +use Drupal\views\Render\ViewsRenderPipelineMarkup; use Drupal\views\ViewExecutable; /** @@ -718,7 +718,7 @@ protected function renderFields(array $result) { foreach ($this->rendered_fields[$index] as &$rendered_field) { // Placeholders and rendered fields have been processed by the // render system and are therefore safe. - $rendered_field = ViewsRenderPipelineSafeString::create(str_replace($placeholders, $values, $rendered_field)); + $rendered_field = ViewsRenderPipelineMarkup::create(str_replace($placeholders, $values, $rendered_field)); } } } @@ -755,7 +755,7 @@ public function elementPreRenderRow(array $data) { * @param string $field * The ID of the field. * - * @return \Drupal\Component\Utility\SafeStringInterface|null + * @return \Drupal\Component\Render\MarkupInterface|null * The output of the field, or NULL if it was empty. */ public function getField($index, $field) { diff --git a/core/modules/views/src/Render/ViewsRenderPipelineSafeString.php b/core/modules/views/src/Render/ViewsRenderPipelineMarkup.php similarity index 60% rename from core/modules/views/src/Render/ViewsRenderPipelineSafeString.php rename to core/modules/views/src/Render/ViewsRenderPipelineMarkup.php index f0cbd4bc461e273a2bc8062e9b3a1f03918d37c7..4532b9cddcdc17f3e1325e39b89cb1e26118e558 100644 --- a/core/modules/views/src/Render/ViewsRenderPipelineSafeString.php +++ b/core/modules/views/src/Render/ViewsRenderPipelineMarkup.php @@ -2,13 +2,13 @@ /** * @file - * Contains \Drupal\views\Render\ViewsRenderPipelineSafeString. + * Contains \Drupal\views\Render\ViewsRenderPipelineMarkup. */ namespace Drupal\views\Render; -use Drupal\Component\Utility\SafeStringInterface; -use Drupal\Component\Utility\SafeStringTrait; +use Drupal\Component\Render\MarkupInterface; +use Drupal\Component\Render\MarkupTrait; /** * Defines an object that passes safe strings through the Views render system. @@ -21,8 +21,8 @@ * This object is marked as internal because it should only be used in the * Views render pipeline. * - * @see \Drupal\Core\Render\SafeString + * @see \Drupal\Core\Render\Markup */ -final class ViewsRenderPipelineSafeString implements SafeStringInterface, \Countable { - use SafeStringTrait; +final class ViewsRenderPipelineMarkup implements MarkupInterface, \Countable { + use MarkupTrait; } diff --git a/core/modules/views/src/Tests/FieldApiDataTest.php b/core/modules/views/src/Tests/FieldApiDataTest.php index a4c11422efee5a94a485a9ec2b04b90a41a8654f..d2f3808cc2d79ac1d1da6ee8ba82a27ab952e805 100644 --- a/core/modules/views/src/Tests/FieldApiDataTest.php +++ b/core/modules/views/src/Tests/FieldApiDataTest.php @@ -7,7 +7,7 @@ namespace Drupal\views\Tests; -use Drupal\Component\Utility\SafeStringInterface; +use Drupal\Component\Render\MarkupInterface; use Drupal\field\Entity\FieldConfig; use Drupal\field\Tests\Views\FieldTestBase; @@ -99,10 +99,10 @@ function testViewsData() { // Click sort should only be on the primary field. $this->assertTrue(empty($data[$revision_table][$field_storage->getName()]['field']['click sortable']), 'Non-primary fields are not click sortable'); - $this->assertTrue($data[$current_table][$field_storage->getName()]['help'] instanceof SafeStringInterface); + $this->assertTrue($data[$current_table][$field_storage->getName()]['help'] instanceof MarkupInterface); $this->assertEqual($data[$current_table][$field_storage->getName()]['help'], 'Appears in: page, article. Also known as: Content: The giraffe2" label'); - $this->assertTrue($data[$current_table][$field_storage->getName() . '_value']['help'] instanceof SafeStringInterface); + $this->assertTrue($data[$current_table][$field_storage->getName() . '_value']['help'] instanceof MarkupInterface); $this->assertEqual($data[$current_table][$field_storage->getName() . '_value']['help'], 'Appears in: page, article. Also known as: Content: The giraffe" label (field_name_0)'); } diff --git a/core/modules/views/src/Tests/Plugin/PluginBaseTest.php b/core/modules/views/src/Tests/Plugin/PluginBaseTest.php index c5d69ab310dc6615f338d0a6cf68fbed1b1e1088..0ef1724cfa3b3472dba4be3b71188c058a0224cc 100644 --- a/core/modules/views/src/Tests/Plugin/PluginBaseTest.php +++ b/core/modules/views/src/Tests/Plugin/PluginBaseTest.php @@ -8,7 +8,7 @@ namespace Drupal\views\Tests\Plugin; use Drupal\Core\Render\RenderContext; -use Drupal\Core\Render\SafeString; +use Drupal\Core\Render\Markup; use Drupal\simpletest\KernelTestBase; use Drupal\views\Plugin\views\PluginBase; @@ -34,7 +34,7 @@ public function setUp() { */ public function testViewsTokenReplace() { $text = '{{ langcode__value }} means {{ langcode }}'; - $tokens = ['{{ langcode }}' => SafeString::create('English'), '{{ langcode__value }}' => 'en']; + $tokens = ['{{ langcode }}' => Markup::create('English'), '{{ langcode__value }}' => 'en']; $result = \Drupal::service('renderer')->executeInRenderContext(new RenderContext(), function () use ($text, $tokens) { return $this->testPluginBase->viewsTokenReplace($text, $tokens); diff --git a/core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php b/core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php index 9dfbb06854bf8dca4618ac847f20b0b7cb91f361..015c414a9de975bacacec0536a3b69e661908790 100644 --- a/core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php +++ b/core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php @@ -10,7 +10,7 @@ use Drupal\Core\GeneratedUrl; use Drupal\Core\Language\Language; use Drupal\Core\Render\RendererInterface; -use Drupal\Core\Render\SafeString; +use Drupal\Core\Render\Markup; use Drupal\Core\Url; use Drupal\Core\Utility\LinkGenerator; use Drupal\Core\Utility\LinkGeneratorInterface; @@ -190,7 +190,7 @@ function (&$elements, $is_root_call = FALSE) { if (isset($elements['#suffix'])) { $link = $link . $elements['#suffix']; } - return SafeString::create($link); + return Markup::create($link); } ); } diff --git a/core/modules/views/views.module b/core/modules/views/views.module index 743626bd4fb5c639287cb282172ee90ea54ede9a..dd1d196c90ff13f87422eae704f986ea9ec34344 100644 --- a/core/modules/views/views.module +++ b/core/modules/views/views.module @@ -23,7 +23,7 @@ use Drupal\views\ViewExecutable; use Drupal\Component\Plugin\Exception\PluginException; use Drupal\views\Entity\View; -use Drupal\views\Render\ViewsRenderPipelineSafeString; +use Drupal\views\Render\ViewsRenderPipelineMarkup; use Drupal\views\Views; use Drupal\field\FieldConfigInterface; @@ -638,7 +638,7 @@ function views_pre_render_views_form_views_form($element) { // Apply substitutions to the rendered output. $output = str_replace($search, $replace, drupal_render($element['output'])); - $element['output'] = ['#markup' => ViewsRenderPipelineSafeString::create($output)]; + $element['output'] = ['#markup' => ViewsRenderPipelineMarkup::create($output)]; return $element; } diff --git a/core/modules/views/views.views.inc b/core/modules/views/views.views.inc index 2d4a95df30625e032221ba3ddb0e45bb189d5f89..2216835ad98be23a1503bce6b6744d33bb8a7f7e 100644 --- a/core/modules/views/views.views.inc +++ b/core/modules/views/views.views.inc @@ -8,7 +8,7 @@ use Drupal\Component\Utility\NestedArray; use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Entity\Sql\SqlContentEntityStorage; -use Drupal\Core\Render\SafeString; +use Drupal\Core\Render\Markup; use Drupal\field\FieldConfigInterface; use Drupal\field\FieldStorageConfigInterface; use Drupal\system\ActionConfigEntityInterface; @@ -459,7 +459,7 @@ function views_field_default_views_data(FieldStorageConfigInterface $field_stora // Considering the dual use of this help data (both as metadata and as // help text), other patterns such as use of #markup would not be correct // here. - $data[$table_alias][$field_alias]['help'] = SafeString::create($data[$table_alias][$field_alias]['help'] . ' ' . t('Also known as:') . ' ' . implode(', ', $also_known)); + $data[$table_alias][$field_alias]['help'] = Markup::create($data[$table_alias][$field_alias]['help'] . ' ' . t('Also known as:') . ' ' . implode(', ', $also_known)); } $keys = array_keys($field_columns); @@ -569,7 +569,7 @@ function views_field_default_views_data(FieldStorageConfigInterface $field_stora // Considering the dual use of this help data (both as metadata and as // help text), other patterns such as use of #markup would not be // correct here. - $data[$table_alias][$column_real_name]['help'] = SafeString::create($data[$table_alias][$column_real_name]['help'] . ' ' . t('Also known as:') . ' ' . implode(', ', $also_known)); + $data[$table_alias][$column_real_name]['help'] = Markup::create($data[$table_alias][$column_real_name]['help'] . ' ' . t('Also known as:') . ' ' . implode(', ', $also_known)); } $data[$table_alias][$column_real_name]['argument'] = array( diff --git a/core/modules/views_ui/admin.inc b/core/modules/views_ui/admin.inc index 440ee18251950973fe2ce62fa3a5381f3848b2d3..1187be5e813e71c86c242fe1deeb9c7fe5bd5c43 100644 --- a/core/modules/views_ui/admin.inc +++ b/core/modules/views_ui/admin.inc @@ -93,7 +93,7 @@ function views_ui_add_ajax_trigger(&$wrapping_element, $trigger_key, $refresh_pa // For easiest integration with the form API and the testing framework, we // always give the button a unique #value, rather than playing around with // #name. We also cast the #title to string as we will use it as an array - // key and it may be a TranslatableString. + // key and it may be a TranslatableMarkup. $button_title = !empty($triggering_element['#title']) ? (string) $triggering_element['#title'] : $trigger_key; if (empty($seen_buttons[$button_title])) { $wrapping_element[$button_key]['#value'] = t('Update "@title" choice', array( diff --git a/core/modules/views_ui/src/ViewListBuilder.php b/core/modules/views_ui/src/ViewListBuilder.php index a4a77a6a1aee81bf298327752779e07fa7cd574b..daf96aaa779e9ccfd8490abb38479d32664e6f81 100644 --- a/core/modules/views_ui/src/ViewListBuilder.php +++ b/core/modules/views_ui/src/ViewListBuilder.php @@ -246,7 +246,7 @@ protected function getDisplaysList(EntityInterface $view) { $definition = $this->displayManager->getDefinition($display['display_plugin']); if (!empty($definition['admin'])) { // Cast the admin label to a string since it is an object. - // @see \Drupal\Core\StringTranslation\TranslatableString + // @see \Drupal\Core\StringTranslation\TranslatableMarkup $displays[] = (string) $definition['admin']; } } diff --git a/core/tests/Drupal/KernelTests/Core/Common/DrupalSetMessageTest.php b/core/tests/Drupal/KernelTests/Core/Common/DrupalSetMessageTest.php index 3ef61629274ad404bad2dd80e0b403159e2bbd6a..504675e9e0d2984d650214c615de41188537287e 100644 --- a/core/tests/Drupal/KernelTests/Core/Common/DrupalSetMessageTest.php +++ b/core/tests/Drupal/KernelTests/Core/Common/DrupalSetMessageTest.php @@ -21,7 +21,7 @@ class DrupalSetMessageTest extends KernelTestBase { public function testDrupalSetMessage() { drupal_set_message(t('A message: @foo', ['@foo' => 'bar'])); $messages = drupal_get_messages(); - $this->assertInstanceOf('Drupal\Core\Render\SafeString', $messages['status'][0]); + $this->assertInstanceOf('Drupal\Core\Render\Markup', $messages['status'][0]); $this->assertEquals('A message: bar', (string) $messages['status'][0]); } diff --git a/core/tests/Drupal/KernelTests/Core/StringTranslation/TranslationStringTest.php b/core/tests/Drupal/KernelTests/Core/StringTranslation/TranslationStringTest.php index 012ae7b15c4ae8e71621b90e1b5129af09ded316..5a7126df5977b6770989e8e694aa07596dc46bbb 100644 --- a/core/tests/Drupal/KernelTests/Core/StringTranslation/TranslationStringTest.php +++ b/core/tests/Drupal/KernelTests/Core/StringTranslation/TranslationStringTest.php @@ -12,7 +12,7 @@ use Drupal\language\Entity\ConfigurableLanguage; /** - * Tests the TranslatableString class. + * Tests the TranslatableMarkup class. * * @group StringTranslation */ @@ -36,7 +36,7 @@ protected function setUp() { } /** - * Tests that TranslatableString objects can be compared. + * Tests that TranslatableMarkup objects can be compared. */ public function testComparison() { $this->rebootAndPrepareSettings(); diff --git a/core/tests/Drupal/KernelTests/Core/Theme/ThemeRenderAndAutoescapeTest.php b/core/tests/Drupal/KernelTests/Core/Theme/ThemeRenderAndAutoescapeTest.php index f43ea1331e7b976cef7430cd046296b60ef8ecd9..efd84ff919345ae9f84979565323b6ba3d9767c9 100644 --- a/core/tests/Drupal/KernelTests/Core/Theme/ThemeRenderAndAutoescapeTest.php +++ b/core/tests/Drupal/KernelTests/Core/Theme/ThemeRenderAndAutoescapeTest.php @@ -10,7 +10,7 @@ use Drupal\Component\Utility\Html; use Drupal\Core\Link; use Drupal\Core\Render\RenderContext; -use Drupal\Core\Render\SafeString; +use Drupal\Core\Render\Markup; use Drupal\KernelTests\KernelTestBase; /** @@ -65,8 +65,8 @@ public function providerTestThemeRenderAndAutoescape() { 'int (scalar) cast to string' => [111, '111'], 'float (scalar) cast to string' => [2.10, '2.10'], '> is escaped' => ['>', '>'], - 'SafeString EM tag is unchanged' => [SafeString::create('hi'), 'hi'], - 'SafeString SCRIPT tag is unchanged' => [SafeString::create(''), ''], + 'Markup EM tag is unchanged' => [Markup::create('hi'), 'hi'], + 'Markup SCRIPT tag is unchanged' => [Markup::create(''), ''], 'EM tag in string is escaped' => ['hi', Html::escape('hi')], 'type link render array is rendered' => [['#type' => 'link', '#title' => 'Text', '#url' => ''], 'Text'], 'type markup with EM tags is rendered' => [['#markup' => 'hi'], 'hi'], diff --git a/core/tests/Drupal/Tests/Component/Utility/FormattableStringTest.php b/core/tests/Drupal/Tests/Component/Render/FormattableMarkupTest.php similarity index 61% rename from core/tests/Drupal/Tests/Component/Utility/FormattableStringTest.php rename to core/tests/Drupal/Tests/Component/Render/FormattableMarkupTest.php index 670b6e5cca3dd43b132ef15ee077edf616fb7013..30626fdf53c168ee6ec81d8d78e2c956bbd1c9d7 100644 --- a/core/tests/Drupal/Tests/Component/Utility/FormattableStringTest.php +++ b/core/tests/Drupal/Tests/Component/Render/FormattableMarkupTest.php @@ -2,21 +2,21 @@ /** * @file - * Contains \Drupal\Tests\Component\Utility\FormattableStringTest. + * Contains \Drupal\Tests\Component\Render\FormattableMarkupTest. */ -namespace Drupal\Tests\Component\Utility; +namespace Drupal\Tests\Component\Render; -use Drupal\Component\Utility\FormattableString; +use Drupal\Component\Render\FormattableMarkup; use Drupal\Tests\UnitTestCase; /** - * Tests the TranslatableString class. + * Tests the TranslatableMarkup class. * - * @coversDefaultClass \Drupal\Component\Utility\FormattableString + * @coversDefaultClass \Drupal\Component\Render\FormattableMarkup * @group utility */ -class FormattableStringTest extends UnitTestCase { +class FormattableMarkupTest extends UnitTestCase { /** * @covers ::__toString @@ -24,7 +24,7 @@ class FormattableStringTest extends UnitTestCase { */ public function testToString() { $string = 'Can I please have a @replacement'; - $formattable_string = new FormattableString($string, ['@replacement' => 'kitten']); + $formattable_string = new FormattableMarkup($string, ['@replacement' => 'kitten']); $text = (string) $formattable_string; $this->assertEquals('Can I please have a kitten', $text); $text = $formattable_string->jsonSerialize(); @@ -36,7 +36,7 @@ public function testToString() { */ public function testCount() { $string = 'Can I please have a @replacement'; - $formattable_string = new FormattableString($string, ['@replacement' => 'kitten']); + $formattable_string = new FormattableMarkup($string, ['@replacement' => 'kitten']); $this->assertEquals(strlen($string), $formattable_string->count()); } diff --git a/core/tests/Drupal/Tests/Component/Utility/PlainTextOutputTest.php b/core/tests/Drupal/Tests/Component/Render/PlainTextOutputTest.php similarity index 82% rename from core/tests/Drupal/Tests/Component/Utility/PlainTextOutputTest.php rename to core/tests/Drupal/Tests/Component/Render/PlainTextOutputTest.php index a7038035b553a88cfb6466dff8483e65cb3bdf45..cebdb58c23b56fd55a7adbec3f34469e5d01fa09 100644 --- a/core/tests/Drupal/Tests/Component/Utility/PlainTextOutputTest.php +++ b/core/tests/Drupal/Tests/Component/Render/PlainTextOutputTest.php @@ -2,18 +2,18 @@ /** * @file - * Contains \Drupal\Tests\Component\Utility\PlainTextOutputTest. + * Contains \Drupal\Tests\Component\Render\PlainTextOutputTest. */ -namespace Drupal\Tests\Component\Utility; +namespace Drupal\Tests\Component\Render; -use Drupal\Component\Utility\PlainTextOutput; +use Drupal\Component\Render\PlainTextOutput; use Drupal\Component\Utility\SafeMarkup; -use Drupal\Component\Utility\SafeStringInterface; +use Drupal\Component\Render\MarkupInterface; use Drupal\Tests\UnitTestCase; /** - * @coversDefaultClass \Drupal\Component\Utility\PlainTextOutput + * @coversDefaultClass \Drupal\Component\Render\PlainTextOutput * @group Utility */ class PlainTextOutputTest extends UnitTestCase { @@ -52,12 +52,12 @@ public function providerRenderFromHtml() { $string = 'The <em> tag makes your text look like "this".'; $data['escaped-html-with-quotes'] = [$expected, $string]; - $safe_string = $this->prophesize(SafeStringInterface::class); + $safe_string = $this->prophesize(MarkupInterface::class); $safe_string->__toString()->willReturn('"this"'); $safe_string = $safe_string->reveal(); $data['escaped-html-with-quotes-and-placeholders'] = [$expected, 'The @tag tag makes your text look like @result.', ['@tag' =>'', '@result' => $safe_string]]; - $safe_string = $this->prophesize(SafeStringInterface::class); + $safe_string = $this->prophesize(MarkupInterface::class); $safe_string->__toString()->willReturn($string); $safe_string = $safe_string->reveal(); $data['safe-string'] = [$expected, $safe_string]; diff --git a/core/tests/Drupal/Tests/Component/Utility/SafeMarkupTest.php b/core/tests/Drupal/Tests/Component/Utility/SafeMarkupTest.php index 279bdd49806d685f5a209fa5873d3669f40ae725..2210fa876dd4db898a55d658a99930a193280cca 100644 --- a/core/tests/Drupal/Tests/Component/Utility/SafeMarkupTest.php +++ b/core/tests/Drupal/Tests/Component/Utility/SafeMarkupTest.php @@ -8,8 +8,8 @@ namespace Drupal\Tests\Component\Utility; use Drupal\Component\Utility\SafeMarkup; -use Drupal\Component\Utility\SafeStringInterface; -use Drupal\Component\Utility\SafeStringTrait; +use Drupal\Component\Render\MarkupInterface; +use Drupal\Component\Render\MarkupTrait; use Drupal\Component\Utility\UrlHelper; use Drupal\Tests\UnitTestCase; @@ -115,7 +115,7 @@ public function testSet($text, $message) { * @covers ::isSafe */ public function testIsSafe() { - $safe_string = $this->getMock('\Drupal\Component\Utility\SafeStringInterface'); + $safe_string = $this->getMock('\Drupal\Component\Render\MarkupInterface'); $this->assertTrue(SafeMarkup::isSafe($safe_string)); $string_object = new SafeMarkupTestString('test'); $this->assertFalse(SafeMarkup::isSafe($string_object)); @@ -216,7 +216,7 @@ public function testFormat($string, array $args, $expected, $message, $expected_ $this->assertEquals($expected_is_safe, SafeMarkup::isSafe($result), 'SafeMarkup::format correctly sets the result as safe or not safe.'); foreach ($args as $arg) { - $this->assertSame($arg instanceof SafeMarkupTestSafeString, SafeMarkup::isSafe($arg)); + $this->assertSame($arg instanceof SafeMarkupTestMarkup, SafeMarkup::isSafe($arg)); } } @@ -228,9 +228,9 @@ public function testFormat($string, array $args, $expected, $message, $expected_ function providerFormat() { $tests[] = array('Simple text', array(), 'Simple text', 'SafeMarkup::format leaves simple text alone.', TRUE); $tests[] = array('Escaped text: @value', array('@value' => ''); $data[] = [$safe_string->reveal(), 'teststring', TRUE]; @@ -57,7 +57,7 @@ public function providerTestCreate() { public function testdisplayAllowedTags() { $expected = '
        

    • '; - $this->assertSame($expected, FieldFilteredString::displayAllowedTags()); + $this->assertSame($expected, FieldFilteredMarkup::displayAllowedTags()); } } diff --git a/core/tests/Drupal/Tests/Core/Menu/ContextualLinkDefaultTest.php b/core/tests/Drupal/Tests/Core/Menu/ContextualLinkDefaultTest.php index 6ac118acc2e0ac6a636a29fb427ea3e1d01660a4..7a90abb045545bdbfd0d2f28d916578697785cc4 100644 --- a/core/tests/Drupal/Tests/Core/Menu/ContextualLinkDefaultTest.php +++ b/core/tests/Drupal/Tests/Core/Menu/ContextualLinkDefaultTest.php @@ -8,7 +8,7 @@ namespace Drupal\Tests\Core\Menu; use Drupal\Core\Menu\ContextualLinkDefault; -use Drupal\Core\StringTranslation\TranslatableString; +use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\Tests\UnitTestCase; use Symfony\Component\HttpFoundation\ParameterBag; use Symfony\Component\HttpFoundation\Request; @@ -71,7 +71,7 @@ protected function setupContextualLinkDefault() { */ public function testGetTitle() { $title = 'Example'; - $this->pluginDefinition['title'] = (new TranslatableString($title, [], [], $this->stringTranslation)); + $this->pluginDefinition['title'] = (new TranslatableMarkup($title, [], [], $this->stringTranslation)); $this->stringTranslation->expects($this->once()) ->method('translateString') ->with($this->pluginDefinition['title']) @@ -86,7 +86,7 @@ public function testGetTitle() { */ public function testGetTitleWithContext() { $title = 'Example'; - $this->pluginDefinition['title'] = (new TranslatableString($title, array(), array('context' => 'context'), $this->stringTranslation)); + $this->pluginDefinition['title'] = (new TranslatableMarkup($title, array(), array('context' => 'context'), $this->stringTranslation)); $this->stringTranslation->expects($this->once()) ->method('translateString') ->with($this->pluginDefinition['title']) @@ -101,7 +101,7 @@ public function testGetTitleWithContext() { */ public function testGetTitleWithTitleArguments() { $title = 'Example @test'; - $this->pluginDefinition['title'] = (new TranslatableString($title, array('@test' => 'value'), [], $this->stringTranslation)); + $this->pluginDefinition['title'] = (new TranslatableMarkup($title, array('@test' => 'value'), [], $this->stringTranslation)); $this->stringTranslation->expects($this->once()) ->method('translateString') ->with($this->pluginDefinition['title']) diff --git a/core/tests/Drupal/Tests/Core/Menu/LocalActionDefaultTest.php b/core/tests/Drupal/Tests/Core/Menu/LocalActionDefaultTest.php index 25bf093305f94f644f88783fb17da48d5491771a..1d1c4dd72906c6581d808917d1fb24b69fec30d7 100644 --- a/core/tests/Drupal/Tests/Core/Menu/LocalActionDefaultTest.php +++ b/core/tests/Drupal/Tests/Core/Menu/LocalActionDefaultTest.php @@ -8,7 +8,7 @@ namespace Drupal\Tests\Core\Menu; use Drupal\Core\Menu\LocalActionDefault; -use Drupal\Core\StringTranslation\TranslatableString; +use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\Tests\UnitTestCase; use Symfony\Component\HttpFoundation\ParameterBag; use Symfony\Component\HttpFoundation\Request; @@ -83,7 +83,7 @@ protected function setupLocalActionDefault() { * @see \Drupal\Core\Menu\LocalTaskDefault::getTitle() */ public function testGetTitle() { - $this->pluginDefinition['title'] = (new TranslatableString('Example', [], [], $this->stringTranslation)); + $this->pluginDefinition['title'] = (new TranslatableMarkup('Example', [], [], $this->stringTranslation)); $this->stringTranslation->expects($this->once()) ->method('translateString') ->with($this->pluginDefinition['title']) @@ -99,7 +99,7 @@ public function testGetTitle() { * @see \Drupal\Core\Menu\LocalTaskDefault::getTitle() */ public function testGetTitleWithContext() { - $this->pluginDefinition['title'] = (new TranslatableString('Example', array(), array('context' => 'context'), $this->stringTranslation)); + $this->pluginDefinition['title'] = (new TranslatableMarkup('Example', array(), array('context' => 'context'), $this->stringTranslation)); $this->stringTranslation->expects($this->once()) ->method('translateString') ->with($this->pluginDefinition['title']) @@ -113,7 +113,7 @@ public function testGetTitleWithContext() { * Tests the getTitle method with title arguments. */ public function testGetTitleWithTitleArguments() { - $this->pluginDefinition['title'] = (new TranslatableString('Example @test', array('@test' => 'value'), [], $this->stringTranslation)); + $this->pluginDefinition['title'] = (new TranslatableMarkup('Example @test', array('@test' => 'value'), [], $this->stringTranslation)); $this->stringTranslation->expects($this->once()) ->method('translateString') ->with($this->pluginDefinition['title']) diff --git a/core/tests/Drupal/Tests/Core/Menu/LocalTaskDefaultTest.php b/core/tests/Drupal/Tests/Core/Menu/LocalTaskDefaultTest.php index 51ff248ab2af339a6c1563ebee37308c58827b8b..005add6f6110ea6f496a8276fcd3c03cac8d0f54 100644 --- a/core/tests/Drupal/Tests/Core/Menu/LocalTaskDefaultTest.php +++ b/core/tests/Drupal/Tests/Core/Menu/LocalTaskDefaultTest.php @@ -10,7 +10,7 @@ use Drupal\Core\Menu\LocalTaskDefault; use Drupal\Core\Routing\RouteMatch; use Drupal\Core\Routing\RouteProviderInterface; -use Drupal\Core\StringTranslation\TranslatableString; +use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\Tests\UnitTestCase; use Symfony\Component\Routing\Route; @@ -233,7 +233,7 @@ public function testActive() { * @covers ::getTitle */ public function testGetTitle() { - $this->pluginDefinition['title'] = (new TranslatableString('Example', [], [], $this->stringTranslation)); + $this->pluginDefinition['title'] = (new TranslatableMarkup('Example', [], [], $this->stringTranslation)); $this->stringTranslation->expects($this->once()) ->method('translateString') ->with($this->pluginDefinition['title']) @@ -248,7 +248,7 @@ public function testGetTitle() { */ public function testGetTitleWithContext() { $title = 'Example'; - $this->pluginDefinition['title'] = (new TranslatableString($title, array(), array('context' => 'context'), $this->stringTranslation)); + $this->pluginDefinition['title'] = (new TranslatableMarkup($title, array(), array('context' => 'context'), $this->stringTranslation)); $this->stringTranslation->expects($this->once()) ->method('translateString') ->with($this->pluginDefinition['title']) @@ -262,7 +262,7 @@ public function testGetTitleWithContext() { * @covers ::getTitle */ public function testGetTitleWithTitleArguments() { - $this->pluginDefinition['title'] = (new TranslatableString('Example @test', array('@test' => 'value'), [], $this->stringTranslation)); + $this->pluginDefinition['title'] = (new TranslatableMarkup('Example @test', array('@test' => 'value'), [], $this->stringTranslation)); $this->stringTranslation->expects($this->once()) ->method('translateString') ->with($this->pluginDefinition['title']) diff --git a/core/tests/Drupal/Tests/Core/Plugin/Discovery/YamlDiscoveryTest.php b/core/tests/Drupal/Tests/Core/Plugin/Discovery/YamlDiscoveryTest.php index 32144f3df733cb497e9a9243f222b123f5821f80..0dd3ab38fbf50122e5d4ad1bd4d0086f1d873f36 100644 --- a/core/tests/Drupal/Tests/Core/Plugin/Discovery/YamlDiscoveryTest.php +++ b/core/tests/Drupal/Tests/Core/Plugin/Discovery/YamlDiscoveryTest.php @@ -7,7 +7,7 @@ namespace Drupal\Tests\Core\Plugin\Discovery; -use Drupal\Core\StringTranslation\TranslatableString; +use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\Tests\UnitTestCase; use Drupal\Core\Plugin\Discovery\YamlDiscovery; use org\bovigo\vfs\vfsStream; @@ -104,9 +104,9 @@ public function testGetDefinitionsWithTranslatableDefinitions() { $plugin_1 = $definitions['test_plugin']; $plugin_2 = $definitions['test_plugin2']; - $this->assertInstanceOf(TranslatableString::class, $plugin_1['title']); + $this->assertInstanceOf(TranslatableMarkup::class, $plugin_1['title']); $this->assertEquals([], $plugin_1['title']->getOptions()); - $this->assertInstanceOf(TranslatableString::class, $plugin_2['title']); + $this->assertInstanceOf(TranslatableMarkup::class, $plugin_2['title']); $this->assertEquals(['context' => 'test-context'], $plugin_2['title']->getOptions()); } diff --git a/core/tests/Drupal/Tests/Core/Render/Element/HtmlTagTest.php b/core/tests/Drupal/Tests/Core/Render/Element/HtmlTagTest.php index a83b825b987a2c1bf88340a29fe1f036c665cb11..fdd4e28ff4993a01bf449ebd087dce583f117869 100644 --- a/core/tests/Drupal/Tests/Core/Render/Element/HtmlTagTest.php +++ b/core/tests/Drupal/Tests/Core/Render/Element/HtmlTagTest.php @@ -7,7 +7,7 @@ namespace Drupal\Tests\Core\Render\Element; -use Drupal\Core\Render\SafeString; +use Drupal\Core\Render\Markup; use Drupal\Tests\UnitTestCase; use Drupal\Core\Render\Element\HtmlTag; @@ -86,7 +86,7 @@ public function providerPreRenderHtmlTag() { // Ensure that #value is not filtered if it is marked as safe. $element = array( '#tag' => 'p', - '#value' => SafeString::create(''), + '#value' => Markup::create(''), ); $tags[] = array($element, "

      \n"); @@ -106,8 +106,8 @@ public function providerPreRenderHtmlTag() { */ public function testPreRenderConditionalComments($element, $expected, $set_safe = FALSE) { if ($set_safe) { - $element['#prefix'] = SafeString::create($element['#prefix']); - $element['#suffix'] = SafeString::create($element['#suffix']); + $element['#prefix'] = Markup::create($element['#prefix']); + $element['#suffix'] = Markup::create($element['#suffix']); } $this->assertEquals($expected, HtmlTag::preRenderConditionalComments($element)); } diff --git a/core/tests/Drupal/Tests/Core/Render/Element/TableSelectTest.php b/core/tests/Drupal/Tests/Core/Render/Element/TableSelectTest.php index 4f3e9c938aab8749e5c73b0f247274cd061fed0e..649a57f9d7ab1d8e86878133636a4dfd8fd3e6d3 100644 --- a/core/tests/Drupal/Tests/Core/Render/Element/TableSelectTest.php +++ b/core/tests/Drupal/Tests/Core/Render/Element/TableSelectTest.php @@ -10,7 +10,7 @@ use Drupal\Core\Form\FormState; use Drupal\Core\Link; use Drupal\Core\Render\Element\Tableselect; -use Drupal\Core\StringTranslation\TranslatableString; +use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\Core\StringTranslation\TranslationWrapper; use Drupal\Core\Url; use Drupal\Tests\UnitTestCase; @@ -68,7 +68,7 @@ public function testProcessTableselectWithStringTitle() { Tableselect::processTableselect($element, $form_state, $complete_form); - $this->assertEquals(new TranslatableString('Update @title', ['@title' => 'Static title']), $element[0]['#title']); + $this->assertEquals(new TranslatableMarkup('Update @title', ['@title' => 'Static title']), $element[0]['#title']); } } diff --git a/core/tests/Drupal/Tests/Core/Render/RendererPlaceholdersTest.php b/core/tests/Drupal/Tests/Core/Render/RendererPlaceholdersTest.php index e2bc876962bdd3d32111783e4c436cc890a1ddc3..d32ba5ad1f2272590e5e3916936251195af53b6a 100644 --- a/core/tests/Drupal/Tests/Core/Render/RendererPlaceholdersTest.php +++ b/core/tests/Drupal/Tests/Core/Render/RendererPlaceholdersTest.php @@ -10,7 +10,7 @@ use Drupal\Component\Utility\Html; use Drupal\Core\Render\Element; use Drupal\Core\Cache\Cache; -use Drupal\Core\Render\SafeString; +use Drupal\Core\Render\Markup; /** * @coversDefaultClass \Drupal\Core\Render\Renderer @@ -70,10 +70,10 @@ public function providerPlaceholders() { $token_render_array['#cache']['keys'] = $cache_keys; } $token = hash('crc32b', serialize($token_render_array)); - // \Drupal\Core\Render\SafeString::create() is necessary as the render + // \Drupal\Core\Render\Markup::create() is necessary as the render // system would mangle this markup. As this is exactly what happens at // runtime this is a valid use-case. - return SafeString::create(''); + return Markup::create(''); }; $extract_placeholder_render_array = function ($placeholder_render_array) { @@ -852,7 +852,7 @@ public function testScalarLazybuilderCallbackContext() { ]]; $result = $this->renderer->renderRoot($element); - $this->assertInstanceOf('\Drupal\Core\Render\SafeString', $result); + $this->assertInstanceOf('\Drupal\Core\Render\Markup', $result); $this->assertEquals('

      This is a rendered placeholder!

      ', (string) $result); } diff --git a/core/tests/Drupal/Tests/Core/Render/RendererTest.php b/core/tests/Drupal/Tests/Core/Render/RendererTest.php index 4d0dec5f2f8eb2f91593736e5e677467a65db4cd..673b78d9d47b631092bbc4b051bc26ddaab68ca1 100644 --- a/core/tests/Drupal/Tests/Core/Render/RendererTest.php +++ b/core/tests/Drupal/Tests/Core/Render/RendererTest.php @@ -13,7 +13,7 @@ use Drupal\Core\Cache\Cache; use Drupal\Core\Cache\CacheableDependencyInterface; use Drupal\Core\Render\Element; -use Drupal\Core\Render\SafeString; +use Drupal\Core\Render\Markup; use Drupal\Core\Template\Attribute; /** @@ -111,7 +111,7 @@ public function providerTestRenderBasic() { ], '<em>foo</em>']; // Safe strings in #plain_text are are still escaped. $data[] = [[ - '#plain_text' => SafeString::create('foo'), + '#plain_text' => Markup::create('foo'), ], '<em>foo</em>']; // Renderable child element. $data[] = [[ @@ -737,10 +737,10 @@ public function testRenderCacheProperties(array $expected_results) { ], // Collect expected property names. '#cache_properties' => array_keys(array_filter($expected_results)), - 'child1' => ['#markup' => SafeString::create('1')], - 'child2' => ['#markup' => SafeString::create('2')], + 'child1' => ['#markup' => Markup::create('1')], + 'child2' => ['#markup' => Markup::create('2')], // Mark the value as safe. - '#custom_property' => SafeString::create('custom_value'), + '#custom_property' => Markup::create('custom_value'), '#custom_property_array' => ['custom value'], ]; diff --git a/core/tests/Drupal/Tests/Core/StringTranslation/TranslatableStringTest.php b/core/tests/Drupal/Tests/Core/StringTranslation/TranslatableMarkupTest.php similarity index 83% rename from core/tests/Drupal/Tests/Core/StringTranslation/TranslatableStringTest.php rename to core/tests/Drupal/Tests/Core/StringTranslation/TranslatableMarkupTest.php index 862a78a7b9fddbf574fce01121cc46e48e6cb117..0b243ccd5e4871ac89575e789c2ea6f10668e88e 100644 --- a/core/tests/Drupal/Tests/Core/StringTranslation/TranslatableStringTest.php +++ b/core/tests/Drupal/Tests/Core/StringTranslation/TranslatableMarkupTest.php @@ -2,22 +2,22 @@ /** * @file - * Contains \Drupal\Tests\Core\StringTranslation\TranslatableStringTest. + * Contains \Drupal\Tests\Core\StringTranslation\TranslatableMarkupTest. */ namespace Drupal\Tests\Core\StringTranslation; use Drupal\Core\StringTranslation\TranslationInterface; -use Drupal\Core\StringTranslation\TranslatableString; +use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\Tests\UnitTestCase; /** - * Tests the TranslatableString class. + * Tests the TranslatableMarkup class. * - * @coversDefaultClass \Drupal\Core\StringTranslation\TranslatableString + * @coversDefaultClass \Drupal\Core\StringTranslation\TranslatableMarkup * @group StringTranslation */ -class TranslatableStringTest extends UnitTestCase { +class TranslatableMarkupTest extends UnitTestCase { /** * The error message of the last error in the error handler. @@ -59,7 +59,7 @@ public function testToString() { $translation = $this->getMock(TranslationInterface::class); $string = 'May I have an exception please?'; - $text = $this->getMockBuilder(TranslatableString::class) + $text = $this->getMockBuilder(TranslatableMarkup::class) ->setConstructorArgs([$string, [], [], $translation]) ->setMethods(['_die']) ->getMock(); @@ -82,7 +82,7 @@ public function testToString() { restore_error_handler(); $this->assertEquals(E_USER_ERROR, $this->lastErrorNumber); - $this->assertRegExp('/Exception thrown while calling __toString on a .*Mock_TranslatableString_.* object in .*TranslatableStringTest.php on line [0-9]+: Yes you may./', $this->lastErrorMessage); + $this->assertRegExp('/Exception thrown while calling __toString on a .*Mock_TranslatableMarkup_.* object in .*TranslatableMarkupTest.php on line [0-9]+: Yes you may./', $this->lastErrorMessage); } } diff --git a/core/tests/Drupal/Tests/Core/StringTranslation/TranslationManagerTest.php b/core/tests/Drupal/Tests/Core/StringTranslation/TranslationManagerTest.php index 730437b560af5becf86dfbdd4fffea554bef1ef4..305963daaa912539ae0e7035a06fc03dd98b6cea 100644 --- a/core/tests/Drupal/Tests/Core/StringTranslation/TranslationManagerTest.php +++ b/core/tests/Drupal/Tests/Core/StringTranslation/TranslationManagerTest.php @@ -8,7 +8,7 @@ namespace Drupal\Tests\Core\StringTranslation; use Drupal\Component\Utility\SafeMarkup; -use Drupal\Component\Utility\SafeStringInterface; +use Drupal\Component\Render\MarkupInterface; use Drupal\Core\StringTranslation\TranslationManager; use Drupal\Tests\UnitTestCase; @@ -76,7 +76,7 @@ public function testFormatPlural($count, $singular, $plural, array $args = array */ public function testTranslatePlaceholder($string, array $args = array(), $expected_string) { $actual = $this->translationManager->translate($string, $args); - $this->assertInstanceOf(SafeStringInterface::class, $actual); + $this->assertInstanceOf(MarkupInterface::class, $actual); $this->assertEquals($expected_string, (string) $actual); } diff --git a/core/tests/Drupal/Tests/Core/Template/AttributeTest.php b/core/tests/Drupal/Tests/Core/Template/AttributeTest.php index fba778614e8d47d45115193d8b0d9e273d06f2ab..69941a95bed765316f40e9d4efbee8781d00d5f9 100644 --- a/core/tests/Drupal/Tests/Core/Template/AttributeTest.php +++ b/core/tests/Drupal/Tests/Core/Template/AttributeTest.php @@ -8,12 +8,12 @@ namespace Drupal\Tests\Core\Template; use Drupal\Component\Utility\Html; -use Drupal\Core\Render\SafeString; +use Drupal\Core\Render\Markup; use Drupal\Core\Template\Attribute; use Drupal\Core\Template\AttributeArray; use Drupal\Core\Template\AttributeString; use Drupal\Tests\UnitTestCase; -use Drupal\Component\Utility\SafeStringInterface; +use Drupal\Component\Render\MarkupInterface; /** * @coversDefaultClass \Drupal\Core\Template\Attribute @@ -40,7 +40,7 @@ public function testConstructor() { $this->assertEquals(new AttributeArray('class', array('example-class')), $attribute['class']); // Test that safe string objects work correctly. - $safe_string = $this->prophesize(SafeStringInterface::class); + $safe_string = $this->prophesize(MarkupInterface::class); $safe_string->__toString()->willReturn('example-class'); $attribute = new Attribute(array('class' => $safe_string->reveal())); $this->assertTrue(isset($attribute['class'])); @@ -367,10 +367,10 @@ public function providerTestAttributeValues() { $data = []; $string = '"> "'; - $data['safe-object-xss1'] = [['title' => SafeString::create($string)], ' title=""> alert(123)""']; + $data['safe-object-xss1'] = [['title' => Markup::create($string)], ' title=""> alert(123)""']; $data['non-safe-object-xss1'] = [['title' => $string], ' title="' . Html::escape($string) . '"']; $string = '">'; - $data['safe-object-xss2'] = [['title' => SafeString::create($string)], ' title="">alert(123)"']; + $data['safe-object-xss2'] = [['title' => Markup::create($string)], ' title="">alert(123)"']; $data['non-safe-object-xss2'] = [['title' => $string], ' title="' . Html::escape($string) . '"']; return $data; diff --git a/core/tests/Drupal/Tests/Core/Template/TwigExtensionTest.php b/core/tests/Drupal/Tests/Core/Template/TwigExtensionTest.php index d01641b448752687405b578a53900b82ecede8ca..13f46394fc13dc07cead38311c84db6a784bb86c 100644 --- a/core/tests/Drupal/Tests/Core/Template/TwigExtensionTest.php +++ b/core/tests/Drupal/Tests/Core/Template/TwigExtensionTest.php @@ -126,7 +126,7 @@ public function testFormatDate() { } /** - * Tests the escaping of objects implementing SafeStringInterface. + * Tests the escaping of objects implementing MarkupInterface. * * @covers ::escapeFilter */ @@ -141,11 +141,11 @@ public function testSafeStringEscaping() { $twig_extension = new TwigExtension($renderer); // By default, TwigExtension will attempt to cast objects to strings. - // Ensure objects that implement SafeStringInterface are unchanged. - $safe_string = $this->getMock('\Drupal\Component\Utility\SafeStringInterface'); + // Ensure objects that implement MarkupInterface are unchanged. + $safe_string = $this->getMock('\Drupal\Component\Render\MarkupInterface'); $this->assertSame($safe_string, $twig_extension->escapeFilter($twig, $safe_string, 'html', 'UTF-8', TRUE)); - // Ensure objects that do not implement SafeStringInterface are escaped. + // Ensure objects that do not implement MarkupInterface are escaped. $string_object = new TwigExtensionTestString(""); $this->assertSame('<script>alert('here');</script>', $twig_extension->escapeFilter($twig, $string_object, 'html', 'UTF-8', TRUE)); } diff --git a/core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php b/core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php index 05f1af1deb15d2eb616e44a30b4ff037aa05c24f..e2ffb807d0c33d2685bb050ffafa8246c9738352 100644 --- a/core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php +++ b/core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php @@ -7,11 +7,11 @@ namespace Drupal\Tests\Core\Utility { -use Drupal\Component\Utility\SafeStringInterface; +use Drupal\Component\Render\MarkupInterface; use Drupal\Core\GeneratedUrl; use Drupal\Core\Language\Language; use Drupal\Core\Link; -use Drupal\Core\Render\SafeString; +use Drupal\Core\Render\Markup; use Drupal\Core\Url; use Drupal\Core\Utility\LinkGenerator; use Drupal\Tests\UnitTestCase; @@ -357,11 +357,11 @@ public function testGenerateWithHtml() { ), $result); // Test that safe HTML is output inside the anchor tag unescaped. The - // SafeString::create() call is an intentional unit test for the interaction - // between SafeStringInterface and the LinkGenerator. + // Markup::create() call is an intentional unit test for the interaction + // between MarkupInterface and the LinkGenerator. $url = new Url('test_route_5', array()); $url->setUrlGenerator($this->urlGenerator); - $result = $this->linkGenerator->generate(SafeString::create('HTML output'), $url); + $result = $this->linkGenerator->generate(Markup::create('HTML output'), $url); $this->assertLink(array( 'attributes' => array('href' => '/test-route-5'), 'child' => array( @@ -499,12 +499,12 @@ public function testGenerateBubbleableMetadata() { * An associative array of link properties, with the following keys: * - attributes: optional array of HTML attributes that should be present. * - content: optional link content. - * @param \Drupal\Component\Utility\SafeStringInterface $html + * @param \Drupal\Component\Render\MarkupInterface $html * The HTML to check. * @param int $count * How many times the link should be present in the HTML. Defaults to 1. */ - public static function assertLink(array $properties, SafeStringInterface $html, $count = 1) { + public static function assertLink(array $properties, MarkupInterface $html, $count = 1) { // Provide default values. $properties += array('attributes' => array()); diff --git a/core/tests/Drupal/Tests/Core/Utility/TokenTest.php b/core/tests/Drupal/Tests/Core/Utility/TokenTest.php index e9021341193962488671627e4775dde0aa2b9255..60e378f644c7bdadbbaa72212d0831b25362c096 100644 --- a/core/tests/Drupal/Tests/Core/Utility/TokenTest.php +++ b/core/tests/Drupal/Tests/Core/Utility/TokenTest.php @@ -12,7 +12,7 @@ use Drupal\Core\DependencyInjection\ContainerBuilder; use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Render\BubbleableMetadata; -use Drupal\Core\Render\SafeString; +use Drupal\Core\Render\Markup; use Drupal\Core\Utility\Token; use Drupal\Tests\UnitTestCase; @@ -292,7 +292,7 @@ public function providerTestReplaceEscaping() { $data['simple-placeholder-with-safe-html'] = [ '

      [token:meh]

      ', - ['[token:meh]' => SafeString::create('Emphasized')], + ['[token:meh]' => Markup::create('Emphasized')], '

      Emphasized

      ', ]; diff --git a/core/tests/Drupal/Tests/Core/Validation/Plugin/Validation/Constraint/PrimitiveTypeConstraintValidatorTest.php b/core/tests/Drupal/Tests/Core/Validation/Plugin/Validation/Constraint/PrimitiveTypeConstraintValidatorTest.php index 1183a2bc1235ed1dc813f281d69d3dfb68c436c5..34df3eff71b3231d6c92078602e8acfbb58b7407 100644 --- a/core/tests/Drupal/Tests/Core/Validation/Plugin/Validation/Constraint/PrimitiveTypeConstraintValidatorTest.php +++ b/core/tests/Drupal/Tests/Core/Validation/Plugin/Validation/Constraint/PrimitiveTypeConstraintValidatorTest.php @@ -16,7 +16,7 @@ use Drupal\Core\TypedData\PrimitiveInterface; use Drupal\Core\Validation\Plugin\Validation\Constraint\PrimitiveTypeConstraint; use Drupal\Core\Validation\Plugin\Validation\Constraint\PrimitiveTypeConstraintValidator; -use Drupal\Core\StringTranslation\TranslatableString; +use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\Tests\UnitTestCase; /** @@ -64,7 +64,7 @@ public function provideTestValidate() { $data[] = [new IntegerData(DataDefinition::create('integer')), 1.5, FALSE]; $data[] = [new IntegerData(DataDefinition::create('integer')), 'test', FALSE]; $data[] = [new StringData(DataDefinition::create('string')), 'test', TRUE]; - $data[] = [new StringData(DataDefinition::create('string')), new TranslatableString('test'), TRUE]; + $data[] = [new StringData(DataDefinition::create('string')), new TranslatableMarkup('test'), TRUE]; // It is odd that 1 is a valid string. // $data[] = [$this->getMock('Drupal\Core\TypedData\Type\StringInterface'), 1, FALSE]; $data[] = [new StringData(DataDefinition::create('string')), [], FALSE]; diff --git a/core/tests/Drupal/Tests/UnitTestCase.php b/core/tests/Drupal/Tests/UnitTestCase.php index 63098bb4aa52c4332143c6320179f33bccd21a44..64b631776bb96563a32a9820d8aa311e6a5f8cb5 100644 --- a/core/tests/Drupal/Tests/UnitTestCase.php +++ b/core/tests/Drupal/Tests/UnitTestCase.php @@ -12,8 +12,8 @@ use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Cache\CacheTagsInvalidatorInterface; use Drupal\Core\DependencyInjection\ContainerBuilder; -use Drupal\Core\StringTranslation\TranslatableString; -use Drupal\Core\StringTranslation\PluralTranslatableString; +use Drupal\Core\StringTranslation\TranslatableMarkup; +use Drupal\Core\StringTranslation\PluralTranslatableMarkup; /** @@ -218,17 +218,17 @@ public function getStringTranslationStub() { $translation->expects($this->any()) ->method('translate') ->willReturnCallback(function ($string, array $args = array(), array $options = array()) use ($translation) { - return new TranslatableString($string, $args, $options, $translation); + return new TranslatableMarkup($string, $args, $options, $translation); }); $translation->expects($this->any()) ->method('translateString') - ->willReturnCallback(function (TranslatableString $wrapper) { + ->willReturnCallback(function (TranslatableMarkup $wrapper) { return $wrapper->getUntranslatedString(); }); $translation->expects($this->any()) ->method('formatPlural') ->willReturnCallback(function ($count, $singular, $plural, array $args = [], array $options = []) use ($translation) { - $wrapper = new PluralTranslatableString($count, $singular, $plural, $args, $options, $translation); + $wrapper = new PluralTranslatableMarkup($count, $singular, $plural, $args, $options, $translation); return $wrapper; }); return $translation; diff --git a/core/themes/engines/twig/twig.engine b/core/themes/engines/twig/twig.engine index 977f09446d934138f0189ac4da113f98b52aad3f..44ee5ac6bfb609daf304991c6d4b0fdc5ac7a62e 100644 --- a/core/themes/engines/twig/twig.engine +++ b/core/themes/engines/twig/twig.engine @@ -7,7 +7,7 @@ use Drupal\Component\Utility\Html; use Drupal\Component\Utility\SafeMarkup; -use Drupal\Core\Render\SafeString; +use Drupal\Core\Render\Markup; use Drupal\Core\Extension\Extension; /** @@ -46,7 +46,7 @@ function twig_init(Extension $theme) { * @param array $variables * A keyed array of variables that will appear in the output. * - * @return string|\Drupal\Component\Utility\SafeStringInterface + * @return string|\Drupal\Component\Render\MarkupInterface * The output generated by the template, plus any debug information. */ function twig_render_template($template_file, array $variables) { @@ -116,7 +116,7 @@ function twig_render_template($template_file, array $variables) { $output['debug_suffix'] .= "\n\n\n"; } // This output has already been rendered and is therefore considered safe. - return SafeString::create(implode('', $output)); + return Markup::create(implode('', $output)); } /**