Commit 45bc0552 authored by catch's avatar catch

Issue #2958429 by alexpott: Properly deprecate SafeMarkup::format()

parent 2e8be78f
......@@ -7,7 +7,7 @@
use Drupal\Component\Utility\Crypt;
use Drupal\Component\Utility\Html;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Config\BootstrapConfigStorageFactory;
use Drupal\Core\Logger\RfcLogLevel;
......@@ -273,7 +273,7 @@ function drupal_get_filename($type, $name, $filename = NULL) {
}
}
// If the filename is still unknown, create a user-level error message.
trigger_error(SafeMarkup::format('The following @type is missing from the file system: @name', ['@type' => $type, '@name' => $name]), E_USER_WARNING);
trigger_error(new FormattableMarkup('The following @type is missing from the file system: @name', ['@type' => $type, '@name' => $name]), E_USER_WARNING);
}
/**
......@@ -349,7 +349,7 @@ function t($string, array $args = [], array $options = []) {
* @see https://www.drupal.org/node/2302363
*/
function format_string($string, array $args) {
return SafeMarkup::format($string, $args);
return new FormattableMarkup($string, $args);
}
/**
......@@ -981,10 +981,10 @@ function drupal_static_reset($name = NULL) {
* Formats text for emphasized display in a placeholder inside a sentence.
*
* @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0. Use
* \Drupal\Component\Utility\SafeMarkup::format() or Twig's "placeholder"
* filter instead. Note this method should not be used to simply emphasize a
* string and therefore has few valid use-cases. Note also, that this method
* does not mark the string as safe.
* \Drupal\Component\Render\FormattableMarkup or Twig's "placeholder" filter
* instead. Note this method should not be used to simply emphasize a string
* and therefore has few valid use-cases. Note also, that this method does not
* mark the string as safe.
*
* @see https://www.drupal.org/node/2302363
*/
......
......@@ -215,7 +215,7 @@ function valid_email_address($mail) {
* @deprecated in Drupal 8.0.x-dev, will be removed before Drupal 9.0.0.
* Use UrlHelper::stripDangerousProtocols() or UrlHelper::filterBadProtocol()
* instead. UrlHelper::stripDangerousProtocols() can be used in conjunction
* with \Drupal\Component\Utility\SafeMarkup::format() and an @variable
* with \Drupal\Component\Render\FormattableMarkup and an @variable
* placeholder which will perform the necessary escaping.
* UrlHelper::filterBadProtocol() is functionality equivalent to check_url()
* apart from the fact it is protected from double escaping bugs. Note that
......
......@@ -5,7 +5,7 @@
* Functions for error handling.
*/
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\Component\Utility\Xss;
use Drupal\Core\Logger\RfcLogLevel;
use Drupal\Core\Render\Markup;
......@@ -178,7 +178,7 @@ function _drupal_log_error($error, $fatal = FALSE) {
if ($fatal) {
// When called from CLI, simply output a plain text message.
// Should not translate the string to avoid errors producing more errors.
$response->setContent(html_entity_decode(strip_tags(SafeMarkup::format('%type: @message in %function (line %line of %file).', $error))) . "\n");
$response->setContent(html_entity_decode(strip_tags(new FormattableMarkup('%type: @message in %function (line %line of %file).', $error))) . "\n");
$response->send();
exit;
}
......@@ -189,7 +189,7 @@ function _drupal_log_error($error, $fatal = FALSE) {
if (error_displayable($error)) {
// When called from JavaScript, simply output the error message.
// Should not translate the string to avoid errors producing more errors.
$response->setContent(SafeMarkup::format('%type: @message in %function (line %line of %file).', $error));
$response->setContent(new FormattableMarkup('%type: @message in %function (line %line of %file).', $error));
$response->send();
}
exit;
......@@ -226,10 +226,10 @@ function _drupal_log_error($error, $fatal = FALSE) {
if ($error_level != ERROR_REPORTING_DISPLAY_VERBOSE) {
// Without verbose logging, use a simple message.
// We call SafeMarkup::format() directly here, rather than use t() since
// we are in the middle of error handling, and we don't want t() to
// cause further errors.
$message = SafeMarkup::format('%type: @message in %function (line %line of %file).', $error);
// We use \Drupal\Component\Render\FormattableMarkup directly here,
// rather than use t() since we are in the middle of error handling, and
// we don't want t() to cause further errors.
$message = new FormattableMarkup('%type: @message in %function (line %line of %file).', $error);
}
else {
// With verbose logging, we will also include a backtrace.
......@@ -241,7 +241,7 @@ function _drupal_log_error($error, $fatal = FALSE) {
array_shift($backtrace);
// Generate a backtrace containing only scalar argument values.
$error['@backtrace'] = Error::formatBacktrace($backtrace);
$message = SafeMarkup::format('%type: @message in %function (line %line of %file). <pre class="backtrace">@backtrace</pre>', $error);
$message = new FormattableMarkup('%type: @message in %function (line %line of %file). <pre class="backtrace">@backtrace</pre>', $error);
}
}
......
......@@ -10,7 +10,7 @@
* @{
*/
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\Core\Render\Element;
/**
......@@ -36,7 +36,7 @@ function template_preprocess_menu_local_task(&$variables) {
$variables['is_active'] = TRUE;
// Add text to indicate active tab for non-visual users.
$active = SafeMarkup::format('<span class="visually-hidden">@label</span>', ['@label' => t('(active tab)')]);
$active = new FormattableMarkup('<span class="visually-hidden">@label</span>', ['@label' => t('(active tab)')]);
$link_text = t('@local-task-title@active', ['@local-task-title' => $link_text, '@active' => $active]);
}
......
......@@ -9,7 +9,7 @@
* column.
*/
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\Core\Url;
use Drupal\Component\Utility\UrlHelper;
......@@ -60,7 +60,7 @@ function tablesort_header(&$cell_content, array &$cell_attributes, array $header
$ts['sort'] = 'asc';
$image = '';
}
$cell_content = \Drupal::l(SafeMarkup::format('@cell_content@image', ['@cell_content' => $cell_content, '@image' => $image]), new Url('<current>', [], [
$cell_content = \Drupal::l(new FormattableMarkup('@cell_content@image', ['@cell_content' => $cell_content, '@image' => $image]), new Url('<current>', [], [
'attributes' => ['title' => $title],
'query' => array_merge($ts['query'], [
'sort' => $ts['sort'],
......
......@@ -2,7 +2,7 @@
namespace Drupal\Component\Gettext;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Component\Render\FormattableMarkup;
/**
* Implements Gettext PO stream reader.
......@@ -290,7 +290,7 @@ private function readLine() {
}
else {
// A comment following any other context is a syntax error.
$this->errors[] = SafeMarkup::format('The translation stream %uri contains an error: "msgstr" was expected but not found on line %line.', $log_vars);
$this->errors[] = new FormattableMarkup('The translation stream %uri contains an error: "msgstr" was expected but not found on line %line.', $log_vars);
return FALSE;
}
return;
......@@ -300,7 +300,7 @@ private function readLine() {
if ($this->context != 'MSGID') {
// A plural form can only be added to an msgid directly.
$this->errors[] = SafeMarkup::format('The translation stream %uri contains an error: "msgid_plural" was expected but not found on line %line.', $log_vars);
$this->errors[] = new FormattableMarkup('The translation stream %uri contains an error: "msgid_plural" was expected but not found on line %line.', $log_vars);
return FALSE;
}
......@@ -311,7 +311,7 @@ private function readLine() {
$quoted = $this->parseQuoted($line);
if ($quoted === FALSE) {
// The plural form must be wrapped in quotes.
$this->errors[] = SafeMarkup::format('The translation stream %uri contains a syntax error on line %line.', $log_vars);
$this->errors[] = new FormattableMarkup('The translation stream %uri contains a syntax error on line %line.', $log_vars);
return FALSE;
}
......@@ -338,7 +338,7 @@ private function readLine() {
}
elseif ($this->context == 'MSGID') {
// We are currently already in the context, meaning we passed an id with no data.
$this->errors[] = SafeMarkup::format('The translation stream %uri contains an error: "msgid" is unexpected on line %line.', $log_vars);
$this->errors[] = new FormattableMarkup('The translation stream %uri contains an error: "msgid" is unexpected on line %line.', $log_vars);
return FALSE;
}
......@@ -349,7 +349,7 @@ private function readLine() {
$quoted = $this->parseQuoted($line);
if ($quoted === FALSE) {
// The message id must be wrapped in quotes.
$this->errors[] = SafeMarkup::format('The translation stream %uri contains an error: invalid format for "msgid" on line %line.', $log_vars, $log_vars);
$this->errors[] = new FormattableMarkup('The translation stream %uri contains an error: invalid format for "msgid" on line %line.', $log_vars, $log_vars);
return FALSE;
}
......@@ -367,7 +367,7 @@ private function readLine() {
}
elseif (!empty($this->currentItem['msgctxt'])) {
// A context cannot apply to another context.
$this->errors[] = SafeMarkup::format('The translation stream %uri contains an error: "msgctxt" is unexpected on line %line.', $log_vars);
$this->errors[] = new FormattableMarkup('The translation stream %uri contains an error: "msgctxt" is unexpected on line %line.', $log_vars);
return FALSE;
}
......@@ -378,7 +378,7 @@ private function readLine() {
$quoted = $this->parseQuoted($line);
if ($quoted === FALSE) {
// The context string must be quoted.
$this->errors[] = SafeMarkup::format('The translation stream %uri contains an error: invalid format for "msgctxt" on line %line.', $log_vars);
$this->errors[] = new FormattableMarkup('The translation stream %uri contains an error: invalid format for "msgctxt" on line %line.', $log_vars);
return FALSE;
}
......@@ -396,13 +396,13 @@ private function readLine() {
($this->context != 'MSGSTR_ARR')) {
// Plural message strings must come after msgid, msgxtxt,
// msgid_plural, or other msgstr[] entries.
$this->errors[] = SafeMarkup::format('The translation stream %uri contains an error: "msgstr[]" is unexpected on line %line.', $log_vars);
$this->errors[] = new FormattableMarkup('The translation stream %uri contains an error: "msgstr[]" is unexpected on line %line.', $log_vars);
return FALSE;
}
// Ensure the plurality is terminated.
if (strpos($line, ']') === FALSE) {
$this->errors[] = SafeMarkup::format('The translation stream %uri contains an error: invalid format for "msgstr[]" on line %line.', $log_vars);
$this->errors[] = new FormattableMarkup('The translation stream %uri contains an error: invalid format for "msgstr[]" on line %line.', $log_vars);
return FALSE;
}
......@@ -417,7 +417,7 @@ private function readLine() {
$quoted = $this->parseQuoted($line);
if ($quoted === FALSE) {
// The string must be quoted.
$this->errors[] = SafeMarkup::format('The translation stream %uri contains an error: invalid format for "msgstr[]" on line %line.', $log_vars);
$this->errors[] = new FormattableMarkup('The translation stream %uri contains an error: invalid format for "msgstr[]" on line %line.', $log_vars);
return FALSE;
}
if (!isset($this->currentItem['msgstr']) || !is_array($this->currentItem['msgstr'])) {
......@@ -434,7 +434,7 @@ private function readLine() {
if (($this->context != 'MSGID') && ($this->context != 'MSGCTXT')) {
// Strings are only valid within an id or context scope.
$this->errors[] = SafeMarkup::format('The translation stream %uri contains an error: "msgstr" is unexpected on line %line.', $log_vars);
$this->errors[] = new FormattableMarkup('The translation stream %uri contains an error: "msgstr" is unexpected on line %line.', $log_vars);
return FALSE;
}
......@@ -445,7 +445,7 @@ private function readLine() {
$quoted = $this->parseQuoted($line);
if ($quoted === FALSE) {
// The string must be quoted.
$this->errors[] = SafeMarkup::format('The translation stream %uri contains an error: invalid format for "msgstr" on line %line.', $log_vars);
$this->errors[] = new FormattableMarkup('The translation stream %uri contains an error: invalid format for "msgstr" on line %line.', $log_vars);
return FALSE;
}
......@@ -460,7 +460,7 @@ private function readLine() {
$quoted = $this->parseQuoted($line);
if ($quoted === FALSE) {
// This string must be quoted.
$this->errors[] = SafeMarkup::format('The translation stream %uri contains an error: string continuation expected on line %line.', $log_vars);
$this->errors[] = new FormattableMarkup('The translation stream %uri contains an error: string continuation expected on line %line.', $log_vars);
return FALSE;
}
......@@ -490,7 +490,7 @@ private function readLine() {
}
else {
// No valid context to append to.
$this->errors[] = SafeMarkup::format('The translation stream %uri contains an error: unexpected string on line %line.', $log_vars);
$this->errors[] = new FormattableMarkup('The translation stream %uri contains an error: unexpected string on line %line.', $log_vars);
return FALSE;
}
return;
......@@ -503,7 +503,7 @@ private function readLine() {
$this->currentItem = [];
}
elseif ($this->context != 'COMMENT') {
$this->errors[] = SafeMarkup::format('The translation stream %uri ended unexpectedly at line %line.', $log_vars);
$this->errors[] = new FormattableMarkup('The translation stream %uri ended unexpectedly at line %line.', $log_vars);
return FALSE;
}
......
......@@ -95,6 +95,7 @@ public static function checkPlain($text) {
* @see https://www.drupal.org/node/2549395
*/
public static function format($string, array $args) {
@trigger_error('SafeMarkup::format() is scheduled for removal in Drupal 9.0.0. Use \Drupal\Component\Render\FormattableMarkup. See https://www.drupal.org/node/2549395.', E_USER_DEPRECATED);
return new FormattableMarkup($string, $args);
}
......
......@@ -3,7 +3,7 @@
namespace Drupal\Core\Config\Development;
use Drupal\Component\Utility\Crypt;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\Core\Config\ConfigCrudEvent;
use Drupal\Core\Config\ConfigEvents;
use Drupal\Core\Config\Schema\SchemaCheckTrait;
......@@ -90,7 +90,7 @@ public function onConfigSave(ConfigCrudEvent $event) {
elseif (is_array($errors)) {
$text_errors = [];
foreach ($errors as $key => $error) {
$text_errors[] = SafeMarkup::format('@key @error', ['@key' => $key, '@error' => $error]);
$text_errors[] = new FormattableMarkup('@key @error', ['@key' => $key, '@error' => $error]);
}
throw new SchemaIncompleteException("Schema errors for $name with the following errors: " . implode(', ', $text_errors));
}
......
......@@ -2,7 +2,7 @@
namespace Drupal\Core\Config;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Component\Render\FormattableMarkup;
/**
* An exception thrown if configuration with the same name already exists.
......@@ -56,7 +56,7 @@ public function getExtension() {
* @return \Drupal\Core\Config\PreExistingConfigException
*/
public static function create($extension, array $config_objects) {
$message = SafeMarkup::format('Configuration objects (@config_names) provided by @extension already exist in active configuration',
$message = new FormattableMarkup('Configuration objects (@config_names) provided by @extension already exist in active configuration',
[
'@config_names' => implode(', ', static::flattenConfigObjects($config_objects)),
'@extension' => $extension
......
......@@ -2,7 +2,7 @@
namespace Drupal\Core\Entity;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\Core\Entity\Plugin\DataType\EntityReference;
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\Core\Field\ChangedFieldItemList;
......@@ -799,7 +799,7 @@ public function onChange($name) {
// Update the default internal language cache.
$this->setDefaultLangcode();
if (isset($this->translations[$this->defaultLangcode])) {
$message = SafeMarkup::format('A translation already exists for the specified language (@langcode).', ['@langcode' => $this->defaultLangcode]);
$message = new FormattableMarkup('A translation already exists for the specified language (@langcode).', ['@langcode' => $this->defaultLangcode]);
throw new \InvalidArgumentException($message);
}
$this->updateFieldLangcodes($this->defaultLangcode);
......@@ -810,7 +810,7 @@ public function onChange($name) {
$items = $this->get($this->langcodeKey);
if ($items->value != $this->activeLangcode) {
$items->setValue($this->activeLangcode, FALSE);
$message = SafeMarkup::format('The translation language cannot be changed (@langcode).', ['@langcode' => $this->activeLangcode]);
$message = new FormattableMarkup('The translation language cannot be changed (@langcode).', ['@langcode' => $this->activeLangcode]);
throw new \LogicException($message);
}
}
......@@ -821,7 +821,7 @@ public function onChange($name) {
// read-only. See https://www.drupal.org/node/2443991.
if (isset($this->values[$this->defaultLangcodeKey]) && $this->get($this->defaultLangcodeKey)->value != $this->isDefaultTranslation()) {
$this->get($this->defaultLangcodeKey)->setValue($this->isDefaultTranslation(), FALSE);
$message = SafeMarkup::format('The default translation flag cannot be changed (@langcode).', ['@langcode' => $this->activeLangcode]);
$message = new FormattableMarkup('The default translation flag cannot be changed (@langcode).', ['@langcode' => $this->activeLangcode]);
throw new \LogicException($message);
}
break;
......
......@@ -2,7 +2,7 @@
namespace Drupal\Core\EventSubscriber;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Core\Utility\Error;
......@@ -98,10 +98,10 @@ public function onException(GetResponseForExceptionEvent $event) {
if (!$this->isErrorLevelVerbose()) {
// Without verbose logging, use a simple message.
// We call SafeMarkup::format directly here, rather than use t() since
// we are in the middle of error handling, and we don't want t() to
// cause further errors.
$message = SafeMarkup::format('%type: @message in %function (line %line of %file).', $error);
// We use \Drupal\Component\Render\FormattableMarkup directly here,
// rather than use t() since we are in the middle of error handling, and
// we don't want t() to cause further errors.
$message = new FormattableMarkup('%type: @message in %function (line %line of %file).', $error);
}
else {
// With verbose logging, we will also include a backtrace.
......@@ -119,7 +119,7 @@ public function onException(GetResponseForExceptionEvent $event) {
// Generate a backtrace containing only scalar argument values.
$error['@backtrace'] = Error::formatBacktrace($backtrace);
$message = SafeMarkup::format('%type: @message in %function (line %line of %file). <pre class="backtrace">@backtrace</pre>', $error);
$message = new FormattableMarkup('%type: @message in %function (line %line of %file). <pre class="backtrace">@backtrace</pre>', $error);
}
}
......
......@@ -2,7 +2,7 @@
namespace Drupal\Core\EventSubscriber;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Render\BareHtmlPageRendererInterface;
use Drupal\Core\Messenger\MessengerInterface;
......@@ -146,7 +146,7 @@ public function onKernelRequestMaintenance(GetResponseEvent $event) {
* The formatted site maintenance message.
*/
protected function getSiteMaintenanceMessage() {
return SafeMarkup::format($this->config->get('system.maintenance')->get('message'), [
return new FormattableMarkup($this->config->get('system.maintenance')->get('message'), [
'@site' => $this->config->get('system.site')->get('name'),
]);
}
......
......@@ -2,7 +2,7 @@
namespace Drupal\Core\Field\Plugin\Field\FieldFormatter;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Datetime\DateFormatterInterface;
use Drupal\Core\Field\FieldDefinitionInterface;
......@@ -187,13 +187,13 @@ protected function formatTimestamp($timestamp) {
if ($this->request->server->get('REQUEST_TIME') > $timestamp) {
$result = $this->dateFormatter->formatTimeDiffSince($timestamp, $options);
$build = [
'#markup' => SafeMarkup::format($this->getSetting('past_format'), ['@interval' => $result->getString()]),
'#markup' => new FormattableMarkup($this->getSetting('past_format'), ['@interval' => $result->getString()]),
];
}
else {
$result = $this->dateFormatter->formatTimeDiffUntil($timestamp, $options);
$build = [
'#markup' => SafeMarkup::format($this->getSetting('future_format'), ['@interval' => $result->getString()]),
'#markup' => new FormattableMarkup($this->getSetting('future_format'), ['@interval' => $result->getString()]),
];
}
CacheableMetadata::createFromObject($result)->applyTo($build);
......
......@@ -7,7 +7,7 @@
use Drupal\Core\Plugin\DefaultPluginManager;
use Drupal\Component\Plugin\Exception\PluginNotFoundException;
use Drupal\Component\Plugin\Factory\DefaultFactory;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Component\Render\FormattableMarkup;
use Psr\Log\LoggerInterface;
/**
......@@ -91,7 +91,7 @@ function ($definition) use ($toolkit_id, $operation) {
return $this->getToolkitOperationPluginId($base_toolkit, $operation);
}
$message = SafeMarkup::format("No image operation plugin for '@toolkit' toolkit and '@operation' operation.", ['@toolkit' => $toolkit_id, '@operation' => $operation]);
$message = new FormattableMarkup("No image operation plugin for '@toolkit' toolkit and '@operation' operation.", ['@toolkit' => $toolkit_id, '@operation' => $operation]);
throw new PluginNotFoundException($toolkit_id . '.' . $operation, $message);
}
else {
......
......@@ -16,7 +16,7 @@ public function parseMessagePlaceholders(&$message, array &$context) {
if (($start = strpos($message, '{')) !== FALSE && strpos($message, '}') > $start) {
$has_psr3 = TRUE;
// Transform PSR3 style messages containing placeholders to
// \Drupal\Component\Utility\SafeMarkup::format() style.
// \Drupal\Component\Render\FormattableMarkup style.
$message = preg_replace('/\{(.*)\}/U', '@$1', $message);
}
foreach ($context as $key => $variable) {
......@@ -30,7 +30,7 @@ public function parseMessagePlaceholders(&$message, array &$context) {
}
}
if (!empty($key) && ($key[0] === '@' || $key[0] === '%' || $key[0] === '!')) {
// The key is now in \Drupal\Component\Utility\SafeMarkup::format() style.
// The key is now in \Drupal\Component\Render\FormattableMarkup style.
$variables[$key] = $variable;
}
}
......
......@@ -15,14 +15,15 @@ interface LogMessageParserInterface {
* - PSR3 format:
* @see https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md#12-message
* - Drupal specific string placeholder format:
* @see \Drupal\Component\Utility\SafeMarkup::format()
* @see \Drupal\Component\Render\FormattableMarkup
*
* Values in PSR3 format will be transformed to SafeMarkup::format() format.
* Values in PSR3 format will be transformed to
* \Drupal\Component\Render\FormattableMarkup format.
*
* @param string $message
* The message that contains the placeholders.
* If the message is in PSR3 style, it will be transformed to
* \Drupal\Component\Utility\SafeMarkup::format() style.
* \Drupal\Component\Render\FormattableMarkup style.
* @param array $context
* An array that may or may not contain placeholder variables.
*
......
......@@ -450,7 +450,7 @@ function hook_system_breadcrumb_alter(\Drupal\Core\Breadcrumb\Breadcrumb &$bread
* The following keys can be altered:
* - text: The link text for the anchor tag. If the hook implementation
* changes this text it needs to preserve the safeness of the original text.
* Using t() or \Drupal\Component\Utility\SafeMarkup::format() with
* Using t() or \Drupal\Component\Render\FormattableMarkup with
* @placeholder is recommended as this will escape the original text if
* necessary. If the resulting text is not marked safe it will be escaped.
* - url_is_active: Whether or not the link points to the currently active
......
......@@ -2,7 +2,7 @@
namespace Drupal\Core\Render;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\Core\Access\AccessResultInterface;
/**
......@@ -94,7 +94,7 @@ public static function children(array &$elements, $sort = FALSE) {
// Only trigger an error if the value is not null.
// @see https://www.drupal.org/node/1283892
elseif (isset($value)) {
trigger_error(SafeMarkup::format('"@key" is an invalid render array key', ['@key' => $key]), E_USER_ERROR);
trigger_error(new FormattableMarkup('"@key" is an invalid render array key', ['@key' => $key]), E_USER_ERROR);
}
}
$i++;
......
......@@ -81,7 +81,7 @@ public function __construct($count, $singular, $plural, array $args = [], array
* An associative array of replacements to make after translation. Instances
* of any key in this array are replaced with the corresponding value.
* Based on the first character of the key, the value is escaped and/or
* themed. See \Drupal\Component\Utility\SafeMarkup::format(). Note that you
* themed. See \Drupal\Component\Render\FormattableMarkup. Note that you
* do not need to include @count in this array; this replacement is done
* automatically for the plural cases.
* @param array $options
......
......@@ -93,7 +93,7 @@ public function translateString(TranslatableMarkup $translated_string);
* An associative array of replacements to make after translation. Instances
* of any key in this array are replaced with the corresponding value.
* Based on the first character of the key, the value is escaped and/or
* themed. See \Drupal\Component\Utility\SafeMarkup::format(). Note that you do
* themed. See \Drupal\Component\Render\FormattableMarkup. Note that you do
* not need to include @count in this array; this replacement is done
* automatically for the plural cases.
* @param array $options
......@@ -104,7 +104,7 @@ public function translateString(TranslatableMarkup $translated_string);
*
* @see \Drupal\Core\StringTranslation\TranslationInterface::translate()
* @see t()
* @see \Drupal\Component\Utility\SafeMarkup::format()
* @see \Drupal\Component\Render\FormattableMarkup
* @see \Drupal\Core\StringTranslation\PluralTranslatableMarkup::createFromTranslatedString()
*/
public function formatPlural($count, $singular, $plural, array $args = [], array $options = []);
......
......@@ -45,7 +45,7 @@ protected function getMails(array $filter = []) {
* Value of the field to assert.
* @param string $message
* (optional) A message to display with the assertion. Do not translate
* messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
* messages: use \Drupal\Component\Render\FormattableMarkup to embed
* variables in the message text, not t(). If left blank, a default message
* will be displayed.
* @param string $group
......@@ -74,7 +74,7 @@ protected function assertMail($name, $value = '', $message = '', $group = 'Email
* Number of emails to search for string, starting with most recent.
* @param string $message
* (optional) A message to display with the assertion. Do not translate
* messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
* messages: use \Drupal\Component\Render\FormattableMarkup to embed
* variables in the message text, not t(). If left blank, a default message
* will be displayed.
* @param string $group
......@@ -117,7 +117,7 @@ protected function assertMailString($field_name, $string, $email_depth, $message
* Pattern to search for.
* @param string $message
* (optional) A message to display with the assertion. Do not translate
* messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
* messages: use \Drupal\Component\Render\FormattableMarkup to embed
* variables in the message text, not t(). If left blank, a default message
* will be displayed.
* @param string $group
......
......@@ -3,7 +3,7 @@
namespace Drupal\Core\Test;
use Drupal\Component\FileCache\FileCacheFactory;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Config\Development\ConfigSchemaChecker;
use Drupal\Core\Database\Database;
......@@ -435,7 +435,7 @@ protected function installModulesFromClassProperty(ContainerInterface $container
$modules = array_unique($modules);
try {
$success = $container->get('module_installer')->install($modules, TRUE);
$this->assertTrue($success, SafeMarkup::format('Enabled modules: %modules', ['%modules' => implode(', ', $modules)]));
$this->assertTrue($success, new FormattableMarkup('Enabled modules: %modules', ['%modules' => implode(', ', $modules)]));
}
catch (MissingDependencyException $e) {
// The exception message has all the details.
......
......@@ -2,7 +2,7 @@
namespace Drupal\Core\Utility;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\Component\Utility\Xss;
use Drupal\Core\Database\DatabaseExceptionWrapper;
......@@ -97,7 +97,7 @@ public static function renderExceptionSafe($exception) {
// no longer function correctly (as opposed to a user-triggered error), so
// we assume that it is safe to include a verbose backtrace.
$decode['@backtrace'] = Error::formatBacktrace($backtrace);
return SafeMarkup::format('%type: @message in %function (line %line of %file). <pre class="backtrace">@backtrace</pre>', $decode);
return new FormattableMarkup('%type: @message in %function (line %line of %file). <pre class="backtrace">@backtrace</pre>', $decode);
}
/**
......
......@@ -36,7 +36,7 @@ interface LinkGeneratorInterface {
* Strings will be sanitized automatically. If you need to output HTML in
* the link text, use a render array or an already sanitized string such as
* the output of \Drupal\Component\Utility\Xss::filter() or
* \Drupal\Component\Utility\SafeMarkup::format().
* \Drupal\Component\Render\FormattableMarkup.
* @param \Drupal\Core\Url $url
* The URL object used for the link. Amongst its options, the following may
* be set to affect the generated link:
......
......@@ -3,7 +3,7 @@
namespace Drupal\aggregator\Form;
use Drupal\aggregator\Plugin\AggregatorPluginManager;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\PluginFormInterface;
......@@ -68,7 +68,7 @@ public function __construct(ConfigFactoryInterface $config_factory, AggregatorPl
// Get all available fetcher, parser and processor definitions.
foreach (['fetcher', 'parser', 'processor'] as $type) {
foreach ($this->managers[$type]->getDefinitions() as $id => $definition) {
$this->definitions[$type][$id] = SafeMarkup::format('@title <span class="description">@description</span>', ['@title' => $definition['title'], '@description' => $definition['description']]);
$this->definitions[$type][$id] = new FormattableMarkup('@title <span class="description">@description</span>', ['@title' => $definition['title'], '@description' => $definition['description']]);
}
}
}
......
......@@ -2,7 +2,7 @@
namespace Drupal\Tests\aggregator\Functional;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\views\Entity\View;
/**
......@@ -114,7 +114,7 @@ public function testFeedPage() {
// Find the expected read_more link on the sources page.
$href = $feed->url();
$links = $this->xpath('//a[@href = :href]', [':href' => $href]);
$this->assertTrue(isset($links[0]), SafeMarkup::format('Link to href %href found.', ['%href' => $href]));
$this->assertTrue(isset($links[0]), new FormattableMarkup('Link to href %href found.', ['%href' => $href]));
$cache_tags_header = $this->drupalGetHeader('X-Drupal-Cache-Tags');
$cache_tags = explode(' ', $cache_tags_header);
$this->assertTrue(in_array('aggregator_feed:' . $feed->id(), $cache_tags));
......