summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoreffulgentsia2015-10-01 23:25:03 (GMT)
committereffulgentsia2015-10-01 23:25:03 (GMT)
commit708ce0a998fc3f315b66ce629cc021944c2218de (patch)
tree8d4f33249e945e078b7392e2511dc8830356546b
parent03bd7fc75b824e3eceeb7172d8d79a42d9389b2b (diff)
Issue #2576533 by alexpott, stefan.r, Wim Leers, dawehner, xjm, effulgentsia, catch: Rename SafeStringInterface to MarkupInterface and move related classes
-rw-r--r--core/includes/bootstrap.inc12
-rw-r--r--core/includes/common.inc32
-rw-r--r--core/includes/errors.inc4
-rw-r--r--core/includes/theme.inc8
-rw-r--r--core/lib/Drupal/Component/Render/FormattableMarkup.php (renamed from core/lib/Drupal/Component/Utility/FormattableString.php)53
-rw-r--r--core/lib/Drupal/Component/Render/MarkupInterface.php45
-rw-r--r--core/lib/Drupal/Component/Render/MarkupTrait.php (renamed from core/lib/Drupal/Component/Utility/SafeStringTrait.php)24
-rw-r--r--core/lib/Drupal/Component/Render/OutputStrategyInterface.php (renamed from core/lib/Drupal/Component/Utility/OutputStrategyInterface.php)4
-rw-r--r--core/lib/Drupal/Component/Render/PlainTextOutput.php (renamed from core/lib/Drupal/Component/Utility/PlainTextOutput.php)6
-rw-r--r--core/lib/Drupal/Component/Utility/SafeMarkup.php21
-rw-r--r--core/lib/Drupal/Component/Utility/SafeStringInterface.php45
-rw-r--r--core/lib/Drupal/Core/Ajax/CommandWithAttachedAssetsTrait.php2
-rw-r--r--core/lib/Drupal/Core/Annotation/ContextDefinition.php4
-rw-r--r--core/lib/Drupal/Core/Annotation/Translation.php6
-rw-r--r--core/lib/Drupal/Core/Block/BlockBase.php2
-rw-r--r--core/lib/Drupal/Core/Config/ConfigBase.php8
-rw-r--r--core/lib/Drupal/Core/Entity/Annotation/ConfigEntityType.php4
-rw-r--r--core/lib/Drupal/Core/Entity/Annotation/ContentEntityType.php4
-rw-r--r--core/lib/Drupal/Core/Field/AllowedTagsXssTrait.php10
-rw-r--r--core/lib/Drupal/Core/Field/FieldFilteredMarkup.php (renamed from core/lib/Drupal/Core/Field/FieldFilteredString.php)18
-rw-r--r--core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/NumericFormatterBase.php4
-rw-r--r--core/lib/Drupal/Core/Field/Plugin/Field/FieldType/BooleanItem.php6
-rw-r--r--core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php8
-rw-r--r--core/lib/Drupal/Core/Field/Plugin/Field/FieldType/PasswordItem.php6
-rw-r--r--core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringItemBase.php6
-rw-r--r--core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/NumberWidget.php6
-rw-r--r--core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/OptionsWidgetBase.php4
-rw-r--r--core/lib/Drupal/Core/Field/WidgetBase.php4
-rw-r--r--core/lib/Drupal/Core/GeneratedLink.php4
-rw-r--r--core/lib/Drupal/Core/Language/LanguageManager.php24
-rw-r--r--core/lib/Drupal/Core/Logger/RfcLogLevel.php18
-rw-r--r--core/lib/Drupal/Core/Mail/MailManager.php2
-rw-r--r--core/lib/Drupal/Core/Menu/ContextualLinkDefault.php2
-rw-r--r--core/lib/Drupal/Core/Menu/LocalActionDefault.php2
-rw-r--r--core/lib/Drupal/Core/Menu/LocalTaskDefault.php2
-rw-r--r--core/lib/Drupal/Core/Menu/MenuLinkManager.php4
-rw-r--r--core/lib/Drupal/Core/Menu/MenuTreeStorage.php4
-rw-r--r--core/lib/Drupal/Core/Menu/menu.api.php8
-rw-r--r--core/lib/Drupal/Core/Plugin/Discovery/YamlDiscovery.php8
-rw-r--r--core/lib/Drupal/Core/Render/Element/HtmlTag.php12
-rw-r--r--core/lib/Drupal/Core/Render/Element/Tableselect.php4
-rw-r--r--core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php2
-rw-r--r--core/lib/Drupal/Core/Render/Markup.php (renamed from core/lib/Drupal/Core/Render/SafeString.php)10
-rw-r--r--core/lib/Drupal/Core/Render/PlaceholderGenerator.php2
-rw-r--r--core/lib/Drupal/Core/Render/RenderCache.php8
-rw-r--r--core/lib/Drupal/Core/Render/Renderer.php26
-rw-r--r--core/lib/Drupal/Core/Render/RendererInterface.php6
-rw-r--r--core/lib/Drupal/Core/Session/AccountInterface.php4
-rw-r--r--core/lib/Drupal/Core/StringTranslation/PluralTranslatableMarkup.php (renamed from core/lib/Drupal/Core/StringTranslation/PluralTranslatableString.php)18
-rw-r--r--core/lib/Drupal/Core/StringTranslation/TranslatableMarkup.php (renamed from core/lib/Drupal/Core/StringTranslation/TranslatableString.php)28
-rw-r--r--core/lib/Drupal/Core/StringTranslation/TranslationInterface.php16
-rw-r--r--core/lib/Drupal/Core/StringTranslation/TranslationManager.php6
-rw-r--r--core/lib/Drupal/Core/StringTranslation/TranslationWrapper.php4
-rw-r--r--core/lib/Drupal/Core/Template/Attribute.php10
-rw-r--r--core/lib/Drupal/Core/Template/TwigEnvironment.php8
-rw-r--r--core/lib/Drupal/Core/Template/TwigExtension.php4
-rw-r--r--core/lib/Drupal/Core/Theme/ThemeManager.php8
-rw-r--r--core/lib/Drupal/Core/Theme/ThemeManagerInterface.php4
-rw-r--r--core/lib/Drupal/Core/Utility/LinkGenerator.php4
-rw-r--r--core/lib/Drupal/Core/Utility/token.api.php2
-rw-r--r--core/lib/Drupal/Core/Validation/ConstraintManager.php10
-rw-r--r--core/lib/Drupal/Core/Validation/DrupalTranslator.php6
-rw-r--r--core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/PrimitiveTypeConstraintValidator.php4
-rw-r--r--core/modules/action/src/Plugin/Action/EmailAction.php2
-rw-r--r--core/modules/comment/comment.tokens.inc4
-rw-r--r--core/modules/comment/src/Tests/CommentTokenReplaceTest.php4
-rw-r--r--core/modules/contact/src/Tests/ContactPersonalTest.php2
-rw-r--r--core/modules/content_translation/content_translation.module6
-rw-r--r--core/modules/dblog/dblog.module6
-rw-r--r--core/modules/editor/editor.module6
-rw-r--r--core/modules/field/src/Tests/EntityReference/EntityReferenceItemTest.php6
-rw-r--r--core/modules/field_ui/src/Form/FieldConfigEditForm.php4
-rw-r--r--core/modules/file/file.field.inc4
-rw-r--r--core/modules/file/src/Plugin/Field/FieldType/FileItem.php2
-rw-r--r--core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php4
-rw-r--r--core/modules/filter/filter.module2
-rw-r--r--core/modules/filter/src/Element/ProcessedText.php4
-rw-r--r--core/modules/filter/src/Plugin/Filter/FilterCaption.php6
-rw-r--r--core/modules/filter/src/Render/FilteredMarkup.php29
-rw-r--r--core/modules/filter/src/Render/FilteredString.php29
-rw-r--r--core/modules/language/src/ConfigurableLanguageManager.php4
-rw-r--r--core/modules/locale/locale.module2
-rw-r--r--core/modules/locale/src/LocaleConfigManager.php14
-rw-r--r--core/modules/locale/src/LocaleConfigSubscriber.php8
-rw-r--r--core/modules/locale/src/Tests/LocalePluralFormatTest.php8
-rw-r--r--core/modules/menu_link_content/src/Tests/MenuLinkContentDeriverTest.php4
-rw-r--r--core/modules/node/node.tokens.inc4
-rw-r--r--core/modules/node/src/Tests/NodeTokenReplaceTest.php4
-rw-r--r--core/modules/options/src/Plugin/Field/FieldFormatter/OptionsDefaultFormatter.php4
-rw-r--r--core/modules/options/src/Plugin/Field/FieldFormatter/OptionsKeyFormatter.php4
-rw-r--r--core/modules/options/src/Plugin/views/argument/NumberListField.php4
-rw-r--r--core/modules/options/src/Plugin/views/argument/StringListField.php4
-rw-r--r--core/modules/quickedit/src/QuickEditController.php2
-rw-r--r--core/modules/rest/src/Plugin/views/display/RestExport.php4
-rw-r--r--core/modules/serialization/serialization.services.yml2
-rw-r--r--core/modules/serialization/src/Normalizer/MarkupNormalizer.php (renamed from core/modules/serialization/src/Normalizer/SafeStringNormalizer.php)8
-rw-r--r--core/modules/simpletest/src/AssertContentTrait.php26
-rw-r--r--core/modules/simpletest/src/AssertHelperTrait.php10
-rw-r--r--core/modules/simpletest/src/TestBase.php10
-rw-r--r--core/modules/simpletest/src/WebTestBase.php16
-rw-r--r--core/modules/simpletest/tests/src/Unit/AssertHelperTraitTest.php4
-rw-r--r--core/modules/system/src/Tests/Bootstrap/DrupalSetMessageTest.php10
-rw-r--r--core/modules/system/src/Tests/Plugin/Discovery/DiscoveryTestBase.php4
-rw-r--r--core/modules/system/src/Tests/System/TokenReplaceUnitTest.php4
-rw-r--r--core/modules/system/src/Tests/Theme/ThemeTest.php8
-rw-r--r--core/modules/system/src/Tests/Update/MenuTreeSerializationTitleTest.php8
-rw-r--r--core/modules/system/system.install2
-rw-r--r--core/modules/system/system.module2
-rw-r--r--core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/FieldTestItem.php6
-rw-r--r--core/modules/system/tests/modules/plugin_test/src/Plugin/MockBlockManager.php4
-rw-r--r--core/modules/system/tests/modules/system_test/src/Controller/SystemTestController.php22
-rw-r--r--core/modules/taxonomy/taxonomy.tokens.inc4
-rw-r--r--core/modules/user/src/Tests/UserTokenReplaceTest.php6
-rw-r--r--core/modules/user/tests/src/Unit/PermissionHandlerTest.php10
-rw-r--r--core/modules/user/user.module2
-rw-r--r--core/modules/views/src/Entity/View.php2
-rw-r--r--core/modules/views/src/Plugin/Derivative/ViewsBlock.php6
-rw-r--r--core/modules/views/src/Plugin/views/HandlerBase.php4
-rw-r--r--core/modules/views/src/Plugin/views/PluginBase.php4
-rw-r--r--core/modules/views/src/Plugin/views/ViewsHandlerInterface.php2
-rw-r--r--core/modules/views/src/Plugin/views/argument/FieldList.php4
-rw-r--r--core/modules/views/src/Plugin/views/argument/ListString.php4
-rw-r--r--core/modules/views/src/Plugin/views/field/Boolean.php4
-rw-r--r--core/modules/views/src/Plugin/views/field/FieldHandlerInterface.php16
-rw-r--r--core/modules/views/src/Plugin/views/field/FieldPluginBase.php16
-rw-r--r--core/modules/views/src/Plugin/views/field/NumericField.php4
-rw-r--r--core/modules/views/src/Plugin/views/filter/FilterPluginBase.php2
-rw-r--r--core/modules/views/src/Plugin/views/relationship/RelationshipPluginBase.php2
-rw-r--r--core/modules/views/src/Plugin/views/style/StylePluginBase.php6
-rw-r--r--core/modules/views/src/Render/ViewsRenderPipelineMarkup.php (renamed from core/modules/views/src/Render/ViewsRenderPipelineSafeString.php)12
-rw-r--r--core/modules/views/src/Tests/FieldApiDataTest.php6
-rw-r--r--core/modules/views/src/Tests/Plugin/PluginBaseTest.php4
-rw-r--r--core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php4
-rw-r--r--core/modules/views/views.module4
-rw-r--r--core/modules/views/views.views.inc6
-rw-r--r--core/modules/views_ui/admin.inc2
-rw-r--r--core/modules/views_ui/src/ViewListBuilder.php2
-rw-r--r--core/tests/Drupal/KernelTests/Core/Common/DrupalSetMessageTest.php2
-rw-r--r--core/tests/Drupal/KernelTests/Core/StringTranslation/TranslationStringTest.php4
-rw-r--r--core/tests/Drupal/KernelTests/Core/Theme/ThemeRenderAndAutoescapeTest.php6
-rw-r--r--core/tests/Drupal/Tests/Component/Render/FormattableMarkupTest.php (renamed from core/tests/Drupal/Tests/Component/Utility/FormattableStringTest.php)16
-rw-r--r--core/tests/Drupal/Tests/Component/Render/PlainTextOutputTest.php (renamed from core/tests/Drupal/Tests/Component/Utility/PlainTextOutputTest.php)14
-rw-r--r--core/tests/Drupal/Tests/Component/Utility/SafeMarkupTest.php18
-rw-r--r--core/tests/Drupal/Tests/Core/Config/ConfigTest.php4
-rw-r--r--core/tests/Drupal/Tests/Core/Entity/EntityTypeTest.php8
-rw-r--r--core/tests/Drupal/Tests/Core/Field/FieldFilteredMarkupTest.php (renamed from core/tests/Drupal/Tests/Core/Field/FieldFilteredStringTest.php)18
-rw-r--r--core/tests/Drupal/Tests/Core/Menu/ContextualLinkDefaultTest.php8
-rw-r--r--core/tests/Drupal/Tests/Core/Menu/LocalActionDefaultTest.php8
-rw-r--r--core/tests/Drupal/Tests/Core/Menu/LocalTaskDefaultTest.php8
-rw-r--r--core/tests/Drupal/Tests/Core/Plugin/Discovery/YamlDiscoveryTest.php6
-rw-r--r--core/tests/Drupal/Tests/Core/Render/Element/HtmlTagTest.php8
-rw-r--r--core/tests/Drupal/Tests/Core/Render/Element/TableSelectTest.php4
-rw-r--r--core/tests/Drupal/Tests/Core/Render/RendererPlaceholdersTest.php8
-rw-r--r--core/tests/Drupal/Tests/Core/Render/RendererTest.php10
-rw-r--r--core/tests/Drupal/Tests/Core/StringTranslation/TranslatableMarkupTest.php (renamed from core/tests/Drupal/Tests/Core/StringTranslation/TranslatableStringTest.php)14
-rw-r--r--core/tests/Drupal/Tests/Core/StringTranslation/TranslationManagerTest.php4
-rw-r--r--core/tests/Drupal/Tests/Core/Template/AttributeTest.php10
-rw-r--r--core/tests/Drupal/Tests/Core/Template/TwigExtensionTest.php8
-rw-r--r--core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php14
-rw-r--r--core/tests/Drupal/Tests/Core/Utility/TokenTest.php4
-rw-r--r--core/tests/Drupal/Tests/Core/Validation/Plugin/Validation/Constraint/PrimitiveTypeConstraintValidatorTest.php4
-rw-r--r--core/tests/Drupal/Tests/UnitTestCase.php10
-rw-r--r--core/themes/engines/twig/twig.engine6
163 files changed, 675 insertions, 663 deletions
diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc
index b717841..adc2923 100644
--- a/core/includes/bootstrap.inc
+++ b/core/includes/bootstrap.inc
@@ -13,7 +13,7 @@ use Drupal\Component\Utility\Unicode;
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 e66261e..cb5d8b0 100644
--- a/core/includes/common.inc
+++ b/core/includes/common.inc
@@ -22,10 +22,10 @@ use Drupal\Component\Utility\UrlHelper;
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\Core\PhpStorage\PhpStorageFactory;
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 @@ const JS_THEME = 100;
* 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 1757acd..4795480 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 61bc83f..a9a8826 100644
--- a/core/includes/theme.inc
+++ b/core/includes/theme.inc
@@ -12,7 +12,7 @@ use Drupal\Component\Serialization\Json;
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\Template\Attribute;
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
index c069da2..c8b9ae4 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 @@ namespace Drupal\Component\Utility;
* 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 @@ namespace Drupal\Component\Utility;
*
* @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 @@ class FormattableString implements SafeStringInterface {
* 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 @@ class FormattableString implements SafeStringInterface {
*
* @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 @@ class FormattableString implements SafeStringInterface {
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 @@ class FormattableString implements SafeStringInterface {
// 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 @@ class FormattableString implements SafeStringInterface {
/**
* 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 0000000..2da4e13
--- /dev/null
+++ b/core/lib/Drupal/Component/Render/MarkupInterface.php
@@ -0,0 +1,45 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\Component\Render\MarkupInterface.
+ */
+
+namespace Drupal\Component\Render;
+
+/**
+ * Marks an object's __toString() method as returning markup.
+ *
+ * Objects that implement this interface will not be automatically XSS filtered
+ * by the render system or automatically escaped by the theme engine.
+ *
+ * If there is any risk of the object's __toString() method returning
+ * user-entered data that has not been filtered first, it must not be used. If
+ * the object that implements this does not perform automatic escaping or
+ * filtering itself, then it must be marked as "@internal". For example, Views
+ * has the internal ViewsRenderPipelineMarkup object to provide a custom render
+ * pipeline in order to render JSON and to fast render fields. By contrast,
+ * FormattableMarkup and TranslatableMarkup always sanitize their output when
+ * used correctly.
+ *
+ * If the object is going to be used directly in Twig templates it should
+ * implement \Countable so it can be used in if statements.
+ *
+ * @see \Drupal\Component\Render\MarkupTrait
+ * @see \Drupal\Component\Utility\SafeMarkup::isSafe()
+ * @see \Drupal\Core\Template\TwigExtension::escapeFilter()
+ * @see \Drupal\Component\Render\FormattableMarkup
+ * @see \Drupal\Core\StringTranslation\TranslatableMarkup
+ * @see \Drupal\views\Render\ViewsRenderPipelineMarkup
+ */
+interface MarkupInterface extends \JsonSerializable {
+
+ /**
+ * Returns markup.
+ *
+ * @return string
+ * The markup.
+ */
+ public function __toString();
+
+}
diff --git a/core/lib/Drupal/Component/Utility/SafeStringTrait.php b/core/lib/Drupal/Component/Render/MarkupTrait.php
index bd1ee75..84b2c91 100644
--- a/core/lib/Drupal/Component/Utility/SafeStringTrait.php
+++ b/core/lib/Drupal/Component/Render/MarkupTrait.php
@@ -2,17 +2,19 @@
/**
* @file
- * Contains \Drupal\Component\Utility\SafeStringTrait.
+ * Contains \Drupal\Component\Render\MarkupTrait.
*/
-namespace Drupal\Component\Utility;
+namespace Drupal\Component\Render;
+
+use Drupal\Component\Utility\Unicode;
/**
- * Implements SafeStringInterface and Countable for rendered objects.
+ * Implements MarkupInterface and Countable for rendered objects.
*
- * @see \Drupal\Component\Utility\SafeStringInterface
+ * @see \Drupal\Component\Render\MarkupInterface
*/
-trait SafeStringTrait {
+trait MarkupTrait {
/**
* The safe string.
@@ -22,20 +24,20 @@ trait SafeStringTrait {
protected $string;
/**
- * Creates a SafeString object if necessary.
+ * Creates a Markup object if necessary.
*
* If $string is equal to a blank string then it is not necessary to create a
- * SafeString object. If $string is an object that implements
- * SafeStringInterface it is returned unchanged.
+ * Markup object. If $string is an object that implements MarkupInterface it
+ * is returned unchanged.
*
* @param mixed $string
* The string to mark as safe. This value will be cast to a string.
*
- * @return string|\Drupal\Component\Utility\SafeStringInterface
+ * @return string|\Drupal\Component\Render\MarkupInterface
* A safe string.
*/
public static function create($string) {
- if ($string instanceof SafeStringInterface) {
+ if ($string instanceof MarkupInterface) {
return $string;
}
$string = (string) $string;
@@ -48,7 +50,7 @@ trait SafeStringTrait {
}
/**
- * Returns the string version of the SafeString object.
+ * Returns the string version of the Markup object.
*
* @return string
* The safe string content.
diff --git a/core/lib/Drupal/Component/Utility/OutputStrategyInterface.php b/core/lib/Drupal/Component/Render/OutputStrategyInterface.php
index e4a51b5..5832cd4 100644
--- a/core/lib/Drupal/Component/Utility/OutputStrategyInterface.php
+++ b/core/lib/Drupal/Component/Render/OutputStrategyInterface.php
@@ -2,10 +2,10 @@
/**
* @file
- * Contains \Drupal\Component\Utility\OutputStrategyInterface.
+ * Contains \Drupal\Component\Render\OutputStrategyInterface.
*/
-namespace Drupal\Component\Utility;
+namespace Drupal\Component\Render;
/**
* Provides an output strategy that formats HTML strings for a given context.
diff --git a/core/lib/Drupal/Component/Utility/PlainTextOutput.php b/core/lib/Drupal/Component/Render/PlainTextOutput.php
index 2bbcb74..d59189c 100644
--- a/core/lib/Drupal/Component/Utility/PlainTextOutput.php
+++ b/core/lib/Drupal/Component/Render/PlainTextOutput.php
@@ -1,10 +1,12 @@
<?php
/**
* @file
- * Contains \Drupal\Component\Utility\PlainTextOutput.
+ * Contains \Drupal\Component\Render\PlainTextOutput.
*/
-namespace Drupal\Component\Utility;
+namespace Drupal\Component\Render;
+
+use Drupal\Component\Utility\Html;
/**
* Provides an output strategy for transforming HTML into simple plain text.
diff --git a/core/lib/Drupal/Component/Utility/SafeMarkup.php b/core/lib/Drupal/Component/Utility/SafeMarkup.php
index c6f2468..1272cee 100644
--- a/core/lib/Drupal/Component/Utility/SafeMarkup.php
+++ b/core/lib/Drupal/Component/Utility/SafeMarkup.php
@@ -7,6 +7,9 @@
namespace Drupal\Component\Utility;
+use Drupal\Component\Render\FormattableMarkup;
+use Drupal\Component\Render\MarkupInterface;
+
/**
* Manages known safe strings for rendering at the theme layer.
*
@@ -47,7 +50,7 @@ class SafeMarkup {
/**
* Checks if a string is safe to output.
*
- * @param string|\Drupal\Component\Utility\SafeStringInterface $string
+ * @param string|\Drupal\Component\Render\MarkupInterface $string
* The content to be checked.
* @param string $strategy
* The escaping strategy. Defaults to 'html'. Two escaping strategies are
@@ -64,7 +67,7 @@ class SafeMarkup {
public static function isSafe($string, $strategy = 'html') {
// Do the instanceof checks first to save unnecessarily casting the object
// to a string.
- return $string instanceOf SafeStringInterface || isset(static::$safeStrings[(string) $string][$strategy]) ||
+ return $string instanceOf MarkupInterface || isset(static::$safeStrings[(string) $string][$strategy]) ||
isset(static::$safeStrings[(string) $string]['all']);
}
@@ -166,23 +169,23 @@ class SafeMarkup {
* any unsafe content must be in $args and inserted via placeholders.
* @param array $args
* 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.
*
- * @return string|\Drupal\Component\Utility\SafeStringInterface
- * The formatted string, which is an instance of SafeStringInterface unless
+ * @return string|\Drupal\Component\Render\MarkupInterface
+ * The formatted string, which is an instance of MarkupInterface unless
* sanitization of an unsafe argument was suppressed (see above).
*
* @ingroup sanitization
*
- * @see \Drupal\Component\Utility\FormattableString::placeholderFormat()
- * @see \Drupal\Component\Utility\FormattableString
+ * @see \Drupal\Component\Render\FormattableMarkup::placeholderFormat()
+ * @see \Drupal\Component\Render\FormattableMarkup
*
* @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
- * Use \Drupal\Component\Utility\FormattableString.
+ * Use \Drupal\Component\Render\FormattableMarkup.
*/
public static function format($string, array $args) {
- return new FormattableString($string, $args);
+ return new FormattableMarkup($string, $args);
}
}
diff --git a/core/lib/Drupal/Component/Utility/SafeStringInterface.php b/core/lib/Drupal/Component/Utility/SafeStringInterface.php
deleted file mode 100644
index 181d1d6..0000000
--- a/core/lib/Drupal/Component/Utility/SafeStringInterface.php
+++ /dev/null
@@ -1,45 +0,0 @@
-<?php
-
-/**
- * @file
- * Contains \Drupal\Component\Utility\SafeStringInterface.
- */
-
-namespace Drupal\Component\Utility;
-
-/**
- * Marks an object's __toString() method as returning safe markup.
- *
- * All objects that implement this interface should be marked @internal.
- *
- * This interface should only be used on objects that emit known safe strings
- * from their __toString() method. If there is any risk of the method returning
- * user-entered data that has not been filtered first, it must not be used.
- *
- * If the object is going to be used directly in Twig templates it should
- * implement \Countable so it can be used in if statements.
- *
- * @internal
- * This interface is marked as internal because it should only be used by
- * objects used during rendering. This interface should be used by modules if
- * they interrupt the render pipeline and explicitly deal with SafeString
- * objects created by the render system. Additionally, if a module reuses the
- * regular render pipeline internally and passes processed data into it. For
- * example, Views implements a custom render pipeline in order to render JSON
- * and to fast render fields.
- *
- * @see \Drupal\Component\Utility\SafeStringTrait
- * @see \Drupal\Component\Utility\SafeMarkup::isSafe()
- * @see \Drupal\Core\Template\TwigExtension::escapeFilter()
- */
-interface SafeStringInterface extends \JsonSerializable {
-
- /**
- * Returns a safe string.
- *
- * @return string
- * The safe string.
- */
- public function __toString();
-
-}
diff --git a/core/lib/Drupal/Core/Ajax/CommandWithAttachedAssetsTrait.php b/core/lib/Drupal/Core/Ajax/CommandWithAttachedAssetsTrait.php
index e48d060..f95b9f8 100644
--- a/core/lib/Drupal/Core/Ajax/CommandWithAttachedAssetsTrait.php
+++ b/core/lib/Drupal/Core/Ajax/CommandWithAttachedAssetsTrait.php
@@ -29,7 +29,7 @@ trait CommandWithAttachedAssetsTrait {
* If content is a render array, it may contain attached assets to be
* processed.
*
- * @return string|\Drupal\Component\Utility\SafeStringInterface
+ * @return string|\Drupal\Component\Render\MarkupInterface
* HTML rendered content.
*/
protected function getRenderedContent() {
diff --git a/core/lib/Drupal/Core/Annotation/ContextDefinition.php b/core/lib/Drupal/Core/Annotation/ContextDefinition.php
index 0b26860..3508c57 100644
--- a/core/lib/Drupal/Core/Annotation/ContextDefinition.php
+++ b/core/lib/Drupal/Core/Annotation/ContextDefinition.php
@@ -8,7 +8,7 @@
namespace Drupal\Core\Annotation;
use Drupal\Component\Annotation\Plugin;
-use Drupal\Core\StringTranslation\TranslatableString;
+use Drupal\Core\StringTranslation\TranslatableMarkup;
/**
* @defgroup plugin_context Annotation for context definition
@@ -113,7 +113,7 @@ class ContextDefinition extends Plugin {
// used in the classes they pass to.
foreach (['label', 'description'] as $key) {
// @todo Remove this workaround in https://www.drupal.org/node/2362727.
- if (isset($values[$key]) && $values[$key] instanceof TranslatableString) {
+ if (isset($values[$key]) && $values[$key] instanceof TranslatableMarkup) {
$values[$key] = (string) $values[$key]->get();
}
else {
diff --git a/core/lib/Drupal/Core/Annotation/Translation.php b/core/lib/Drupal/Core/Annotation/Translation.php
index 0f1d743..83cd6f6 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 @@ class Translation extends AnnotationBase {
'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 5684e3d..fe5c12e 100644
--- a/core/lib/Drupal/Core/Block/BlockBase.php
+++ b/core/lib/Drupal/Core/Block/BlockBase.php
@@ -48,7 +48,7 @@ abstract class BlockBase extends ContextAwarePluginBase implements BlockPluginIn
$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 b9a4e61..0d66c66 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 @@ abstract class ConfigBase implements RefinableCacheableDependencyInterface {
}
/**
- * 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 @@ abstract class ConfigBase implements RefinableCacheableDependencyInterface {
* 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 5d4c3da..4c7524b 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 9c59a64..a879704 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 c58096a..c889615 100644
--- a/core/lib/Drupal/Core/Field/AllowedTagsXssTrait.php
+++ b/core/lib/Drupal/Core/Field/AllowedTagsXssTrait.php
@@ -10,9 +10,9 @@ namespace Drupal\Core\Field;
* 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
index 1a513c9..78900a9 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 @@ use Drupal\Component\Utility\Xss;
* 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 0320cd5..28b0159 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 @@ abstract class NumericFormatterBase extends FormatterBase {
// 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 b083111..7128838 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\FieldItemBase;
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 70397fa..5904d35 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\Entity\TypedData\EntityDataDefinition;
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 @@ class EntityReferenceItem extends FieldItemBase {
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 e99b5d1..7caa26f 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 @@ namespace Drupal\Core\Field\Plugin\Field\FieldType;
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 c71bd4c..e856718 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 @@ namespace Drupal\Core\Field\Plugin\Field\FieldType;
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 @@ abstract class StringItemBase 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('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 86c17b6..57abc60 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 @@ class NumberWidget extends WidgetBase {
// 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 cde5684..0235f3f 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 @@ namespace Drupal\Core\Field\Plugin\Field\FieldWidget;
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 @@ abstract class OptionsWidgetBase extends WidgetBase {
*/
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 575daf9..6aa4012 100644
--- a/core/lib/Drupal/Core/Field/WidgetBase.php
+++ b/core/lib/Drupal/Core/Field/WidgetBase.php
@@ -85,7 +85,7 @@ abstract class WidgetBase extends PluginSettingsBase implements WidgetInterface
$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 @@ abstract class WidgetBase extends PluginSettingsBase implements WidgetInterface
}
$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 bfd9769..d7e96e1 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 @@ use Drupal\Core\Render\BubbleableMetadata;
* 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 b8f5aef..092e9fe 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 @@ class LanguageManager implements LanguageManagerInterface {
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 @@ class LanguageManager implements LanguageManagerInterface {
*/
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 @@ class LanguageManager implements LanguageManagerInterface {
'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 @@ class LanguageManager implements LanguageManagerInterface {
$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 c7139b0..ba31938 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 22b9a28..663cfd4 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 65e43b5..8f44d7a 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 a8ce7ed..4b72af4 100644
--- a/core/lib/Drupal/Core/Menu/LocalActionDefault.php
+++ b/core/lib/Drupal/Core/Menu/LocalActionDefault.php
@@ -71,7 +71,7 @@ class LocalActionDefault extends PluginBase implements LocalActionInterface, Con
*/
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 116546d..252a03a 100644
--- a/core/lib/Drupal/Core/Menu/LocalTaskDefault.php
+++ b/core/lib/Drupal/Core/Menu/LocalTaskDefault.php
@@ -80,7 +80,7 @@ class LocalTaskDefault extends PluginBase implements LocalTaskInterface, Cacheab
* {@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 c561f63..106407b 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 9392fa4..d639be7 100644
--- a/core/lib/Drupal/Core/Menu/MenuTreeStorage.php
+++ b/core/lib/Drupal/Core/Menu/MenuTreeStorage.php
@@ -1262,14 +1262,14 @@ class MenuTreeStorage implements MenuTreeStorageInterface {
'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 a403cda..5d05634 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 fe78de8..97ea374 100644
--- a/core/lib/Drupal/Core/Plugin/Discovery/YamlDiscovery.php
+++ b/core/lib/Drupal/Core/Plugin/Discovery/YamlDiscovery.php
@@ -10,7 +10,7 @@ namespace Drupal\Core\Plugin\Discovery;
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 @@ use Drupal\Core\StringTranslation\TranslatableString;
* 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 @@ class YamlDiscovery implements DiscoveryInterface {
$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 @@ class YamlDiscovery implements DiscoveryInterface {
$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 03e67d1..f2bcacf 100644
--- a/core/lib/Drupal/Core/Render/Element/HtmlTag.php
+++ b/core/lib/Drupal/Core/Render/Element/HtmlTag.php
@@ -9,7 +9,7 @@ namespace Drupal\Core\Render\Element;
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 @@ class HtmlTag extends RenderElement {
if (!empty($element['#noscript'])) {
$markup = "<noscript>$markup</noscript>";
}
- $element['#markup'] = SafeString::create($markup);
+ $element['#markup'] = Markup::create($markup);
return $element;
}
@@ -166,13 +166,13 @@ class HtmlTag extends RenderElement {
// filtered if they are unsafe. Thus, all these strings are safe.
if (!$browsers['!IE']) {
// "downlevel-hidden".
- $element['#prefix'] = SafeString::create("\n<!--[if $expression]>\n" . $prefix);
- $element['#suffix'] = SafeString::create($suffix . "<![endif]-->\n");
+ $element['#prefix'] = Markup::create("\n<!--[if $expression]>\n" . $prefix);
+ $element['#suffix'] = Markup::create($suffix . "<![endif]-->\n");
}
else {
// "downlevel-revealed".
- $element['#prefix'] = SafeString::create("\n<!--[if $expression]><!-->\n" . $prefix);
- $element['#suffix'] = SafeString::create($suffix . "<!--<![endif]-->\n");
+ $element['#prefix'] = Markup::create("\n<!--[if $expression]><!-->\n" . $prefix);
+ $element['#suffix'] = Markup::create($suffix . "<!--<![endif]-->\n");
}
return $element;
diff --git a/core/lib/Drupal/Core/Render/Element/Tableselect.php b/core/lib/Drupal/Core/Render/Element/Tableselect.php
index 3617b8c..cc6aefd 100644
--- a/core/lib/Drupal/Core/Render/Element/Tableselect.php
+++ b/core/lib/Drupal/Core/Render/Element/Tableselect.php
@@ -10,7 +10,7 @@ namespace Drupal\Core\Render\Element;
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 @@ class Tableselect extends Table {
$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 6104b0a..196c290 100644
--- a/core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php
+++ b/core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php
@@ -237,7 +237,7 @@ class HtmlResponseAttachmentsProcessor implements AttachmentsResponseProcessorIn
*/
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
index 4d968ce..c36d29f 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 @@ use Drupal\Component\Utility\SafeStringTrait;
* @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 0548901..e0940bf 100644
--- a/core/lib/Drupal/Core/Render/PlaceholderGenerator.php
+++ b/core/lib/Drupal/Core/Render/PlaceholderGenerator.php
@@ -93,7 +93,7 @@ class PlaceholderGenerator implements PlaceholderGeneratorInterface {
// 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 b7fb4f6..ac6e34e 100644
--- a/core/lib/Drupal/Core/Render/RenderCache.php
+++ b/core/lib/Drupal/Core/Render/RenderCache.php
@@ -339,10 +339,10 @@ class RenderCache implements RenderCacheInterface {
// 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 @@ class RenderCache implements RenderCacheInterface {
// 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 c2e03c9..b1f7c2a 100644
--- a/core/lib/Drupal/Core/Render/Renderer.php
+++ b/core/lib/Drupal/Core/Render/Renderer.php
@@ -187,7 +187,7 @@ class Renderer implements RendererInterface {
// 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 @@ class Renderer implements RendererInterface {
}
// 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 @@ class Renderer implements RendererInterface {
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 @@ class Renderer implements RendererInterface {
// 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 @@ class Renderer implements RendererInterface {
$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 @@ class Renderer implements RendererInterface {
* 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 @@ class Renderer implements RendererInterface {
* @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 @@ class Renderer implements RendererInterface {
}
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 649cf98..02269e4 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 @@ 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 ::renderRoot()
@@ -302,7 +302,7 @@ interface RendererInterface {
* (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 36b390a..ad79ee1 100644
--- a/core/lib/Drupal/Core/Session/AccountInterface.php
+++ b/core/lib/Drupal/Core/Session/AccountInterface.php
@@ -143,9 +143,9 @@ interface AccountInterface {
*
* @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
index f8fb07b..583ab18 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 @@ class PluralTranslatableString extends TranslatableString {
}
/**
- * 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 @@ class PluralTranslatableString extends TranslatableString {
* @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
index 1368e6f..8b4902a 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 @@ class TranslatableString extends FormattableString {
* 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 195a5a1..57ed36e 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 @@ interface TranslationInterface {
* 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 @@ interface TranslationInterface {
* @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 ec16db2..7ccf5a3 100644
--- a/core/lib/Drupal/Core/StringTranslation/TranslationManager.php
+++ b/core/lib/Drupal/Core/StringTranslation/TranslationManager.php
@@ -110,13 +110,13 @@ class TranslationManager implements TranslationInterface, TranslatorInterface {
* {@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 @@ class TranslationManager implements TranslationInterface, TranslatorInterface {
* {@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 0a72c23..2e43a11 100644
--- a/core/lib/Drupal/Core/StringTranslation/TranslationWrapper.php
+++ b/core/lib/Drupal/Core/StringTranslation/TranslationWrapper.php
@@ -11,6 +11,6 @@ namespace Drupal\Core\StringTranslation;
* 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 8784025..a794142 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 @@ use Drupal\Component\Utility\SafeStringInterface;
* @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 @@ class Attribute implements \ArrayAccess, \IteratorAggregate, SafeStringInterface
// 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 845f219..8d3feaa 100644
--- a/core/lib/Drupal/Core/Template/TwigEnvironment.php
+++ b/core/lib/Drupal/Core/Template/TwigEnvironment.php
@@ -9,7 +9,7 @@ namespace Drupal\Core\Template;
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 @@ class TwigEnvironment extends \Twig_Environment {
* @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 552ef54..23091d5 100644
--- a/core/lib/Drupal/Core/Template/TwigExtension.php
+++ b/core/lib/Drupal/Core/Template/TwigExtension.php
@@ -14,7 +14,7 @@ namespace Drupal\Core\Template;
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 @@ class TwigExtension extends \Twig_Extension {
}
// 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 9958b56..7e0e0b4 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 @@ class ThemeManager implements ThemeManagerInterface {
// 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 @@ class ThemeManager implements ThemeManagerInterface {
$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 b61ff84..029cda0 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 6eb473b..8b453f7 100644
--- a/core/lib/Drupal/Core/Utility/LinkGenerator.php
+++ b/core/lib/Drupal/Core/Utility/LinkGenerator.php
@@ -10,7 +10,7 @@ namespace Drupal\Core\Utility;
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 @@ class LinkGenerator implements LinkGeneratorInterface {
// 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 4bc619f..d39d66f 100644
--- a/core/lib/Drupal/Core/Utility/token.api.php
+++ b/core/lib/Drupal/Core/Utility/token.api.php
@@ -65,7 +65,7 @@ use Drupal\user\Entity\User;
* @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 7c61b03..1dd9a03 100644
--- a/core/lib/Drupal/Core/Validation/ConstraintManager.php
+++ b/core/lib/Drupal/Core/Validation/ConstraintManager.php
@@ -11,7 +11,7 @@ use Drupal\Component\Plugin\Discovery\StaticDiscoveryDecorator;
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 @@ class ConstraintManager extends DefaultPluginManager {
*/
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 4318f9d..c7db71c 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 @@ class DrupalTranslator implements TranslatorInterface {
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 6fa8771..503825f 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\IntegerInterface;
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 @@ class PrimitiveTypeConstraintValidator extends ConstraintValidator {
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 4c68e1d..797d8a4 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 e2d606f..73f48b7 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 13c415e..b7172e3 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 @@ class CommentTokenReplaceTest extends CommentTestBase {
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 7028a48..d133240 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 39ff551..0370367 100644
--- a/core/modules/content_translation/content_translation.module
+++ b/core/modules/content_translation/content_translation.module
@@ -13,7 +13,7 @@ use Drupal\Core\Entity\EntityTypeInterface;
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 3305178..a42242b 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 1e645dd..0e4f795 100644
--- a/core/modules/editor/editor.module
+++ b/core/modules/editor/editor.module
@@ -11,7 +11,7 @@ use Drupal\Core\Field\FieldDefinitionInterface;
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 8d492e5..d785696 100644
--- a/core/modules/field/src/Tests/EntityReference/EntityReferenceItemTest.php
+++ b/core/modules/field/src/Tests/EntityReference/EntityReferenceItemTest.php
@@ -10,7 +10,7 @@ namespace Drupal\field\Tests\EntityReference;
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 @@ class EntityReferenceItemTest extends FieldUnitTestBase {
$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 @@ class EntityReferenceItemTest extends FieldUnitTestBase {
$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 ba972a9..e2d1bce 100644
--- a/core/modules/field_ui/src/Form/FieldConfigEditForm.php
+++ b/core/modules/field_ui/src/Form/FieldConfigEditForm.php
@@ -9,7 +9,7 @@ namespace Drupal\field_ui\Form;
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 @@ class FieldConfigEditForm extends EntityForm {
'#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.<br />Allowed HTML tags: @tags', array('@tags' => FieldFilteredString::displayAllowedTags())) . '<br />' . $this->t('This field supports tokens.'),
+ '#description' => $this->t('Instructions to present to the user below this field on the editing form.<br />Allowed HTML tags: @tags', array('@tags' => FieldFilteredMarkup::displayAllowedTags())) . '<br />' . $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 50b913f..aac6bd8 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 8bbe278..3d6bfc5 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 5852ab4..7d32ce9 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 @@ namespace Drupal\file\Plugin\Field\FieldWidget;
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 @@ class FileWidget extends WidgetBase implements ContainerFactoryPluginInterface {
}
$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 6c4db0a..934bda6 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 de9d5cc..6a3fa40 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\Element\RenderElement;
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 @@ class ProcessedText extends RenderElement {
// 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 7671452..37c18cc 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\Unicode;
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 @@ class FilterCaption extends FilterBase {
// Sanitize caption: decode HTML encoding, limit allowed HTML tags; only
// allow inline tags that are allowed by default, plus <br>.
$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 @@ class FilterCaption extends FilterBase {
// 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 0000000..2abfac3
--- /dev/null
+++ b/core/modules/filter/src/Render/FilteredMarkup.php
@@ -0,0 +1,29 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\filter\Render\FilteredMarkup.
+ */
+
+namespace Drupal\filter\Render;
+
+use Drupal\Component\Render\MarkupInterface;
+use Drupal\Component\Render\MarkupTrait;
+
+/**
+ * Defines an object that passes markup through the Filter system.
+ *
+ * This object should only be constructed with markup that is safe to render. If
+ * there is any risk that the string contains user-entered data that has not
+ * been filtered first, it must not be used.
+ *
+ * @internal
+ * This object is marked as internal because it should only be used in the
+ * Filter module on strings that have already been been filtered and sanitized
+ * in \Drupal\filter\Plugin\FilterInterface.
+ *
+ * @see \Drupal\Core\Render\Markup
+ */
+final class FilteredMarkup implements MarkupInterface, \Countable {
+ use MarkupTrait;
+}
diff --git a/core/modules/filter/src/Render/FilteredString.php b/core/modules/filter/src/Render/FilteredString.php
deleted file mode 100644
index 2c694e6..0000000
--- a/core/modules/filter/src/Render/FilteredString.php
+++ /dev/null
@@ -1,29 +0,0 @@
-<?php
-
-/**
- * @file
- * Contains \Drupal\filter\Render\FilteredString.
- */
-
-namespace Drupal\filter\Render;
-
-use Drupal\Component\Utility\SafeStringInterface;
-use Drupal\Component\Utility\SafeStringTrait;
-
-/**
- * Defines an object that passes safe strings through the Filter system.
- *
- * This object should only be constructed with a known safe string. If there is
- * any risk that the string contains user-entered data that has not been
- * filtered first, it must not be used.
- *
- * @internal
- * This object is marked as internal because it should only be used in the
- * Filter module on strings that have already been been filtered and sanitized
- * in \Drupal\filter\Plugin\FilterInterface.
- *
- * @see \Drupal\Core\Render\SafeString
- */
-final class FilteredString implements SafeStringInterface, \Countable {
- use SafeStringTrait;
-}
diff --git a/core/modules/language/src/ConfigurableLanguageManager.php b/core/modules/language/src/ConfigurableLanguageManager.php
index 26c6c13..6b72a4f 100644
--- a/core/modules/language/src/ConfigurableLanguageManager.php
+++ b/core/modules/language/src/ConfigurableLanguageManager.php
@@ -13,7 +13,7 @@ use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Language\Language;
use Drupal\Core\Language\LanguageDefault;
use Drupal\Core\Language\LanguageManager;
-use Drupal\Core\StringTranslation\TranslatableString;
+use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\Core\Url;
use Drupal\language\Config\LanguageConfigFactoryOverrideInterface;
use Drupal\language\Entity\ConfigurableLanguage;
@@ -470,7 +470,7 @@ class ConfigurableLanguageManager extends LanguageManager implements Configurabl
unset($predefined[$key]);
continue;
}
- $predefined[$key] = new TranslatableString($value[0]);
+ $predefined[$key] = new TranslatableMarkup($value[0]);
}
asort($predefined);
return $predefined;
diff --git a/core/modules/locale/locale.module b/core/modules/locale/locale.module
index 02ab2e7..9cd1c75 100644
--- a/core/modules/locale/locale.module
+++ b/core/modules/locale/locale.module
@@ -20,7 +20,7 @@ use Drupal\Core\Cache\Cache;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Language\Language;
use Drupal\Core\Routing\RouteMatchInterface;
-use Drupal\Core\StringTranslation\TranslatableString;
+use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\Core\Language\LanguageInterface;
use Drupal\language\ConfigurableLanguageInterface;
use Drupal\Component\Utility\Crypt;
diff --git a/core/modules/locale/src/LocaleConfigManager.php b/core/modules/locale/src/LocaleConfigManager.php
index 79628e1..1328873 100644
--- a/core/modules/locale/src/LocaleConfigManager.php
+++ b/core/modules/locale/src/LocaleConfigManager.php
@@ -12,7 +12,7 @@ use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Config\InstallStorage;
use Drupal\Core\Config\StorageInterface;
use Drupal\Core\Config\TypedConfigManagerInterface;
-use Drupal\Core\StringTranslation\TranslatableString;
+use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\Core\TypedData\TraversableTypedDataInterface;
use Drupal\Core\TypedData\TypedDataInterface;
use Drupal\language\ConfigurableLanguageManagerInterface;
@@ -150,11 +150,11 @@ class LocaleConfigManager {
* @param \Drupal\Core\TypedData\TypedDataInterface $element
* Typed configuration element.
*
- * @return array|\Drupal\Core\StringTranslation\TranslatableString
+ * @return array|\Drupal\Core\StringTranslation\TranslatableMarkup
* A nested array matching the exact structure under $element with only the
- * elements that are translatable wrapped into a TranslatableString. If the
+ * elements that are translatable wrapped into a TranslatableMarkup. If the
* provided $element is not traversable, the return value is a single
- * TranslatableString.
+ * TranslatableMarkup.
*/
protected function getTranslatableData(TypedDataInterface $element) {
$translatable = array();
@@ -173,7 +173,7 @@ class LocaleConfigManager {
if (isset($definition['translation context'])) {
$options['context'] = $definition['translation context'];
}
- return new TranslatableString($element->getValue(), array(), $options);
+ return new TranslatableMarkup($element->getValue(), array(), $options);
}
}
return $translatable;
@@ -191,10 +191,10 @@ class LocaleConfigManager {
* 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 1c10480..bb20102 100644
--- a/core/modules/locale/src/LocaleConfigSubscriber.php
+++ b/core/modules/locale/src/LocaleConfigSubscriber.php
@@ -133,7 +133,7 @@ class LocaleConfigSubscriber implements EventSubscriberInterface {
* 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 @@ class LocaleConfigSubscriber implements EventSubscriberInterface {
*
* @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 386cd5d..ba5cf84 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 @@ class LocalePluralFormatTest extends WebTestBase {
$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 554f2ea..b5ae7ae 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 @@ namespace Drupal\menu_link_content\Tests;
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 @@ class MenuLinkContentDeriverTest extends KernelTestBase {
$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('<script>alert("Welcome to the discovered jungle!")</script>', $title);
$this->assertFalse(SafeMarkup::isSafe($title));
diff --git a/core/modules/node/node.tokens.inc b/core/modules/node/node.tokens.inc
index dbe8da2..81fa3f0 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 a99637f..bc6a049 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 @@ class NodeTokenReplaceTest extends TokenReplaceUnitTestBase {
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 81b299f..9908aac 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 @@ class OptionsDefaultFormatter extends FormatterBase {
$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 138d709..586aa88 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 @@ class OptionsKeyFormatter extends FormatterBase {
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 a96f27e..eb75ac3 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 @@ class NumberListField extends NumericArgument {
$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 ddf764a..ee26d43 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 @@ class StringListField extends StringArgument {
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 bf0b62d..ed26a09 100644
--- a/core/modules/quickedit/src/QuickEditController.php
+++ b/core/modules/quickedit/src/QuickEditController.php
@@ -255,7 +255,7 @@ class QuickEditController extends ControllerBase {
* 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 2d3a5b0..0b0e3c6 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\Render\RendererInterface;
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 @@ class RestExport extends PathPluginBase implements ResponseDisplayPluginInterfac
// 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 070a530..0eb4e23 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
index 16b7fcd..761ae44 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 9ef0a66..3d27687 100644
--- a/core/modules/simpletest/src/AssertContentTrait.php
+++ b/core/modules/simpletest/src/AssertContentTrait.php
@@ -178,7 +178,7 @@ trait AssertContentTrait {
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 @@ trait AssertContentTrait {
*
* 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 @@ trait AssertContentTrait {
* 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 @@ trait AssertContentTrait {
/**
* 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 @@ trait AssertContentTrait {
* 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 @@ trait AssertContentTrait {
* 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 @@ trait AssertContentTrait {
* 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 @@ trait AssertContentTrait {
*
* 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 @@ trait AssertContentTrait {
* 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 @@ trait AssertContentTrait {
$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 @@ trait AssertContentTrait {
*
* @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 @@ trait AssertContentTrait {
* 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 102b9d9..d477081 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 @@ use Drupal\Component\Utility\SafeStringInterface;
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 b94afcf..65edaeb 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 @@ abstract class TestBase {
* @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 @@ abstract class TestBase {
* 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 @@ abstract class TestBase {
* 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 @@ abstract class TestBase {
* 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 2fe6f53..f5c90cf 100644
--- a/core/modules/simpletest/src/WebTestBase.php
+++ b/core/modules/simpletest/src/WebTestBase.php
@@ -233,7 +233,7 @@ abstract class WebTestBase extends TestBase {
/**
* 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 @@ abstract class WebTestBase extends TestBase {
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 @@ abstract class WebTestBase extends TestBase {
*/
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 @@ abstract class WebTestBase extends TestBase {
*
* 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 @@ abstract class WebTestBase extends TestBase {
*
* 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 @@ abstract class WebTestBase extends TestBase {
/**
* 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 @@ abstract class WebTestBase extends TestBase {
* 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 @@ abstract class WebTestBase extends TestBase {
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 172474e..835f5c1 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 @@ class AssertHelperTraitTest extends UnitTestCase {
}
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 1b63324..12ae2aa 100644
--- a/core/modules/system/src/Tests/Bootstrap/DrupalSetMessageTest.php
+++ b/core/modules/system/src/Tests/Bootstrap/DrupalSetMessageTest.php
@@ -37,14 +37,14 @@ class DrupalSetMessageTest extends WebTestBase {
$this->assertUniqueText('Non Duplicated message');
$this->assertNoUniqueText('Duplicated message');
- // Ensure SafeString objects are rendered as expected.
- $this->assertRaw('SafeString with <em>markup!</em>');
- $this->assertUniqueText('SafeString with markup!');
+ // Ensure Markup objects are rendered as expected.
+ $this->assertRaw('Markup with <em>markup!</em>');
+ $this->assertUniqueText('Markup with markup!');
$this->assertRaw('SafeString2 with <em>markup!</em>');
// 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('<em>This<span>markup will be</span> escaped</em>.');
diff --git a/core/modules/system/src/Tests/Plugin/Discovery/DiscoveryTestBase.php b/core/modules/system/src/Tests/Plugin/Discovery/DiscoveryTestBase.php
index a06cb7b..b6f5cc1 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 @@ abstract class DiscoveryTestBase extends KernelTestBase {
*/
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 c7af02d..f89d1fa 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 @@ class TokenReplaceUnitTest extends TokenReplaceUnitTestBase {
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 4aafc4f..c47e022 100644
--- a/core/modules/system/src/Tests/Theme/ThemeTest.php
+++ b/core/modules/system/src/Tests/Theme/ThemeTest.php
@@ -13,7 +13,7 @@ use Drupal\test_theme\ThemeClass;
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 @@ class ThemeTest extends WebTestBase {
*/
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 5aaa772..1b3ad2c 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 @@ class MenuTreeSerializationTitleTest extends UpdatePathTestBase {
$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 6ece8ce..47f6dca 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 e21c2c8..7ec8d0f 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 f248191..2a91375 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 @@ namespace Drupal\entity_test\Plugin\Field\FieldType;
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 ec913f3..b31a2bf 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 @@ class MockBlockManager extends PluginManagerBase {
*/
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 15ab478..2b020df 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 @@ namespace Drupal\system_test\Controller;
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 @@ class SystemTestController extends ControllerBase {
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 <em>markup!</em>'));
- // Test duplicate SafeString messages.
- drupal_set_message(SafeString::create('SafeString with <em>markup!</em>'));
- // Ensure that multiple SafeString messages work.
- drupal_set_message(SafeString::create('SafeString2 with <em>markup!</em>'));
+ // Add a Markup message.
+ drupal_set_message(Markup::create('Markup with <em>markup!</em>'));
+ // Test duplicate Markup messages.
+ drupal_set_message(Markup::create('Markup with <em>markup!</em>'));
+ // Ensure that multiple Markup messages work.
+ drupal_set_message(Markup::create('SafeString2 with <em>markup!</em>'));
// 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('<em>This<span>markup will be</span> escaped</em>.');
diff --git a/core/modules/taxonomy/taxonomy.tokens.inc b/core/modules/taxonomy/taxonomy.tokens.inc
index aac7acb..20251f2 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 fd2f032..5a472f4 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 @@ class UserTokenReplaceTest extends WebTestBase {
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 @@ class UserTokenReplaceTest extends WebTestBase {
$input = '[user:display-name] [current-user:display-name]';
$expected = "<em>{$user1->id()}</em> <em>{$user2->id()}</em>";
$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 1b155e0..e252b49 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 @@ class TestTranslationManager implements TranslationInterface {
* {@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 a7f752a..7782954 100644
--- a/core/modules/user/user.module
+++ b/core/modules/user/user.module
@@ -1,7 +1,7 @@
<?php
use Drupal\Component\Utility\Crypt;
-use Drupal\Component\Utility\PlainTextOutput;
+use Drupal\Component\Render\PlainTextOutput;
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Asset\AttachedAssetsInterface;
use Drupal\Core\Cache\Cache;
diff --git a/core/modules/views/src/Entity/View.php b/core/modules/views/src/Entity/View.php
index 0b51a13..d5344f4 100644
--- a/core/modules/views/src/Entity/View.php
+++ b/core/modules/views/src/Entity/View.php
@@ -191,7 +191,7 @@ class View extends ConfigEntityBase implements ViewEntityInterface {
'display_plugin' => $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 e3e5165..3e02fe8 100644
--- a/core/modules/views/src/Plugin/Derivative/ViewsBlock.php
+++ b/core/modules/views/src/Plugin/Derivative/ViewsBlock.php
@@ -9,7 +9,7 @@ namespace Drupal\views\Plugin\Derivative;
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 @@ class ViewsBlock implements ContainerDeriverInterface {
}
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 c6ae4b7..5f9842f 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\Form\FormStateInterface;
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 @@ abstract class HandlerBase extends PluginBase implements ViewsHandlerInterface {
$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 449cc23..cf00382 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\Language\LanguageInterface;
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 @@ abstract class PluginBase extends ComponentPluginBase implements ContainerFactor
// 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 8a23086..ac8aeb2 100644
--- a/core/modules/views/src/Plugin/views/ViewsHandlerInterface.php
+++ b/core/modules/views/src/Plugin/views/ViewsHandlerInterface.php
@@ -75,7 +75,7 @@ interface ViewsHandlerInterface extends ViewsPluginInterface {
* 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 54b7883..854fd4d 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 @@ class FieldList extends NumericArgument {
$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 5b10132..775ccdb 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 @@ namespace Drupal\views\Plugin\views\argument;
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 @@ class ListString extends StringArgument {
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 3a0740d..b4f1405 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 @@ namespace Drupal\views\Plugin\views\field;
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 @@ class Boolean extends FieldPluginBase {
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 975c10d..6836c73 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 @@ interface FieldHandlerInterface extends ViewsHandlerInterface {
* @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 @@ interface FieldHandlerInterface extends ViewsHandlerInterface {
* @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 @@ interface FieldHandlerInterface extends ViewsHandlerInterface {
* - 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 @@ interface FieldHandlerInterface extends ViewsHandlerInterface {
* @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 23eccf2..cc2a151 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 @@ namespace Drupal\views\Plugin\views\field;
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\Render\Renderer;
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 @@ abstract class FieldPluginBase extends HandlerBase implements FieldHandlerInterf
$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 @@ abstract class FieldPluginBase extends HandlerBase implements FieldHandlerInterf
* {@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 @@ abstract class FieldPluginBase extends HandlerBase implements FieldHandlerInterf
// 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 @@ abstract class FieldPluginBase extends HandlerBase implements FieldHandlerInterf
// 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 @@ abstract class FieldPluginBase extends HandlerBase implements FieldHandlerInterf
// \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 e558de3..06f4a66 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 @@ class NumericField extends FieldPluginBase {
// 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 c60df58..1e401ff 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 @@ abstract class FilterPluginBase extends HandlerBase implements CacheablePluginIn
}
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 544ba0e..7ca2cc90 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 @@ abstract class RelationshipPluginBase extends HandlerBase {
// 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 75c8bc7..8614de1 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\Core\Render\Element;
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 @@ abstract class StylePluginBase extends PluginBase {
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 @@ abstract class StylePluginBase extends PluginBase {
* @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
index f0cbd4b..4532b9c 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 @@ use Drupal\Component\Utility\SafeStringTrait;
* 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 a4c1142..d2f3808 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 @@ class FieldApiDataTest extends FieldTestBase {
// 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&quot; 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&quot; 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 c5d69ab..0ef1724 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 @@ class PluginBaseTest extends KernelTestBase {
*/
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 9dfbb06..015c414 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 @@ namespace Drupal\Tests\views\Unit\Plugin\field;
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 @@ class FieldPluginBaseTest extends UnitTestCase {
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 743626b..dd1d196 100644
--- a/core/modules/views/views.module
+++ b/core/modules/views/views.module
@@ -23,7 +23,7 @@ use Drupal\views\Plugin\views\display\Page;
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 2d4a95d..2216835 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 440ee18..1187be5 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 a4a77a6..daf96aa 100644
--- a/core/modules/views_ui/src/ViewListBuilder.php
+++ b/core/modules/views_ui/src/ViewListBuilder.php
@@ -246,7 +246,7 @@ class ViewListBuilder extends ConfigEntityListBuilder {
$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 3ef6162..504675e 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 012ae7b..5a7126d 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\KernelTests\KernelTestBase;
use Drupal\language\Entity\ConfigurableLanguage;
/**
- * Tests the TranslatableString class.
+ * Tests the TranslatableMarkup class.
*
* @group StringTranslation
*/
@@ -36,7 +36,7 @@ class TranslationStringTest extends KernelTestBase {
}
/**
- * 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 f43ea13..efd84ff 100644
--- a/core/tests/Drupal/KernelTests/Core/Theme/ThemeRenderAndAutoescapeTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Theme/ThemeRenderAndAutoescapeTest.php
@@ -10,7 +10,7 @@ namespace Drupal\KernelTests\Core\Theme;
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 @@ class ThemeRenderAndAutoescapeTest extends KernelTestBase {
'int (scalar) cast to string' => [111, '111'],
'float (scalar) cast to string' => [2.10, '2.10'],
'> is escaped' => ['>', '&gt;'],
- 'SafeString EM tag is unchanged' => [SafeString::create('<em>hi</em>'), '<em>hi</em>'],
- 'SafeString SCRIPT tag is unchanged' => [SafeString::create('<script>alert("hi");</script>'), '<script>alert("hi");</script>'],
+ 'Markup EM tag is unchanged' => [Markup::create('<em>hi</em>'), '<em>hi</em>'],
+ 'Markup SCRIPT tag is unchanged' => [Markup::create('<script>alert("hi");</script>'), '<script>alert("hi");</script>'],
'EM tag in string is escaped' => ['<em>hi</em>', Html::escape('<em>hi</em>')],
'type link render array is rendered' => [['#type' => 'link', '#title' => 'Text', '#url' => '<none>'], '<a href="">Text</a>'],
'type markup with EM tags is rendered' => [['#markup' => '<em>hi</em>'], '<em>hi</em>'],
diff --git a/core/tests/Drupal/Tests/Component/Utility/FormattableStringTest.php b/core/tests/Drupal/Tests/Component/Render/FormattableMarkupTest.php
index 670b6e5..30626fd 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 @@ class FormattableStringTest extends UnitTestCase {
*/
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
index a703803..cebdb58 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 @@ class PlainTextOutputTest extends UnitTestCase {
$string = 'The &lt;em&gt; tag makes your text look like <em>"this"</em>.';
$data['escaped-html-with-quotes'] = [$expected, $string];
- $safe_string = $this->prophesize(SafeStringInterface::class);
+ $safe_string = $this->prophesize(MarkupInterface::class);
$safe_string->__toString()->willReturn('<em>"this"</em>');
$safe_string = $safe_string->reveal();
$data['escaped-html-with-quotes-and-placeholders'] = [$expected, 'The @tag tag makes your text look like @result.', ['@tag' =>'<em>', '@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 279bdd4..2210fa8 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 @@ class SafeMarkupTest extends UnitTestCase {
* @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 @@ class SafeMarkupTest extends UnitTestCase {
$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 @@ class SafeMarkupTest extends UnitTestCase {
function providerFormat() {
$tests[] = array('Simple text', array(), 'Simple text', 'SafeMarkup::format leaves simple text alone.', TRUE);
$tests[] = array('Escaped text: @value', array('@value' => '<script>'), 'Escaped text: &lt;script&gt;', 'SafeMarkup::format replaces and escapes string.', TRUE);
- $tests[] = array('Escaped text: @value', array('@value' => SafeMarkupTestSafeString::create('<span>Safe HTML</span>')), 'Escaped text: <span>Safe HTML</span>', 'SafeMarkup::format does not escape an already safe string.', TRUE);
+ $tests[] = array('Escaped text: @value', array('@value' => SafeMarkupTestMarkup::create('<span>Safe HTML</span>')), 'Escaped text: <span>Safe HTML</span>', 'SafeMarkup::format does not escape an already safe string.', TRUE);
$tests[] = array('Placeholder text: %value', array('%value' => '<script>'), 'Placeholder text: <em class="placeholder">&lt;script&gt;</em>', 'SafeMarkup::format replaces, escapes and themes string.', TRUE);
- $tests[] = array('Placeholder text: %value', array('%value' => SafeMarkupTestSafeString::create('<span>Safe HTML</span>')), 'Placeholder text: <em class="placeholder"><span>Safe HTML</span></em>', 'SafeMarkup::format does not escape an already safe string themed as a placeholder.', TRUE);
+ $tests[] = array('Placeholder text: %value', array('%value' => SafeMarkupTestMarkup::create('<span>Safe HTML</span>')), 'Placeholder text: <em class="placeholder"><span>Safe HTML</span></em>', 'SafeMarkup::format does not escape an already safe string themed as a placeholder.', TRUE);
$tests['javascript-protocol-url'] = ['Simple text <a href=":url">giraffe</a>', [':url' => 'javascript://example.com?foo&bar'], 'Simple text <a href="//example.com?foo&amp;bar">giraffe</a>', 'Support for filtering bad protocols', TRUE];
$tests['external-url'] = ['Simple text <a href=":url">giraffe</a>', [':url' => 'http://example.com?foo&bar'], 'Simple text <a href="http://example.com?foo&amp;bar">giraffe</a>', 'Support for filtering bad protocols', TRUE];
@@ -268,9 +268,9 @@ class SafeMarkupTestString {
/**
* Marks text as safe.
*
- * SafeMarkupTestSafeString is used to mark text as safe because
+ * SafeMarkupTestMarkup is used to mark text as safe because
* SafeMarkup::$safeStrings is a global static that affects all tests.
*/
-class SafeMarkupTestSafeString implements SafeStringInterface {
- use SafeStringTrait;
+class SafeMarkupTestMarkup implements MarkupInterface {
+ use MarkupTrait;
}
diff --git a/core/tests/Drupal/Tests/Core/Config/ConfigTest.php b/core/tests/Drupal/Tests/Core/Config/ConfigTest.php
index 39f0638..06c2cbb 100644
--- a/core/tests/Drupal/Tests/Core/Config/ConfigTest.php
+++ b/core/tests/Drupal/Tests/Core/Config/ConfigTest.php
@@ -8,7 +8,7 @@
namespace Drupal\Tests\Core\Config;
use Drupal\Core\DependencyInjection\ContainerBuilder;
-use Drupal\Core\Render\SafeString;
+use Drupal\Core\Render\Markup;
use Drupal\Tests\UnitTestCase;
use Drupal\Core\Config\Config;
use Drupal\Component\Utility\SafeMarkup;
@@ -536,7 +536,7 @@ class ConfigTest extends UnitTestCase {
*/
public function testSafeStringHandling() {
// Safe strings are cast when using ::set().
- $safe_string = SafeString::create('bar');
+ $safe_string = Markup::create('bar');
$this->config->set('foo', $safe_string);
$this->assertSame('bar', $this->config->get('foo'));
$this->config->set('foo', ['bar' => $safe_string]);
diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityTypeTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityTypeTest.php
index 84076c5..6fa1f9c 100644
--- a/core/tests/Drupal/Tests/Core/Entity/EntityTypeTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/EntityTypeTest.php
@@ -9,7 +9,7 @@ namespace Drupal\Tests\Core\Entity;
use Drupal\Core\Entity\EntityType;
use Drupal\Core\Entity\EntityTypeInterface;
-use Drupal\Core\StringTranslation\TranslatableString;
+use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\Core\StringTranslation\TranslationInterface;
use Drupal\Tests\UnitTestCase;
@@ -289,7 +289,7 @@ class EntityTypeTest extends UnitTestCase {
* @covers ::getLabel
*/
public function testGetLabel() {
- $translatable_label = new TranslatableString($this->randomMachineName());
+ $translatable_label = new TranslatableMarkup($this->randomMachineName());
$entity_type = $this->setUpEntityType(array('label' => $translatable_label));
$this->assertSame($translatable_label, $entity_type->getLabel());
@@ -302,7 +302,7 @@ class EntityTypeTest extends UnitTestCase {
* @covers ::getGroupLabel
*/
public function testGetGroupLabel() {
- $translatable_group_label = new TranslatableString($this->randomMachineName());
+ $translatable_group_label = new TranslatableMarkup($this->randomMachineName());
$entity_type = $this->setUpEntityType(array('group_label' => $translatable_group_label));
$this->assertSame($translatable_group_label, $entity_type->getGroupLabel());
@@ -310,7 +310,7 @@ class EntityTypeTest extends UnitTestCase {
$entity_type = $this->setUpEntityType(array('group_label' => $default_label));
$this->assertSame($default_label, $entity_type->getGroupLabel());
- $default_label = new TranslatableString('Other', array(), array('context' => 'Entity type group'));
+ $default_label = new TranslatableMarkup('Other', array(), array('context' => 'Entity type group'));
$entity_type = $this->setUpEntityType([]);
$string_translation = $this->getMock(TranslationInterface::class);
diff --git a/core/tests/Drupal/Tests/Core/Field/FieldFilteredStringTest.php b/core/tests/Drupal/Tests/Core/Field/FieldFilteredMarkupTest.php
index bbcc692..c3a6e87 100644
--- a/core/tests/Drupal/Tests/Core/Field/FieldFilteredStringTest.php
+++ b/core/tests/Drupal/Tests/Core/Field/FieldFilteredMarkupTest.php
@@ -2,30 +2,30 @@
/**
* @file
- * Contains \Drupal\Tests\Core\Field\FieldFilteredStringTest.
+ * Contains \Drupal\Tests\Core\Field\FieldFilteredMarkupTest.
*/
namespace Drupal\Tests\Core\Field;
use Drupal\Tests\UnitTestCase;
-use Drupal\Core\Field\FieldFilteredString;
-use Drupal\Component\Utility\SafeStringInterface;
+use Drupal\Core\Field\FieldFilteredMarkup;
+use Drupal\Component\Render\MarkupInterface;
/**
- * @coversDefaultClass \Drupal\Core\Field\FieldFilteredString
+ * @coversDefaultClass \Drupal\Core\Field\FieldFilteredMarkup
* @group Field
*/
-class FieldFilteredStringTest extends UnitTestCase {
+class FieldFilteredMarkupTest extends UnitTestCase {
/**
* @covers ::create
* @dataProvider providerTestCreate
*/
public function testCreate($string, $expected, $instance_of_check) {
- $filtered_string = FieldFilteredString::create($string);
+ $filtered_string = FieldFilteredMarkup::create($string);
if ($instance_of_check) {
- $this->assertInstanceOf(FieldFilteredString::class, $filtered_string);
+ $this->assertInstanceOf(FieldFilteredMarkup::class, $filtered_string);
}
$this->assertSame($expected, (string) $filtered_string);
}
@@ -44,7 +44,7 @@ class FieldFilteredStringTest extends UnitTestCase {
$data[] = ['<em>teststring', '<em>teststring</em>', TRUE];
// Even safe strings will be escaped.
- $safe_string = $this->prophesize(SafeStringInterface::class);
+ $safe_string = $this->prophesize(MarkupInterface::class);
$safe_string->__toString()->willReturn('<script>teststring</script>');
$data[] = [$safe_string->reveal(), 'teststring', TRUE];
@@ -57,7 +57,7 @@ class FieldFilteredStringTest extends UnitTestCase {
public function testdisplayAllowedTags() {
$expected = '<a> <b> <big> <code> <del> <em> <i> <ins> <pre> <q> <small> <span> <strong> <sub> <sup> <tt> <ol> <ul> <li> <p> <br> <img>';
- $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 6ac118a..7a90abb 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 @@ class ContextualLinkDefaultTest extends UnitTestCase {
*/
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 @@ class ContextualLinkDefaultTest extends UnitTestCase {
*/
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 @@ class ContextualLinkDefaultTest extends UnitTestCase {
*/
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 25bf093..1d1c4dd 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 @@ class LocalActionDefaultTest extends UnitTestCase {
* @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 @@ class LocalActionDefaultTest extends UnitTestCase {
* @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 @@ class LocalActionDefaultTest extends UnitTestCase {
* 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 51ff248..005add6 100644
--- a/core/tests/Drupal/Tests/Core/Menu/LocalTaskDefaultTest.php
+++ b/core/tests/Drupal/Tests/Core/Menu/LocalTaskDefaultTest.php
@@ -10,7 +10,7 @@ namespace Drupal\Tests\Core\Menu;
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 @@ class LocalTaskDefaultTest extends UnitTestCase {
* @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 @@ class LocalTaskDefaultTest extends UnitTestCase {
*/
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 @@ class LocalTaskDefaultTest extends UnitTestCase {
* @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 32144f3..0dd3ab3 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 @@ EOS;
$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 a83b825..fdd4e28 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 @@ class HtmlTagTest extends UnitTestCase {
// Ensure that #value is not filtered if it is marked as safe.
$element = array(
'#tag' => 'p',
- '#value' => SafeString::create('<script>value</script>'),
+ '#value' => Markup::create('<script>value</script>'),
);
$tags[] = array($element, "<p><script>value</script></p>\n");
@@ -106,8 +106,8 @@ class HtmlTagTest extends UnitTestCase {
*/
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 4f3e9c9..649a57f 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 @@ namespace Drupal\Tests\Core\Render\Element;
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 @@ class TableSelectTest extends UnitTestCase {
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 e2bc876..d32ba5a 100644
--- a/core/tests/Drupal/Tests/Core/Render/RendererPlaceholdersTest.php
+++ b/core/tests/Drupal/Tests/Core/Render/RendererPlaceholdersTest.php
@@ -10,7 +10,7 @@ namespace Drupal\Tests\Core\Render;
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 @@ class RendererPlaceholdersTest extends RendererTestBase {
$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('<drupal-render-placeholder callback="Drupal\Tests\Core\Render\PlaceholdersTest::callback" arguments="' . '0=' . $args[0] . '" token="' . $token . '"></drupal-render-placeholder>');
+ return Markup::create('<drupal-render-placeholder callback="Drupal\Tests\Core\Render\PlaceholdersTest::callback" arguments="' . '0=' . $args[0] . '" token="' . $token . '"></drupal-render-placeholder>');
};
$extract_placeholder_render_array = function ($placeholder_render_array) {
@@ -852,7 +852,7 @@ class RendererPlaceholdersTest extends RendererTestBase {
]];
$result = $this->renderer->renderRoot($element);
- $this->assertInstanceOf('\Drupal\Core\Render\SafeString', $result);
+ $this->assertInstanceOf('\Drupal\Core\Render\Markup', $result);
$this->assertEquals('<p>This is a rendered placeholder!</p>', (string) $result);
}
diff --git a/core/tests/Drupal/Tests/Core/Render/RendererTest.php b/core/tests/Drupal/Tests/Core/Render/RendererTest.php
index 4d0dec5..673b78d 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\Access\AccessResultInterface;
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 @@ class RendererTest extends RendererTestBase {
], '&lt;em&gt;foo&lt;/em&gt;'];
// Safe strings in #plain_text are are still escaped.
$data[] = [[
- '#plain_text' => SafeString::create('<em>foo</em>'),
+ '#plain_text' => Markup::create('<em>foo</em>'),
], '&lt;em&gt;foo&lt;/em&gt;'];
// Renderable child element.
$data[] = [[
@@ -737,10 +737,10 @@ class RendererTest extends RendererTestBase {
],
// 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
index 862a78a..0b243cc 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 @@ class TranslatableStringTest extends UnitTestCase {
$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 @@ class TranslatableStringTest extends UnitTestCase {
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 730437b..305963d 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 @@ class TranslationManagerTest extends UnitTestCase {
*/
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 fba7786..69941a9 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 @@ class AttributeTest extends UnitTestCase {
$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 @@ class AttributeTest extends UnitTestCase {
$data = [];
$string = '"> <script>alert(123)</script>"';
- $data['safe-object-xss1'] = [['title' => SafeString::create($string)], ' title="&quot;&gt; alert(123)&quot;"'];
+ $data['safe-object-xss1'] = [['title' => Markup::create($string)], ' title="&quot;&gt; alert(123)&quot;"'];
$data['non-safe-object-xss1'] = [['title' => $string], ' title="' . Html::escape($string) . '"'];
$string = '&quot;><script>alert(123)</script>';
- $data['safe-object-xss2'] = [['title' => SafeString::create($string)], ' title="&quot;&gt;alert(123)"'];
+ $data['safe-object-xss2'] = [['title' => Markup::create($string)], ' title="&quot;&gt;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 d01641b..13f4639 100644
--- a/core/tests/Drupal/Tests/Core/Template/TwigExtensionTest.php
+++ b/core/tests/Drupal/Tests/Core/Template/TwigExtensionTest.php
@@ -126,7 +126,7 @@ class TwigExtensionTest extends UnitTestCase {
}
/**
- * Tests the escaping of objects implementing SafeStringInterface.
+ * Tests the escaping of objects implementing MarkupInterface.
*
* @covers ::escapeFilter
*/
@@ -141,11 +141,11 @@ class TwigExtensionTest extends UnitTestCase {
$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("<script>alert('here');</script>");
$this->assertSame('&lt;script&gt;alert(&#039;here&#039;);&lt;/script&gt;', $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 05f1af1..e2ffb80 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 @@ class LinkGeneratorTest extends UnitTestCase {
), $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('<em>HTML output</em>'), $url);
+ $result = $this->linkGenerator->generate(Markup::create('<em>HTML output</em>'), $url);
$this->assertLink(array(
'attributes' => array('href' => '/test-route-5'),
'child' => array(
@@ -499,12 +499,12 @@ class LinkGeneratorTest extends UnitTestCase {
* 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 e902134..60e378f 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\Cache\Context\CacheContextsManager;
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 @@ class TokenTest extends UnitTestCase {
$data['simple-placeholder-with-safe-html'] = [
'<h1>[token:meh]</h1>',
- ['[token:meh]' => SafeString::create('<em>Emphasized</em>')],
+ ['[token:meh]' => Markup::create('<em>Emphasized</em>')],
'<h1><em>Emphasized</em></h1>',
];
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 1183a2b..34df3ef 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\Plugin\DataType\Uri;
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 @@ class PrimitiveTypeConstraintValidatorTest extends UnitTestCase {
$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 63098bb..64b6317 100644
--- a/core/tests/Drupal/Tests/UnitTestCase.php
+++ b/core/tests/Drupal/Tests/UnitTestCase.php
@@ -12,8 +12,8 @@ use Drupal\Component\Utility\Random;
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 @@ abstract class UnitTestCase extends \PHPUnit_Framework_TestCase {
$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 977f094..44ee5ac 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<!-- END OUTPUT from '" . Html::escape($template_file) . "' -->\n\n";
}
// This output has already been rendered and is therefore considered safe.
- return SafeString::create(implode('', $output));
+ return Markup::create(implode('', $output));
}
/**