diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index 2b129467363..1d05b4a93c5 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -174,7 +174,7 @@ function config_get_config_directory($type = CONFIG_ACTIVE_DIRECTORY) { if (!empty($config_directories[$type])) { return $config_directories[$type]; } - throw new \Exception(format_string('The configuration directory type %type does not exist.', array('%type' => $type))); + throw new \Exception("The configuration directory type '$type' does not exist"); } /** diff --git a/core/lib/Drupal/Component/Utility/UrlHelper.php b/core/lib/Drupal/Component/Utility/UrlHelper.php index 6c87822c52a..2039d832644 100644 --- a/core/lib/Drupal/Component/Utility/UrlHelper.php +++ b/core/lib/Drupal/Component/Utility/UrlHelper.php @@ -244,7 +244,7 @@ class UrlHelper { $base_parts = parse_url($base_url); if (empty($base_parts['host']) || empty($url_parts['host'])) { - throw new \InvalidArgumentException(SafeMarkup::format('A path was passed when a fully qualified domain was expected.')); + throw new \InvalidArgumentException('A path was passed when a fully qualified domain was expected.'); } if (!isset($url_parts['path']) || !isset($base_parts['path'])) { diff --git a/core/lib/Drupal/Core/Breadcrumb/BreadcrumbManager.php b/core/lib/Drupal/Core/Breadcrumb/BreadcrumbManager.php index 00998979ac2..0015bf3cedc 100644 --- a/core/lib/Drupal/Core/Breadcrumb/BreadcrumbManager.php +++ b/core/lib/Drupal/Core/Breadcrumb/BreadcrumbManager.php @@ -7,7 +7,6 @@ namespace Drupal\Core\Breadcrumb; -use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Routing\RouteMatchInterface; @@ -95,7 +94,7 @@ class BreadcrumbManager implements ChainBreadcrumbBuilderInterface { break; } else { - throw new \UnexpectedValueException(SafeMarkup::format('Invalid breadcrumb returned by !class::build().', array('!class' => get_class($builder)))); + throw new \UnexpectedValueException('Invalid breadcrumb returned by ' . get_class($builder) . '::build().'); } } // Allow modules to alter the breadcrumb. diff --git a/core/lib/Drupal/Core/Config/ConfigBase.php b/core/lib/Drupal/Core/Config/ConfigBase.php index 1ffe7c0c339..6fbdd29027a 100644 --- a/core/lib/Drupal/Core/Config/ConfigBase.php +++ b/core/lib/Drupal/Core/Config/ConfigBase.php @@ -8,7 +8,6 @@ namespace Drupal\Core\Config; use Drupal\Component\Utility\NestedArray; -use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Cache\Cache; use Drupal\Core\Cache\RefinableCacheableDependencyInterface; use Drupal\Core\Cache\RefinableCacheableDependencyTrait; @@ -99,24 +98,17 @@ abstract class ConfigBase implements RefinableCacheableDependencyInterface { public static function validateName($name) { // The name must be namespaced by owner. if (strpos($name, '.') === FALSE) { - throw new ConfigNameException(SafeMarkup::format('Missing namespace in Config object name @name.', array( - '@name' => $name, - ))); + throw new ConfigNameException("Missing namespace in Config object name $name."); } // The name must be shorter than Config::MAX_NAME_LENGTH characters. if (strlen($name) > self::MAX_NAME_LENGTH) { - throw new ConfigNameException(SafeMarkup::format('Config object name @name exceeds maximum allowed length of @length characters.', array( - '@name' => $name, - '@length' => self::MAX_NAME_LENGTH, - ))); + throw new ConfigNameException("Config object name $name exceeds maximum allowed length of " . static::MAX_NAME_LENGTH . " characters."); } // The name must not contain any of the following characters: // : ? * < > " ' / \ if (preg_match('/[:?*<>"\'\/\\\\]/', $name)) { - throw new ConfigNameException(SafeMarkup::format('Invalid character in Config object name @name.', array( - '@name' => $name, - ))); + throw new ConfigNameException("Invalid character in Config object name $name."); } } @@ -224,7 +216,7 @@ abstract class ConfigBase implements RefinableCacheableDependencyInterface { protected function validateKeys(array $data) { foreach ($data as $key => $value) { if (strpos($key, '.') !== FALSE) { - throw new ConfigValueException(SafeMarkup::format('@key key contains a dot which is not supported.', array('@key' => $key))); + throw new ConfigValueException("$key key contains a dot which is not supported."); } if (is_array($value)) { $this->validateKeys($value); diff --git a/core/lib/Drupal/Core/Config/ConfigImporter.php b/core/lib/Drupal/Core/Config/ConfigImporter.php index ed507353dcc..e0d4e0d4b2e 100644 --- a/core/lib/Drupal/Core/Config/ConfigImporter.php +++ b/core/lib/Drupal/Core/Config/ConfigImporter.php @@ -11,7 +11,6 @@ use Drupal\Core\Config\Importer\MissingContentEvent; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Extension\ModuleInstallerInterface; use Drupal\Core\Extension\ThemeHandlerInterface; -use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Config\Entity\ImportableEntityStorageInterface; use Drupal\Core\DependencyInjection\DependencySerializationTrait; use Drupal\Core\Entity\EntityStorageException; @@ -763,7 +762,7 @@ class ConfigImporter { } } catch (\Exception $e) { - $this->logError($this->t('Unexpected error during import with operation @op for @name: @message', array('@op' => $op, '@name' => $name, '@message' => $e->getMessage()))); + $this->logError($this->t('Unexpected error during import with operation @op for @name: !message', array('@op' => $op, '@name' => $name, '!message' => $e->getMessage()))); // Error for that operation was logged, mark it as processed so that // the import can continue. $this->setProcessedConfiguration($collection, $op, $name); @@ -972,7 +971,7 @@ class ConfigImporter { // Call to the configuration entity's storage to handle the configuration // change. if (!($entity_storage instanceof ImportableEntityStorageInterface)) { - throw new EntityStorageException(SafeMarkup::format('The entity storage "@storage" for the "@entity_type" entity type does not support imports', array('@storage' => get_class($entity_storage), '@entity_type' => $entity_type))); + throw new EntityStorageException(sprintf('The entity storage "%s" for the "%s" entity type does not support imports', get_class($entity_storage), $entity_type)); } $entity_storage->$method($name, $new_config, $old_config); $this->setProcessedConfiguration($collection, $op, $name); @@ -1018,7 +1017,7 @@ class ConfigImporter { // Call to the configuration entity's storage to handle the configuration // change. if (!($entity_storage instanceof ImportableEntityStorageInterface)) { - throw new EntityStorageException(SafeMarkup::format('The entity storage "@storage" for the "@entity_type" entity type does not support imports', array('@storage' => get_class($entity_storage), '@entity_type' => $entity_type_id))); + throw new EntityStorageException(sprintf("The entity storage '%s' for the '%s' entity type does not support imports", get_class($entity_storage), $entity_type_id)); } $entity_storage->importRename($names['old_name'], $new_config, $old_config); $this->setProcessedConfiguration($collection, 'rename', $rename_name); diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php index db0841221a2..5b4688f8187 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php @@ -7,7 +7,6 @@ namespace Drupal\Core\Config\Entity; -use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Cache\Cache; use Drupal\Core\Config\ConfigException; use Drupal\Core\Config\Schema\SchemaIncompleteException; @@ -278,7 +277,7 @@ abstract class ConfigEntityBase extends Entity implements ConfigEntityInterface $config_name = $entity_type->getConfigPrefix() . '.' . $this->id(); $definition = $this->getTypedConfig()->getDefinition($config_name); if (!isset($definition['mapping'])) { - throw new SchemaIncompleteException(SafeMarkup::format('Incomplete or missing schema for @config_name', array('@config_name' => $config_name))); + throw new SchemaIncompleteException("Incomplete or missing schema for $config_name"); } $properties_to_export = array_combine(array_keys($definition['mapping']), array_keys($definition['mapping'])); } @@ -331,7 +330,7 @@ abstract class ConfigEntityBase extends Entity implements ConfigEntityInterface ->execute(); $matched_entity = reset($matching_entities); if (!empty($matched_entity) && ($matched_entity != $this->id()) && $matched_entity != $this->getOriginalId()) { - throw new ConfigDuplicateUUIDException(SafeMarkup::format('Attempt to save a configuration entity %id with UUID %uuid when this UUID is already used for %matched', array('%id' => $this->id(), '%uuid' => $this->uuid(), '%matched' => $matched_entity))); + throw new ConfigDuplicateUUIDException("Attempt to save a configuration entity '{$this->id()}' with UUID '{$this->uuid()}' when this UUID is already used for '$matched_entity'"); } // If this entity is not new, load the original entity for comparison. @@ -339,7 +338,7 @@ abstract class ConfigEntityBase extends Entity implements ConfigEntityInterface $original = $storage->loadUnchanged($this->getOriginalId()); // Ensure that the UUID cannot be changed for an existing entity. if ($original && ($original->uuid() != $this->uuid())) { - throw new ConfigDuplicateUUIDException(SafeMarkup::format('Attempt to save a configuration entity %id with UUID %uuid when this entity already exists with UUID %original_uuid', array('%id' => $this->id(), '%uuid' => $this->uuid(), '%original_uuid' => $original->uuid()))); + throw new ConfigDuplicateUUIDException("Attempt to save a configuration entity '{$this->id()}' with UUID '{$this->uuid()}' when this entity already exists with UUID '{$original->uuid()}'"); } } if (!$this->isSyncing() && !$this->trustedData) { diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php index 8e3ccf8653e..4912dc68700 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php @@ -7,7 +7,6 @@ namespace Drupal\Core\Config\Entity; -use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Cache\CacheableMetadata; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Config\ConfigImporterException; @@ -259,10 +258,7 @@ class ConfigEntityStorage extends EntityStorageBase implements ConfigEntityStora // @todo Consider moving this to a protected method on the parent class, and // abstracting it for all entity types. if (strlen($entity->get($this->idKey)) > self::MAX_ID_LENGTH) { - throw new ConfigEntityIdLengthException(SafeMarkup::format('Configuration entity ID @id exceeds maximum allowed length of @length characters.', array( - '@id' => $entity->get($this->idKey), - '@length' => self::MAX_ID_LENGTH, - ))); + throw new ConfigEntityIdLengthException("Configuration entity ID {$entity->get($this->idKey)} exceeds maximum allowed length of " . self::MAX_ID_LENGTH . " characters."); } return parent::save($entity); @@ -404,7 +400,7 @@ class ConfigEntityStorage extends EntityStorageBase implements ConfigEntityStora $id = static::getIDFromConfigName($name, $this->entityType->getConfigPrefix()); $entity = $this->load($id); if (!$entity) { - throw new ConfigImporterException(SafeMarkup::format('Attempt to update non-existing entity "@id".', array('@id' => $id))); + throw new ConfigImporterException("Attempt to update non-existing entity '$id'."); } $entity->setSyncing(TRUE); $entity = $this->updateFromStorageRecord($entity, $new_config->get()); diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityType.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityType.php index 33cefbdd2ac..ab94c27f6e6 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityType.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityType.php @@ -10,7 +10,6 @@ namespace Drupal\Core\Config\Entity; use Drupal\Core\Config\Entity\Exception\ConfigEntityStorageClassException; use Drupal\Core\Entity\EntityType; use Drupal\Core\Config\ConfigPrefixLengthException; -use Drupal\Component\Utility\SafeMarkup; /** * Provides an implementation of a configuration entity type and its metadata. @@ -93,10 +92,7 @@ class ConfigEntityType extends EntityType implements ConfigEntityTypeInterface { } if (strlen($config_prefix) > static::PREFIX_LENGTH) { - throw new ConfigPrefixLengthException(SafeMarkup::format('The configuration file name prefix @config_prefix exceeds the maximum character limit of @max_char.', array( - '@config_prefix' => $config_prefix, - '@max_char' => static::PREFIX_LENGTH, - ))); + throw new ConfigPrefixLengthException("The configuration file name prefix $config_prefix exceeds the maximum character limit of " . static::PREFIX_LENGTH); } return $config_prefix; } @@ -158,7 +154,7 @@ class ConfigEntityType extends EntityType implements ConfigEntityTypeInterface { */ protected function checkStorageClass($class) { if (!is_a($class, 'Drupal\Core\Config\Entity\ConfigEntityStorage', TRUE)) { - throw new ConfigEntityStorageClassException(SafeMarkup::format('@class is not \Drupal\Core\Config\Entity\ConfigEntityStorage or it does not extend it', ['@class' => $class])); + throw new ConfigEntityStorageClassException("$class is not \\Drupal\\Core\\Config\\Entity\\ConfigEntityStorage or it does not extend it"); } } diff --git a/core/lib/Drupal/Core/Config/FileStorage.php b/core/lib/Drupal/Core/Config/FileStorage.php index ec199e75b5f..0f5b45aa88a 100644 --- a/core/lib/Drupal/Core/Config/FileStorage.php +++ b/core/lib/Drupal/Core/Config/FileStorage.php @@ -9,7 +9,6 @@ namespace Drupal\Core\Config; use Drupal\Component\Serialization\Yaml; use Drupal\Component\Serialization\Exception\InvalidDataTypeException; -use Drupal\Component\Utility\SafeMarkup; /** * Defines the file storage. @@ -101,10 +100,7 @@ class FileStorage implements StorageInterface { $data = $this->decode($data); } catch (InvalidDataTypeException $e) { - throw new UnsupportedDataTypeConfigException(SafeMarkup::format('Invalid data type in config @name: !message', array( - '@name' => $name, - '!message' => $e->getMessage(), - ))); + throw new UnsupportedDataTypeConfigException("Invalid data type in config $name: {$e->getMessage()}"); } return $data; } @@ -130,10 +126,7 @@ class FileStorage implements StorageInterface { $data = $this->encode($data); } catch (InvalidDataTypeException $e) { - throw new StorageException(SafeMarkup::format('Invalid data type in config @name: !message', array( - '@name' => $name, - '!message' => $e->getMessage(), - ))); + throw new StorageException("Invalid data type in config $name: {$e->getMessage()}"); } $target = $this->getFilePath($name); diff --git a/core/lib/Drupal/Core/Config/ImmutableConfig.php b/core/lib/Drupal/Core/Config/ImmutableConfig.php index 8435f711032..511a9c42141 100644 --- a/core/lib/Drupal/Core/Config/ImmutableConfig.php +++ b/core/lib/Drupal/Core/Config/ImmutableConfig.php @@ -7,8 +7,6 @@ namespace Drupal\Core\Config; -use Drupal\Component\Utility\SafeMarkup; - /** * Defines the immutable configuration object. * @@ -31,21 +29,21 @@ class ImmutableConfig extends Config { * {@inheritdoc} */ public function set($key, $value) { - throw new ImmutableConfigException(SafeMarkup::format('Can not set values on immutable configuration !name:!key. Use \Drupal\Core\Config\ConfigFactoryInterface::getEditable() to retrieve a mutable configuration object', ['!name' => $this->getName(), '!key' => $key])); + throw new ImmutableConfigException("Can not set values on immutable configuration {$this->getName()}:$key. Use \\Drupal\\Core\\Config\\ConfigFactoryInterface::getEditable() to retrieve a mutable configuration object"); } /** * {@inheritdoc} */ public function clear($key) { - throw new ImmutableConfigException(SafeMarkup::format('Can not clear !key key in immutable configuration !name. Use \Drupal\Core\Config\ConfigFactoryInterface::getEditable() to retrieve a mutable configuration object', ['!name' => $this->getName(), '!key' => $key])); + throw new ImmutableConfigException("Can not clear $key key in immutable configuration {$this->getName()}. Use \\Drupal\\Core\\Config\\ConfigFactoryInterface::getEditable() to retrieve a mutable configuration object"); } /** * {@inheritdoc} */ public function save($has_trusted_data = FALSE) { - throw new ImmutableConfigException(SafeMarkup::format('Can not save immutable configuration !name. Use \Drupal\Core\Config\ConfigFactoryInterface::getEditable() to retrieve a mutable configuration object', ['!name' => $this->getName()])); + throw new ImmutableConfigException("Can not save immutable configuration {$this->getName()}. Use \\Drupal\\Core\\Config\\ConfigFactoryInterface::getEditable() to retrieve a mutable configuration object"); } /** @@ -55,7 +53,7 @@ class ImmutableConfig extends Config { * The configuration object. */ public function delete() { - throw new ImmutableConfigException(SafeMarkup::format('Can not delete immutable configuration !name. Use \Drupal\Core\Config\ConfigFactoryInterface::getEditable() to retrieve a mutable configuration object', ['!name' => $this->getName()])); + throw new ImmutableConfigException("Can not delete immutable configuration {$this->getName()}. Use \\Drupal\\Core\\Config\\ConfigFactoryInterface::getEditable() to retrieve a mutable configuration object"); } } diff --git a/core/lib/Drupal/Core/Config/InstallStorage.php b/core/lib/Drupal/Core/Config/InstallStorage.php index f3a329808a4..5c1d65a7794 100644 --- a/core/lib/Drupal/Core/Config/InstallStorage.php +++ b/core/lib/Drupal/Core/Config/InstallStorage.php @@ -91,9 +91,7 @@ class InstallStorage extends FileStorage { } // If any code in the early installer requests a configuration object that // does not exist anywhere as default config, then that must be mistake. - throw new StorageException(format_string('Missing configuration file: @name', array( - '@name' => $name, - ))); + throw new StorageException("Missing configuration file: $name"); } /** diff --git a/core/lib/Drupal/Core/Config/Schema/ArrayElement.php b/core/lib/Drupal/Core/Config/Schema/ArrayElement.php index 35e932ac26f..88914c05265 100644 --- a/core/lib/Drupal/Core/Config/Schema/ArrayElement.php +++ b/core/lib/Drupal/Core/Config/Schema/ArrayElement.php @@ -7,7 +7,6 @@ namespace Drupal\Core\Config\Schema; -use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Config\TypedConfigManagerInterface; use Drupal\Core\TypedData\TypedData; @@ -94,7 +93,7 @@ abstract class ArrayElement extends TypedData implements \IteratorAggregate, Typ return $element; } else { - throw new \InvalidArgumentException(SafeMarkup::format("The configuration property @key doesn't exist.", array('@key' => $name))); + throw new \InvalidArgumentException("The configuration property $name doesn't exist."); } } diff --git a/core/lib/Drupal/Core/Config/StorableConfigBase.php b/core/lib/Drupal/Core/Config/StorableConfigBase.php index 92abc28ee2e..a0ad7a2b251 100644 --- a/core/lib/Drupal/Core/Config/StorableConfigBase.php +++ b/core/lib/Drupal/Core/Config/StorableConfigBase.php @@ -7,7 +7,6 @@ namespace Drupal\Core\Config; -use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Config\Schema\Ignore; use Drupal\Core\TypedData\PrimitiveInterface; use Drupal\Core\TypedData\Type\FloatInterface; @@ -163,10 +162,7 @@ abstract class StorableConfigBase extends ConfigBase { } } elseif ($value !== NULL && !is_scalar($value)) { - throw new UnsupportedDataTypeConfigException(SafeMarkup::format('Invalid data type for config element @name:@key', array( - '@name' => $this->getName(), - '@key' => $key, - ))); + throw new UnsupportedDataTypeConfigException("Invalid data type for config element {$this->getName()}:$key"); } } @@ -213,10 +209,7 @@ abstract class StorableConfigBase extends ConfigBase { else { // Throw exception on any non-scalar or non-array value. if (!is_array($value)) { - throw new UnsupportedDataTypeConfigException(SafeMarkup::format('Invalid data type for config element @name:@key', array( - '@name' => $this->getName(), - '@key' => $key, - ))); + throw new UnsupportedDataTypeConfigException("Invalid data type for config element {$this->getName()}:$key"); } // Recurse into any nested keys. foreach ($value as $nested_value_key => $nested_value) { diff --git a/core/lib/Drupal/Core/Config/StorageComparer.php b/core/lib/Drupal/Core/Config/StorageComparer.php index 2e61f96ceb9..a3fa7ee4298 100644 --- a/core/lib/Drupal/Core/Config/StorageComparer.php +++ b/core/lib/Drupal/Core/Config/StorageComparer.php @@ -7,7 +7,6 @@ namespace Drupal\Core\Config; -use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Cache\MemoryBackend; use Drupal\Core\Config\Entity\ConfigDependencyManager; use Drupal\Core\DependencyInjection\DependencySerializationTrait; @@ -196,7 +195,7 @@ class StorageComparer implements StorageComparerInterface { // ensure the array is keyed from 0. $this->changelist[$collection][$op] = array_values(array_intersect($sort_order, $this->changelist[$collection][$op])); if ($count != count($this->changelist[$collection][$op])) { - throw new \InvalidArgumentException(SafeMarkup::format('Sorting the @op changelist should not change its length.', array('@op' => $op))); + throw new \InvalidArgumentException("Sorting the $op changelist should not change its length."); } } } diff --git a/core/lib/Drupal/Core/Config/Testing/ConfigSchemaChecker.php b/core/lib/Drupal/Core/Config/Testing/ConfigSchemaChecker.php index 5e4fe5769dd..06c836a7600 100644 --- a/core/lib/Drupal/Core/Config/Testing/ConfigSchemaChecker.php +++ b/core/lib/Drupal/Core/Config/Testing/ConfigSchemaChecker.php @@ -88,14 +88,14 @@ class ConfigSchemaChecker implements EventSubscriberInterface { $this->checked[$name . ':' . $checksum] = TRUE; $errors = $this->checkConfigSchema($this->typedManager, $name, $data); if ($errors === FALSE) { - throw new SchemaIncompleteException(SafeMarkup::format('No schema for @config_name', array('@config_name' => $name))); + throw new SchemaIncompleteException("No schema for $name"); } elseif (is_array($errors)) { $text_errors = []; foreach ($errors as $key => $error) { $text_errors[] = SafeMarkup::format('@key @error', array('@key' => $key, '@error' => $error)); } - throw new SchemaIncompleteException(SafeMarkup::format('Schema errors for @config_name with the following errors: @errors', array('@config_name' => $name, '@errors' => implode(', ', $text_errors)))); + throw new SchemaIncompleteException("Schema errors for $name with the following errors: " . implode(', ', $text_errors)); } } } diff --git a/core/lib/Drupal/Core/Config/TypedConfigManager.php b/core/lib/Drupal/Core/Config/TypedConfigManager.php index 6bd33cc4c0c..500fc3cfdff 100644 --- a/core/lib/Drupal/Core/Config/TypedConfigManager.php +++ b/core/lib/Drupal/Core/Config/TypedConfigManager.php @@ -8,7 +8,6 @@ namespace Drupal\Core\Config; use Drupal\Component\Utility\NestedArray; -use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Config\Schema\ArrayElement; use Drupal\Core\Config\Schema\ConfigSchemaAlterException; @@ -324,18 +323,18 @@ class TypedConfigManager extends TypedDataManager implements TypedConfigManagerI parent::alterDefinitions($definitions); $altered_schema = array_keys($definitions); if ($discovered_schema != $altered_schema) { - $added_keys = array_diff($altered_schema, $discovered_schema); - $removed_keys = array_diff($discovered_schema, $altered_schema); + $added_keys = implode(',', array_diff($altered_schema, $discovered_schema)); + $removed_keys = implode(',', array_diff($discovered_schema, $altered_schema)); if (!empty($added_keys) && !empty($removed_keys)) { - $message = 'Invoking hook_config_schema_info_alter() has added (@added) and removed (@removed) schema definitions'; + $message = "Invoking hook_config_schema_info_alter() has added ($added_keys) and removed ($removed_keys) schema definitions"; } elseif (!empty($added_keys)) { - $message = 'Invoking hook_config_schema_info_alter() has added (@added) schema definitions'; + $message = "Invoking hook_config_schema_info_alter() has added ($added_keys) schema definitions"; } else { - $message = 'Invoking hook_config_schema_info_alter() has removed (@removed) schema definitions'; + $message = "Invoking hook_config_schema_info_alter() has removed ($removed_keys) schema definitions"; } - throw new ConfigSchemaAlterException(SafeMarkup::format($message, ['@added' => implode(',', $added_keys), '@removed' => implode(',', $removed_keys)])); + throw new ConfigSchemaAlterException($message); } } diff --git a/core/lib/Drupal/Core/Entity/ContentEntityBase.php b/core/lib/Drupal/Core/Entity/ContentEntityBase.php index 27d130fd9fb..491311d1397 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityBase.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityBase.php @@ -263,7 +263,7 @@ abstract class ContentEntityBase extends Entity implements \IteratorAggregate, C */ public function setNewRevision($value = TRUE) { if (!$this->getEntityType()->hasKey('revision')) { - throw new \LogicException(SafeMarkup::format('Entity type @entity_type does not support revisions.', ['@entity_type' => $this->getEntityTypeId()])); + throw new \LogicException("Entity type {$this->getEntityTypeId()} does not support revisions."); } if ($value && !$this->newRevision) { @@ -464,15 +464,14 @@ abstract class ContentEntityBase extends Entity implements \IteratorAggregate, C */ protected function getTranslatedField($name, $langcode) { if ($this->translations[$this->activeLangcode]['status'] == static::TRANSLATION_REMOVED) { - $message = 'The entity object refers to a removed translation (@langcode) and cannot be manipulated.'; - throw new \InvalidArgumentException(SafeMarkup::format($message, array('@langcode' => $this->activeLangcode))); + throw new \InvalidArgumentException("The entity object refers to a removed translation ({$this->activeLangcode}) and cannot be manipulated."); } // Populate $this->fields to speed-up further look-ups and to keep track of // fields objects, possibly holding changes to field values. if (!isset($this->fields[$name][$langcode])) { $definition = $this->getFieldDefinition($name); if (!$definition) { - throw new \InvalidArgumentException('Field ' . SafeMarkup::checkPlain($name) . ' is unknown.'); + throw new \InvalidArgumentException("Field $name is unknown."); } // Non-translatable fields are always stored with // LanguageInterface::LANGCODE_DEFAULT as key. @@ -757,8 +756,7 @@ abstract class ContentEntityBase extends Entity implements \IteratorAggregate, C } if (empty($translation)) { - $message = 'Invalid translation language (@langcode) specified.'; - throw new \InvalidArgumentException(SafeMarkup::format($message, array('@langcode' => $langcode))); + throw new \InvalidArgumentException("Invalid translation language ($langcode) specified."); } return $translation; @@ -825,8 +823,7 @@ abstract class ContentEntityBase extends Entity implements \IteratorAggregate, C public function addTranslation($langcode, array $values = array()) { $this->getLanguages(); if (!isset($this->languages[$langcode]) || $this->hasTranslation($langcode)) { - $message = 'Invalid translation language (@langcode) specified.'; - throw new \InvalidArgumentException(SafeMarkup::format($message, array('@langcode' => $langcode))); + throw new \InvalidArgumentException("Invalid translation language ($langcode) specified."); } // Instantiate a new empty entity so default values will be populated in the @@ -876,8 +873,7 @@ abstract class ContentEntityBase extends Entity implements \IteratorAggregate, C $this->translations[$langcode]['status'] = static::TRANSLATION_REMOVED; } else { - $message = 'The specified translation (@langcode) cannot be removed.'; - throw new \InvalidArgumentException(SafeMarkup::format($message, array('@langcode' => $langcode))); + throw new \InvalidArgumentException("The specified translation ($langcode) cannot be removed."); } } @@ -1010,8 +1006,7 @@ abstract class ContentEntityBase extends Entity implements \IteratorAggregate, C */ public function createDuplicate() { if ($this->translations[$this->activeLangcode]['status'] == static::TRANSLATION_REMOVED) { - $message = 'The entity object refers to a removed translation (@langcode) and cannot be manipulated.'; - throw new \InvalidArgumentException(SafeMarkup::format($message, array('@langcode' => $this->activeLangcode))); + throw new \InvalidArgumentException("The entity object refers to a removed translation ({$this->activeLangcode}) and cannot be manipulated."); } $duplicate = clone $this; diff --git a/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php b/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php index 9240827f96b..6e6a74f89e3 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php @@ -7,7 +7,6 @@ namespace Drupal\Core\Entity; -use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Cache\Cache; use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Field\FieldDefinitionInterface; @@ -83,7 +82,7 @@ abstract class ContentEntityStorageBase extends EntityStorageBase implements Dyn $bundle = FALSE; if ($this->bundleKey) { if (!isset($values[$this->bundleKey])) { - throw new EntityStorageException(SafeMarkup::format('Missing bundle for entity type @type', array('@type' => $this->entityTypeId))); + throw new EntityStorageException('Missing bundle for entity type ' . $this->entityTypeId); } $bundle = $values[$this->bundleKey]; } diff --git a/core/lib/Drupal/Core/Entity/Entity.php b/core/lib/Drupal/Core/Entity/Entity.php index 8d5e9e3e407..4863121d3c0 100644 --- a/core/lib/Drupal/Core/Entity/Entity.php +++ b/core/lib/Drupal/Core/Entity/Entity.php @@ -195,10 +195,7 @@ abstract class Entity implements EntityInterface { $uri = call_user_func($uri_callback, $this); } else { - throw new UndefinedLinkTemplateException(SafeMarkup::format('No link template "@rel" found for the "@entity_type" entity type', array( - '@rel' => $rel, - '@entity_type' => $this->getEntityTypeId(), - ))); + throw new UndefinedLinkTemplateException("No link template '$rel' found for the '{$this->getEntityTypeId()}' entity type"); } } @@ -384,12 +381,7 @@ abstract class Entity implements EntityInterface { if ($this->getEntityType()->getBundleOf()) { // Throw an exception if the bundle ID is longer than 32 characters. if (Unicode::strlen($this->id()) > EntityTypeInterface::BUNDLE_MAX_LENGTH) { - throw new ConfigEntityIdLengthException(SafeMarkup::format( - 'Attempt to create a bundle with an ID longer than @max characters: @id.', array( - '@max' => EntityTypeInterface::BUNDLE_MAX_LENGTH, - '@id' => $this->id(), - ) - )); + throw new ConfigEntityIdLengthException("Attempt to create a bundle with an ID longer than " . EntityTypeInterface::BUNDLE_MAX_LENGTH . " characters: $this->id()."); } } } diff --git a/core/lib/Drupal/Core/Entity/EntityDisplayBase.php b/core/lib/Drupal/Core/Entity/EntityDisplayBase.php index d5cda6511a3..3a59e015642 100644 --- a/core/lib/Drupal/Core/Entity/EntityDisplayBase.php +++ b/core/lib/Drupal/Core/Entity/EntityDisplayBase.php @@ -11,7 +11,6 @@ use Drupal\Core\Config\Entity\ConfigEntityBase; use Drupal\Core\Config\Entity\ConfigEntityInterface; use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Entity\Display\EntityDisplayInterface; -use Drupal\Component\Utility\SafeMarkup; /** * Provides a common base class for entity view and form displays. @@ -262,7 +261,7 @@ abstract class EntityDisplayBase extends ConfigEntityBase implements EntityDispl // If the target entity type uses entities to manage its bundles then // depend on the bundle entity. if (!$bundle_entity = $this->entityManager()->getStorage($bundle_entity_type_id)->load($this->bundle)) { - throw new \LogicException(SafeMarkup::format('Missing bundle entity, entity type %type, entity id %bundle.', array('%type' => $bundle_entity_type_id, '%bundle' => $this->bundle))); + throw new \LogicException("Missing bundle entity, entity type $bundle_entity_type_id, entity id {$this->bundle}."); } $this->addDependency('config', $bundle_entity->getConfigDependencyName()); } diff --git a/core/lib/Drupal/Core/Entity/EntityManager.php b/core/lib/Drupal/Core/Entity/EntityManager.php index 2d03dff552d..ad0002ed5de 100644 --- a/core/lib/Drupal/Core/Entity/EntityManager.php +++ b/core/lib/Drupal/Core/Entity/EntityManager.php @@ -9,7 +9,6 @@ namespace Drupal\Core\Entity; use Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException; use Drupal\Component\Plugin\Exception\PluginNotFoundException; -use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Cache\Cache; use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Config\Entity\ConfigEntityType; @@ -425,7 +424,7 @@ class EntityManager extends DefaultPluginManager implements EntityManagerInterfa // Fail with an exception for non-fieldable entity types. if (!$entity_type->isSubclassOf('\Drupal\Core\Entity\FieldableEntityInterface')) { - throw new \LogicException(SafeMarkup::format('Getting the base fields is not supported for entity type @type.', array('@type' => $entity_type->getLabel()))); + throw new \LogicException("Getting the base fields is not supported for entity type {$entity_type->getLabel()}."); } // Retrieve base field definitions. @@ -493,28 +492,19 @@ class EntityManager extends DefaultPluginManager implements EntityManagerInterfa // translatable values. foreach (array_intersect_key($keys, array_flip(['id', 'revision', 'uuid', 'bundle'])) as $key => $field_name) { if (!isset($base_field_definitions[$field_name])) { - throw new \LogicException(SafeMarkup::format('The @field field definition does not exist and it is used as @key entity key.', array( - '@field' => $field_name, - '@key' => $key, - ))); + throw new \LogicException("The $field_name field definition does not exist and it is used as $key entity key."); } if ($base_field_definitions[$field_name]->isRevisionable()) { - throw new \LogicException(SafeMarkup::format('The @field field cannot be revisionable as it is used as @key entity key.', array( - '@field' => $base_field_definitions[$field_name]->getLabel(), - '@key' => $key, - ))); + throw new \LogicException("The {$base_field_definitions[$field_name]->getLabel()} field cannot be revisionable as it is used as $key entity key."); } if ($base_field_definitions[$field_name]->isTranslatable()) { - throw new \LogicException(SafeMarkup::format('The @field field cannot be translatable as it is used as @key entity key.', array( - '@field' => $base_field_definitions[$field_name]->getLabel(), - '@key' => $key, - ))); + throw new \LogicException("The {$base_field_definitions[$field_name]->getLabel()} field cannot be translatable as it is used as $key entity key."); } } // Make sure translatable entity types define the "langcode" field properly. if ($entity_type->isTranslatable() && (!isset($keys['langcode']) || !isset($base_field_definitions[$keys['langcode']]) || !$base_field_definitions[$keys['langcode']]->isTranslatable())) { - throw new \LogicException(SafeMarkup::format('The @entity_type entity type cannot be translatable as it does not define a translatable "langcode" field.', array('@entity_type' => $entity_type->getLabel()))); + throw new \LogicException("The {$entity_type->getLabel()} entity type cannot be translatable as it does not define a translatable \"langcode\" field."); } return $base_field_definitions; diff --git a/core/lib/Drupal/Core/Entity/EntityStorageBase.php b/core/lib/Drupal/Core/Entity/EntityStorageBase.php index 9163c11e781..f132d89489b 100644 --- a/core/lib/Drupal/Core/Entity/EntityStorageBase.php +++ b/core/lib/Drupal/Core/Entity/EntityStorageBase.php @@ -7,7 +7,6 @@ namespace Drupal\Core\Entity; -use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Entity\Query\QueryInterface; /** @@ -422,7 +421,7 @@ abstract class EntityStorageBase extends EntityHandlerBase implements EntityStor // A new entity should not already exist. if ($id_exists && $entity->isNew()) { - throw new EntityStorageException(SafeMarkup::format('@type entity with ID @id already exists.', array('@type' => $this->entityTypeId, '@id' => $id))); + throw new EntityStorageException("'{$this->entityTypeId}' entity with ID '$id' already exists."); } // Load the original entity, if any. diff --git a/core/lib/Drupal/Core/Entity/EntityType.php b/core/lib/Drupal/Core/Entity/EntityType.php index e121d751ed2..31c7923212d 100644 --- a/core/lib/Drupal/Core/Entity/EntityType.php +++ b/core/lib/Drupal/Core/Entity/EntityType.php @@ -7,7 +7,6 @@ namespace Drupal\Core\Entity; -use Drupal\Component\Utility\SafeMarkup; use Drupal\Component\Utility\Unicode; use Drupal\Core\Entity\Exception\EntityTypeIdLengthException; use Drupal\Core\StringTranslation\StringTranslationTrait; @@ -245,12 +244,7 @@ class EntityType implements EntityTypeInterface { public function __construct($definition) { // Throw an exception if the entity type ID is longer than 32 characters. if (Unicode::strlen($definition['id']) > static::ID_MAX_LENGTH) { - throw new EntityTypeIdLengthException(SafeMarkup::format( - 'Attempt to create an entity type with an ID longer than @max characters: @id.', array( - '@max' => static::ID_MAX_LENGTH, - '@id' => $definition['id'], - ) - )); + throw new EntityTypeIdLengthException('Attempt to create an entity type with an ID longer than ' . static::ID_MAX_LENGTH . " characters: {$definition['id']}."); } foreach ($definition as $property => $value) { diff --git a/core/lib/Drupal/Core/Entity/KeyValueStore/KeyValueEntityStorage.php b/core/lib/Drupal/Core/Entity/KeyValueStore/KeyValueEntityStorage.php index 5d8ac59cb86..5bb10492237 100644 --- a/core/lib/Drupal/Core/Entity/KeyValueStore/KeyValueEntityStorage.php +++ b/core/lib/Drupal/Core/Entity/KeyValueStore/KeyValueEntityStorage.php @@ -7,7 +7,6 @@ namespace Drupal\Core\Entity\KeyValueStore; -use Drupal\Component\Utility\SafeMarkup; use Drupal\Component\Uuid\UuidInterface; use Drupal\Core\Config\Entity\Exception\ConfigEntityIdLengthException; use Drupal\Core\Entity\FieldableEntityInterface; @@ -167,10 +166,7 @@ class KeyValueEntityStorage extends EntityStorageBase { // @todo This is not config-specific, but serial IDs will likely never hit // this limit. Consider renaming the exception class. if (strlen($entity->id()) > static::MAX_ID_LENGTH) { - throw new ConfigEntityIdLengthException(SafeMarkup::format('Entity ID @id exceeds maximum allowed length of @length characters.', array( - '@id' => $entity->id(), - '@length' => static::MAX_ID_LENGTH, - ))); + throw new ConfigEntityIdLengthException("Entity ID {$entity->id()} exceeds maximum allowed length of " . static::MAX_ID_LENGTH . ' characters.'); } return parent::save($entity); } diff --git a/core/lib/Drupal/Core/Entity/Plugin/DataType/EntityAdapter.php b/core/lib/Drupal/Core/Entity/Plugin/DataType/EntityAdapter.php index 1a64c403a7d..054d101ba4d 100644 --- a/core/lib/Drupal/Core/Entity/Plugin/DataType/EntityAdapter.php +++ b/core/lib/Drupal/Core/Entity/Plugin/DataType/EntityAdapter.php @@ -81,12 +81,12 @@ class EntityAdapter extends TypedData implements \IteratorAggregate, ComplexData */ public function get($property_name) { if (!isset($this->entity)) { - throw new MissingDataException(SafeMarkup::format('Unable to get property @name as no entity has been provided.', array('@name' => $property_name))); + throw new MissingDataException("Unable to get property $property_name as no entity has been provided."); } if (!$this->entity instanceof FieldableEntityInterface) { // @todo: Add support for config entities in // https://www.drupal.org/node/1818574. - throw new \InvalidArgumentException(SafeMarkup::format('Unable to get unknown property @name.', array('@name' => $property_name))); + throw new \InvalidArgumentException("Unable to get unknown property $property_name."); } // This will throw an exception for unknown fields. return $this->entity->get($property_name); @@ -97,12 +97,12 @@ class EntityAdapter extends TypedData implements \IteratorAggregate, ComplexData */ public function set($property_name, $value, $notify = TRUE) { if (!isset($this->entity)) { - throw new MissingDataException(SafeMarkup::format('Unable to set property @name as no entity has been provided.', array('@name' => $property_name))); + throw new MissingDataException("Unable to set property $property_name as no entity has been provided."); } if (!$this->entity instanceof FieldableEntityInterface) { // @todo: Add support for config entities in // https://www.drupal.org/node/1818574. - throw new \InvalidArgumentException(SafeMarkup::format('Unable to set unknown property @name.', array('@name' => $property_name))); + throw new \InvalidArgumentException("Unable to set unknown property $property_name."); } // This will throw an exception for unknown fields. $this->entity->set($property_name, $value, $notify); @@ -129,7 +129,7 @@ class EntityAdapter extends TypedData implements \IteratorAggregate, ComplexData */ public function toArray() { if (!isset($this->entity)) { - throw new MissingDataException(SafeMarkup::format('Unable to get property values as no entity has been provided.')); + throw new MissingDataException('Unable to get property values as no entity has been provided.'); } return $this->entity->toArray(); } diff --git a/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php b/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php index 98f4f843a43..e1a976ac9d8 100644 --- a/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php +++ b/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php @@ -215,7 +215,7 @@ class Tables implements TablesInterface { $index_prefix .= "$next_index_prefix."; } else { - throw new QueryException(format_string('Invalid specifier @next.', array('@next' => $relationship_specifier))); + throw new QueryException("Invalid specifier '$relationship_specifier'"); } } } @@ -247,7 +247,7 @@ class Tables implements TablesInterface { return $this->entityTables[$index_prefix . $table]; } } - throw new QueryException(format_string('@property not found', array('@property' => $property))); + throw new QueryException("'$property' not found"); } /** diff --git a/core/lib/Drupal/Core/Entity/Sql/DefaultTableMapping.php b/core/lib/Drupal/Core/Entity/Sql/DefaultTableMapping.php index ac12621d197..b7012791180 100644 --- a/core/lib/Drupal/Core/Entity/Sql/DefaultTableMapping.php +++ b/core/lib/Drupal/Core/Entity/Sql/DefaultTableMapping.php @@ -7,7 +7,6 @@ namespace Drupal\Core\Entity\Sql; -use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Entity\ContentEntityTypeInterface; use Drupal\Core\Field\FieldStorageDefinitionInterface; @@ -178,7 +177,7 @@ class DefaultTableMapping implements TableMappingInterface { } if (!isset($result)) { - throw new SqlContentEntityStorageException(SafeMarkup::format('Table information not available for the "@field_name" field.', array('@field_name' => $field_name))); + throw new SqlContentEntityStorageException("Table information not available for the '$field_name' field."); } return $result; @@ -211,7 +210,7 @@ class DefaultTableMapping implements TableMappingInterface { $column_name = !in_array($property_name, $this->getReservedColumns()) ? $field_name . '_' . $property_name : $property_name; } else { - throw new SqlContentEntityStorageException(SafeMarkup::format('Column information not available for the "@field_name" field.', array('@field_name' => $field_name))); + throw new SqlContentEntityStorageException("Column information not available for the '$field_name' field."); } return $column_name; diff --git a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php index 28a5afa5084..689655af291 100644 --- a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php +++ b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php @@ -7,7 +7,6 @@ namespace Drupal\Core\Entity\Sql; -use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Database\Connection; use Drupal\Core\Database\Database; @@ -266,7 +265,7 @@ class SqlContentEntityStorage extends ContentEntityStorageBase implements SqlEnt $this->initTableLayout(); } else { - throw new EntityStorageException(SafeMarkup::format('Unsupported entity type @id', array('@id' => $entity_type->id()))); + throw new EntityStorageException("Unsupported entity type {$entity_type->id()}"); } } @@ -924,7 +923,7 @@ class SqlContentEntityStorage extends ContentEntityStorageBase implements SqlEnt foreach ($table_mapping->getFieldNames($table_name) as $field_name) { if (empty($this->getFieldStorageDefinitions()[$field_name])) { - throw new EntityStorageException(SafeMarkup::format('Table mapping contains invalid field %field.', array('%field' => $field_name))); + throw new EntityStorageException("Table mapping contains invalid field $field_name."); } $definition = $this->getFieldStorageDefinitions()[$field_name]; $columns = $table_mapping->getColumnNames($field_name); diff --git a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php index 24f46508e3a..8a96e513cf0 100644 --- a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php +++ b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php @@ -7,7 +7,6 @@ namespace Drupal\Core\Entity\Sql; -use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Database\Connection; use Drupal\Core\Database\DatabaseException; use Drupal\Core\Entity\ContentEntityTypeInterface; @@ -286,7 +285,7 @@ class SqlContentEntityStorageSchema implements DynamicallyFieldableEntityStorage // If a migration is required, we can't proceed. if ($this->requiresEntityDataMigration($entity_type, $original)) { - throw new EntityStorageException(SafeMarkup::format('The SQL storage cannot change the schema for an existing entity type with data.')); + throw new EntityStorageException('The SQL storage cannot change the schema for an existing entity type with data.'); } // If we have no data just recreate the entity schema from scratch. @@ -467,7 +466,7 @@ class SqlContentEntityStorageSchema implements DynamicallyFieldableEntityStorage */ protected function checkEntityType(EntityTypeInterface $entity_type) { if ($entity_type->id() != $this->entityType->id()) { - throw new EntityStorageException(SafeMarkup::format('Unsupported entity type @id', array('@id' => $entity_type->id()))); + throw new EntityStorageException("Unsupported entity type {$entity_type->id()}"); } return TRUE; } @@ -530,7 +529,7 @@ class SqlContentEntityStorageSchema implements DynamicallyFieldableEntityStorage } foreach ($table_mapping->getFieldNames($table_name) as $field_name) { if (!isset($storage_definitions[$field_name])) { - throw new FieldException(SafeMarkup::format('Field storage definition for "@field_name" could not be found.', array('@field_name' => $field_name))); + throw new FieldException("Field storage definition for '$field_name' could not be found."); } // Add the schema for base field definitions. elseif ($table_mapping->allowsSharedTableStorage($storage_definitions[$field_name])) { @@ -1430,7 +1429,7 @@ class SqlContentEntityStorageSchema implements DynamicallyFieldableEntityStorage // Check that the schema does not include forbidden column names. if (array_intersect(array_keys($field_schema['columns']), $this->storage->getTableMapping()->getReservedColumns())) { - throw new FieldException(format_string('Illegal field column names on @field_name', array('@field_name' => $storage_definition->getName()))); + throw new FieldException("Illegal field column names on {$storage_definition->getName()}"); } $field_name = $storage_definition->getName(); @@ -1652,7 +1651,7 @@ class SqlContentEntityStorageSchema implements DynamicallyFieldableEntityStorage $properties = $storage_definition->getPropertyDefinitions(); $table_mapping = $this->storage->getTableMapping(); if (array_intersect(array_keys($schema['columns']), $table_mapping->getReservedColumns())) { - throw new FieldException(format_string('Illegal field column names on @field_name', array('@field_name' => $storage_definition->getName()))); + throw new FieldException("Illegal field column names on {$storage_definition->getName()}"); } // Add field columns. diff --git a/core/lib/Drupal/Core/Extension/ModuleHandler.php b/core/lib/Drupal/Core/Extension/ModuleHandler.php index ce5af4f63c1..f97897c18e0 100644 --- a/core/lib/Drupal/Core/Extension/ModuleHandler.php +++ b/core/lib/Drupal/Core/Extension/ModuleHandler.php @@ -9,7 +9,6 @@ namespace Drupal\Core\Extension; use Drupal\Component\Graph\Graph; use Drupal\Component\Utility\NestedArray; -use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Cache\Cache; use Drupal\Core\Cache\CacheBackendInterface; @@ -581,7 +580,7 @@ class ModuleHandler implements ModuleHandlerInterface { } // If a new implementation was added, verify that the function exists. if (!function_exists($module . '_' . $hook)) { - throw new \RuntimeException(SafeMarkup::format('An invalid implementation @function was added by hook_module_implements_alter()', array('@function' => $module . '_' . $hook))); + throw new \RuntimeException("An invalid implementation {$module}_{$hook} was added by hook_module_implements_alter()"); } } } diff --git a/core/lib/Drupal/Core/Extension/ModuleInstaller.php b/core/lib/Drupal/Core/Extension/ModuleInstaller.php index 56902a7aba2..41e698c1d0d 100644 --- a/core/lib/Drupal/Core/Extension/ModuleInstaller.php +++ b/core/lib/Drupal/Core/Extension/ModuleInstaller.php @@ -13,7 +13,6 @@ use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Config\PreExistingConfigException; use Drupal\Core\Config\StorageInterface; use Drupal\Core\DrupalKernelInterface; -use Drupal\Component\Utility\SafeMarkup; /** * Default implementation of the module installer. @@ -88,10 +87,7 @@ class ModuleInstaller implements ModuleInstallerInterface { $module_list = $module_list ? array_combine($module_list, $module_list) : array(); if ($missing_modules = array_diff_key($module_list, $module_data)) { // One or more of the given modules doesn't exist. - throw new MissingDependencyException(SafeMarkup::format('Unable to install modules %modules due to missing modules %missing.', array( - '%modules' => implode(', ', $module_list), - '%missing' => implode(', ', $missing_modules), - ))); + throw new MissingDependencyException(sprintf('Unable to install modules %s due to missing modules %s.', implode(', ', $module_list), implode(', ', $missing_modules))); } // Only process currently uninstalled modules. @@ -107,10 +103,7 @@ class ModuleInstaller implements ModuleInstallerInterface { foreach (array_keys($module_data[$module]->requires) as $dependency) { if (!isset($module_data[$dependency])) { // The dependency does not exist. - throw new MissingDependencyException(SafeMarkup::format('Unable to install modules: module %module is missing its dependency module %dependency.', array( - '%module' => $module, - '%dependency' => $dependency, - ))); + throw new MissingDependencyException("Unable to install modules: module '$module' is missing its dependency module $dependency."); } // Skip already installed modules. @@ -145,10 +138,7 @@ class ModuleInstaller implements ModuleInstallerInterface { if (!$enabled) { // Throw an exception if the module name is too long. if (strlen($module) > DRUPAL_EXTENSION_NAME_MAX_LENGTH) { - throw new ExtensionNameLengthException(format_string('Module name %name is over the maximum allowed length of @max characters.', array( - '%name' => $module, - '@max' => DRUPAL_EXTENSION_NAME_MAX_LENGTH, - ))); + throw new ExtensionNameLengthException("Module name '$module' is over the maximum allowed length of " . DRUPAL_EXTENSION_NAME_MAX_LENGTH . ' characters'); } // Check the validity of the default configuration. This will throw @@ -329,9 +319,7 @@ class ModuleInstaller implements ModuleInstallerInterface { foreach ($reasons as $reason) { $reason_message[] = implode(', ', $reason); } - throw new ModuleUninstallValidatorException(format_string('The following reasons prevents the modules from being uninstalled: @reasons', array( - '@reasons' => implode('; ', $reason_message), - ))); + throw new ModuleUninstallValidatorException('The following reasons prevents the modules from being uninstalled: ' . implode('; ', $reason_message)); } // Set the actual module weights. $module_list = array_map(function ($module) use ($module_data) { diff --git a/core/lib/Drupal/Core/Extension/ThemeHandler.php b/core/lib/Drupal/Core/Extension/ThemeHandler.php index 4059d791cd2..2eb56bc6070 100644 --- a/core/lib/Drupal/Core/Extension/ThemeHandler.php +++ b/core/lib/Drupal/Core/Extension/ThemeHandler.php @@ -429,7 +429,7 @@ class ThemeHandler implements ThemeHandlerInterface { public function getName($theme) { $themes = $this->listInfo(); if (!isset($themes[$theme])) { - throw new \InvalidArgumentException(SafeMarkup::format('Requested the name of a non-existing theme @theme', array('@theme' => $theme))); + throw new \InvalidArgumentException("Requested the name of a non-existing theme $theme"); } return SafeMarkup::checkPlain($themes[$theme]->info['name']); } diff --git a/core/lib/Drupal/Core/Extension/ThemeInstaller.php b/core/lib/Drupal/Core/Extension/ThemeInstaller.php index 1bebca2dbd3..b3b391eb396 100644 --- a/core/lib/Drupal/Core/Extension/ThemeInstaller.php +++ b/core/lib/Drupal/Core/Extension/ThemeInstaller.php @@ -7,7 +7,6 @@ namespace Drupal\Core\Extension; -use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Asset\AssetCollectionOptimizerInterface; use Drupal\Core\Cache\Cache; use Drupal\Core\Config\ConfigFactoryInterface; @@ -113,9 +112,7 @@ class ThemeInstaller implements ThemeInstallerInterface { if ($missing = array_diff_key($theme_list, $theme_data)) { // One or more of the given themes doesn't exist. - throw new \InvalidArgumentException(SafeMarkup::format('Unknown themes: !themes.', array( - '!themes' => implode(', ', $missing), - ))); + throw new \InvalidArgumentException('Unknown themes: ' . implode(', ', $missing) . '.'); } // Only process themes that are not installed currently. @@ -164,10 +161,7 @@ class ThemeInstaller implements ThemeInstallerInterface { // Throw an exception if the theme name is too long. if (strlen($key) > DRUPAL_EXTENSION_NAME_MAX_LENGTH) { - throw new ExtensionNameLengthException(SafeMarkup::format('Theme name %name is over the maximum allowed length of @max characters.', array( - '%name' => $key, - '@max' => DRUPAL_EXTENSION_NAME_MAX_LENGTH, - ))); + throw new ExtensionNameLengthException("Theme name $key is over the maximum allowed length of " . DRUPAL_EXTENSION_NAME_MAX_LENGTH . ' characters.'); } // Validate default configuration of the theme. If there is existing diff --git a/core/lib/Drupal/Core/Field/Entity/BaseFieldOverride.php b/core/lib/Drupal/Core/Field/Entity/BaseFieldOverride.php index 32862d11355..ecf7665aba0 100644 --- a/core/lib/Drupal/Core/Field/Entity/BaseFieldOverride.php +++ b/core/lib/Drupal/Core/Field/Entity/BaseFieldOverride.php @@ -7,7 +7,6 @@ namespace Drupal\Core\Field\Entity; -use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Field\BaseFieldDefinition; use Drupal\Core\Field\FieldConfigBase; @@ -103,10 +102,10 @@ class BaseFieldOverride extends FieldConfigBase { throw new FieldException('Attempt to create a base field bundle override of a field without a field_name'); } if (empty($values['entity_type'])) { - throw new FieldException(SafeMarkup::format('Attempt to create a base field bundle override of field @field_name without an entity_type', array('@field_name' => $values['field_name']))); + throw new FieldException("Attempt to create a base field bundle override of field {$values['field_name']} without an entity_type"); } if (empty($values['bundle'])) { - throw new FieldException(SafeMarkup::format('Attempt to create a base field bundle override of field @field_name without a bundle', array('@field_name' => $values['field_name']))); + throw new FieldException("Attempt to create a base field bundle override of field {$values['field_name']} without a bundle"); } parent::__construct($values, $entity_type); @@ -188,10 +187,10 @@ class BaseFieldOverride extends FieldConfigBase { else { // Some updates are always disallowed. if ($this->entity_type != $this->original->entity_type) { - throw new FieldException(SafeMarkup::format('Cannot change the entity_type of an existing base field bundle override (entity type:@entity_type, bundle:@bundle, field name: @field_name)', array('@field_name' => $this->field_name, '@entity_type' => $this->entity_type, '@bundle' => $this->original->bundle))); + throw new FieldException("Cannot change the entity_type of an existing base field bundle override (entity type:{$this->entity_type}, bundle:{$this->original->bundle}, field name: {$this->field_name})"); } if ($this->bundle != $this->original->bundle && empty($this->bundleRenameAllowed)) { - throw new FieldException(SafeMarkup::format('Cannot change the bundle of an existing base field bundle override (entity type:@entity_type, bundle:@bundle, field name: @field_name)', array('@field_name' => $this->field_name, '@entity_type' => $this->entity_type, '@bundle' => $this->original->bundle))); + throw new FieldException("Cannot change the bundle of an existing base field bundle override (entity type:{$this->entity_type}, bundle:{$this->original->bundle}, field name: {$this->field_name})"); } $previous_definition = $this->original; } diff --git a/core/lib/Drupal/Core/Field/FieldConfigBase.php b/core/lib/Drupal/Core/Field/FieldConfigBase.php index a7790a3bef0..00fc5677351 100644 --- a/core/lib/Drupal/Core/Field/FieldConfigBase.php +++ b/core/lib/Drupal/Core/Field/FieldConfigBase.php @@ -12,7 +12,6 @@ use Drupal\Core\Config\Entity\ConfigEntityBase; use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Entity\FieldableEntityInterface; use Drupal\Core\Field\TypedData\FieldItemDataDefinition; -use Drupal\Component\Utility\SafeMarkup; /** * Base class for configurable field definitions. @@ -254,7 +253,7 @@ abstract class FieldConfigBase extends ConfigEntityBase implements FieldConfigIn $bundle_entity_type_id = $this->entityManager()->getDefinition($this->entity_type)->getBundleEntityType(); if ($bundle_entity_type_id != 'bundle') { if (!$bundle_entity = $this->entityManager()->getStorage($bundle_entity_type_id)->load($this->bundle)) { - throw new \LogicException(SafeMarkup::format('Missing bundle entity, entity type %type, entity id %bundle.', array('%type' => $bundle_entity_type_id, '%bundle' => $this->bundle))); + throw new \LogicException("Missing bundle entity, entity type {$bundle_entity_type_id}, entity id {$this->bundle}."); } $this->addDependency('config', $bundle_entity->getConfigDependencyName()); } diff --git a/core/lib/Drupal/Core/Form/FormBuilder.php b/core/lib/Drupal/Core/Form/FormBuilder.php index a24330d77f2..fe6d104ee4e 100644 --- a/core/lib/Drupal/Core/Form/FormBuilder.php +++ b/core/lib/Drupal/Core/Form/FormBuilder.php @@ -10,7 +10,6 @@ namespace Drupal\Core\Form; use Drupal\Component\Utility\Crypt; use Drupal\Component\Utility\Html; use Drupal\Component\Utility\NestedArray; -use Drupal\Component\Utility\SafeMarkup; use Drupal\Component\Utility\UrlHelper; use Drupal\Core\Access\AccessResultInterface; use Drupal\Core\Access\CsrfTokenGenerator; @@ -153,7 +152,7 @@ class FormBuilder implements FormBuilderInterface, FormValidatorInterface, FormS } if (!is_object($form_arg) || !($form_arg instanceof FormInterface)) { - throw new \InvalidArgumentException(SafeMarkup::format('The form argument @form_arg is not a valid form.', array('@form_arg' => $form_arg))); + throw new \InvalidArgumentException("The form argument $form_arg is not a valid form."); } // Add the $form_arg as the callback object and determine the form ID. diff --git a/core/lib/Drupal/Core/ImageToolkit/ImageToolkitOperationBase.php b/core/lib/Drupal/Core/ImageToolkit/ImageToolkitOperationBase.php index 4fd6bdcf9af..9e21c039ea4 100644 --- a/core/lib/Drupal/Core/ImageToolkit/ImageToolkitOperationBase.php +++ b/core/lib/Drupal/Core/ImageToolkit/ImageToolkitOperationBase.php @@ -8,7 +8,6 @@ namespace Drupal\Core\ImageToolkit; use Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException; -use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Plugin\PluginBase; use Psr\Log\LoggerInterface; @@ -114,7 +113,7 @@ abstract class ImageToolkitOperationBase extends PluginBase implements ImageTool if ($argument['required']) { if (!array_key_exists($id, $arguments)) { // If the argument is required throw an exception. - throw new \InvalidArgumentException(SafeMarkup::format("Argument '@argument' expected by plugin '@plugin' but not passed", array('@argument' => $id, '@plugin' => $this->getPluginId()))); + throw new \InvalidArgumentException("Argument '$id' expected by plugin '{$this->getPluginId()}' but not passed"); } } else { @@ -124,7 +123,7 @@ abstract class ImageToolkitOperationBase extends PluginBase implements ImageTool if (!array_key_exists('default', $argument)) { // The plugin did not define a default, so throw a plugin exception, // not an invalid argument exception. - throw new InvalidPluginDefinitionException(SafeMarkup::format("Default for argument '@argument' expected by plugin '@plugin' but not defined", array('@argument' => $id, '@plugin' => $this->getPluginId()))); + throw new InvalidPluginDefinitionException("Default for argument '$id' expected by plugin '{$this->getPluginId()}' but not defined"); } // Use the default value if the argument is not passed in. diff --git a/core/lib/Drupal/Core/Menu/InaccessibleMenuLink.php b/core/lib/Drupal/Core/Menu/InaccessibleMenuLink.php index 075e3569d1f..1dad00d6f00 100644 --- a/core/lib/Drupal/Core/Menu/InaccessibleMenuLink.php +++ b/core/lib/Drupal/Core/Menu/InaccessibleMenuLink.php @@ -8,7 +8,6 @@ namespace Drupal\Core\Menu; use Drupal\Component\Plugin\Exception\PluginException; -use Drupal\Component\Utility\SafeMarkup; /** * A menu link plugin for wrapping another menu link, in sensitive situations. @@ -80,7 +79,7 @@ class InaccessibleMenuLink extends MenuLinkBase { * {@inheritdoc} */ public function updateLink(array $new_definition_values, $persist) { - throw new PluginException(SafeMarkup::format('Inaccessible menu link plugins do not support updating')); + throw new PluginException('Inaccessible menu link plugins do not support updating'); } } diff --git a/core/lib/Drupal/Core/Menu/MenuLinkBase.php b/core/lib/Drupal/Core/Menu/MenuLinkBase.php index 70774dfed51..6ecfbdf58da 100644 --- a/core/lib/Drupal/Core/Menu/MenuLinkBase.php +++ b/core/lib/Drupal/Core/Menu/MenuLinkBase.php @@ -8,7 +8,6 @@ namespace Drupal\Core\Menu; use Drupal\Component\Plugin\Exception\PluginException; -use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Cache\Cache; use Drupal\Core\Plugin\PluginBase; use Drupal\Core\Url; @@ -170,7 +169,7 @@ abstract class MenuLinkBase extends PluginBase implements MenuLinkInterface { * {@inheritdoc} */ public function deleteLink() { - throw new PluginException(SafeMarkup::format('Menu link plugin with ID @id does not support deletion', array('@id' => $this->getPluginId()))); + throw new PluginException("Menu link plugin with ID '{$this->getPluginId()}' does not support deletion"); } /** diff --git a/core/lib/Drupal/Core/Menu/MenuLinkManager.php b/core/lib/Drupal/Core/Menu/MenuLinkManager.php index b4c77604504..5a18a31bf99 100644 --- a/core/lib/Drupal/Core/Menu/MenuLinkManager.php +++ b/core/lib/Drupal/Core/Menu/MenuLinkManager.php @@ -10,7 +10,6 @@ namespace Drupal\Core\Menu; use Drupal\Component\Plugin\Exception\PluginException; use Drupal\Component\Plugin\Exception\PluginNotFoundException; use Drupal\Component\Utility\NestedArray; -use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Plugin\Discovery\ContainerDerivativeDiscoveryDecorator; use Drupal\Core\Plugin\Discovery\YamlDiscovery; @@ -287,7 +286,7 @@ class MenuLinkManager implements MenuLinkManagerInterface { } } else { - throw new PluginException(SafeMarkup::format('Menu link plugin with ID @id does not support deletion', array('@id' => $id))); + throw new PluginException("Menu link plugin with ID '$id' does not support deletion"); } $this->treeStorage->delete($id); } @@ -355,7 +354,7 @@ class MenuLinkManager implements MenuLinkManagerInterface { */ public function addDefinition($id, array $definition) { if ($this->treeStorage->load($id) || $id === '') { - throw new PluginException(SafeMarkup::format('The ID @id already exists as a plugin definition or is not valid', array('@id' => $id))); + throw new PluginException("The ID $id already exists as a plugin definition or is not valid"); } // Add defaults, so there is no requirement to specify everything. $this->processDefinition($definition, $id); @@ -402,7 +401,7 @@ class MenuLinkManager implements MenuLinkManagerInterface { $id = $instance->getPluginId(); if (!$instance->isResettable()) { - throw new PluginException(SafeMarkup::format('Menu link %id is not resettable', array('%id' => $id))); + throw new PluginException("Menu link $id is not resettable"); } // Get the original data from disk, reset the override and re-save the menu // tree for this link. diff --git a/core/lib/Drupal/Core/Menu/MenuTreeStorage.php b/core/lib/Drupal/Core/Menu/MenuTreeStorage.php index 659d6be3926..3f2d403d6cd 100644 --- a/core/lib/Drupal/Core/Menu/MenuTreeStorage.php +++ b/core/lib/Drupal/Core/Menu/MenuTreeStorage.php @@ -8,7 +8,6 @@ namespace Drupal\Core\Menu; use Drupal\Component\Plugin\Exception\PluginException; -use Drupal\Component\Utility\SafeMarkup; use Drupal\Component\Utility\UrlHelper; use Drupal\Core\Cache\Cache; use Drupal\Core\Cache\CacheBackendInterface; @@ -476,7 +475,7 @@ class MenuTreeStorage implements MenuTreeStorageInterface { $limit = $this->maxDepth() - 1; } if ($parent['depth'] > $limit) { - throw new PluginException(SafeMarkup::format('The link with ID @id or its children exceeded the maximum depth of @depth', array('@id' => $fields['id'], '@depth' => $this->maxDepth()))); + throw new PluginException("The link with ID {$fields['id']} or its children exceeded the maximum depth of {$this->maxDepth()}"); } $fields['depth'] = $parent['depth'] + 1; $i = 1; @@ -637,7 +636,7 @@ class MenuTreeStorage implements MenuTreeStorageInterface { foreach ($properties as $name => $value) { if (!in_array($name, $this->definitionFields(), TRUE)) { $fields = implode(', ', $this->definitionFields()); - throw new \InvalidArgumentException(SafeMarkup::format('An invalid property name, @name was specified. Allowed property names are: @fields.', array('@name' => $name, '@fields' => $fields))); + throw new \InvalidArgumentException("An invalid property name, $name was specified. Allowed property names are: $fields."); } $query->condition($name, $value); } diff --git a/core/lib/Drupal/Core/Plugin/Context/Context.php b/core/lib/Drupal/Core/Plugin/Context/Context.php index 5a5ab6cc66f..837d601d922 100644 --- a/core/lib/Drupal/Core/Plugin/Context/Context.php +++ b/core/lib/Drupal/Core/Plugin/Context/Context.php @@ -9,7 +9,6 @@ namespace Drupal\Core\Plugin\Context; use Drupal\Component\Plugin\Context\Context as ComponentContext; use Drupal\Component\Plugin\Exception\ContextException; -use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Cache\CacheableDependencyInterface; use Drupal\Core\Cache\CacheableMetadata; use Drupal\Core\TypedData\TypedDataInterface; @@ -66,7 +65,7 @@ class Context extends ComponentContext implements ContextInterface { } elseif ($definition->isRequired()) { $type = $definition->getDataType(); - throw new ContextException(SafeMarkup::format("The @type context is required and not present.", array('@type' => $type))); + throw new ContextException("The '$type' context is required and not present."); } return $default_value; } diff --git a/core/lib/Drupal/Core/Plugin/Context/ContextDefinition.php b/core/lib/Drupal/Core/Plugin/Context/ContextDefinition.php index 34ad3621bdd..40fd662492e 100644 --- a/core/lib/Drupal/Core/Plugin/Context/ContextDefinition.php +++ b/core/lib/Drupal/Core/Plugin/Context/ContextDefinition.php @@ -7,7 +7,6 @@ namespace Drupal\Core\Plugin\Context; -use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\TypedData\TypedDataTrait; /** @@ -245,7 +244,7 @@ class ContextDefinition implements ContextDefinitionInterface { } if (!$definition) { - throw new \Exception(SafeMarkup::format('The data type "@type" is invalid', array('@type' => $this->getDataType()))); + throw new \Exception("The data type '{$this->getDataType()}' is invalid"); } $definition->setLabel($this->getLabel()) ->setDescription($this->getDescription()) diff --git a/core/lib/Drupal/Core/Plugin/Context/ContextHandler.php b/core/lib/Drupal/Core/Plugin/Context/ContextHandler.php index 5e5f126b981..373c73c982c 100644 --- a/core/lib/Drupal/Core/Plugin/Context/ContextHandler.php +++ b/core/lib/Drupal/Core/Plugin/Context/ContextHandler.php @@ -8,7 +8,6 @@ namespace Drupal\Core\Plugin\Context; use Drupal\Component\Plugin\Exception\ContextException; -use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Cache\CacheableDependencyInterface; use Drupal\Core\Plugin\ContextAwarePluginInterface; @@ -119,7 +118,7 @@ class ContextHandler implements ContextHandlerInterface { // If there are any mappings that were not satisfied, throw an exception. if (!empty($mappings)) { - throw new ContextException(SafeMarkup::format('Assigned contexts were not satisfied: @mappings', ['@mappings' => implode(',', array_keys($mappings))])); + throw new ContextException('Assigned contexts were not satisfied: ' . implode(',', array_keys($mappings))); } } diff --git a/core/lib/Drupal/Core/Routing/RequestFormatRouteFilter.php b/core/lib/Drupal/Core/Routing/RequestFormatRouteFilter.php index 4d5189a2d30..a0f02385229 100644 --- a/core/lib/Drupal/Core/Routing/RequestFormatRouteFilter.php +++ b/core/lib/Drupal/Core/Routing/RequestFormatRouteFilter.php @@ -7,7 +7,6 @@ namespace Drupal\Core\Routing; -use Drupal\Component\Utility\SafeMarkup; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Exception\NotAcceptableHttpException; use Symfony\Component\Routing\Route; @@ -51,7 +50,7 @@ class RequestFormatRouteFilter implements RouteFilterInterface { // We do not throw a // \Symfony\Component\Routing\Exception\ResourceNotFoundException here // because we don't want to return a 404 status code, but rather a 406. - throw new NotAcceptableHttpException(SafeMarkup::format('No route found for the specified format @format.', ['@format' => $format])); + throw new NotAcceptableHttpException("No route found for the specified format $format."); } } diff --git a/core/lib/Drupal/Core/TypedData/ListDataDefinition.php b/core/lib/Drupal/Core/TypedData/ListDataDefinition.php index b710a75ea5e..e0fd5306d3b 100644 --- a/core/lib/Drupal/Core/TypedData/ListDataDefinition.php +++ b/core/lib/Drupal/Core/TypedData/ListDataDefinition.php @@ -87,7 +87,7 @@ class ListDataDefinition extends DataDefinition implements ListDataDefinitionInt $item_type_definition = \Drupal::typedDataManager() ->getDefinition($this->getItemDefinition()->getDataType()); if (!$item_type_definition) { - throw new \LogicException(format_string('An invalid data type @plugin_id has been specified for list items.', array('@plugin_id' => $this->getItemDefinition()->getDataType()))); + throw new \LogicException("An invalid data type '{$this->getItemDefinition()->getDataType()}' has been specified for list items"); } return $item_type_definition['list_class']; } diff --git a/core/lib/Drupal/Core/TypedData/TypedDataManager.php b/core/lib/Drupal/Core/TypedData/TypedDataManager.php index 89fa657ea9e..858d13d1fa7 100644 --- a/core/lib/Drupal/Core/TypedData/TypedDataManager.php +++ b/core/lib/Drupal/Core/TypedData/TypedDataManager.php @@ -8,7 +8,6 @@ namespace Drupal\Core\TypedData; use Drupal\Component\Plugin\Exception\PluginException; -use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\DependencyInjection\ClassResolverInterface; use Drupal\Core\DependencyInjection\DependencySerializationTrait; @@ -99,7 +98,7 @@ class TypedDataManager extends DefaultPluginManager { $type_definition = $this->getDefinition($data_type); if (!isset($type_definition)) { - throw new \InvalidArgumentException(format_string('Invalid data type %plugin_id has been given.', array('%plugin_id' => $data_type))); + throw new \InvalidArgumentException("Invalid data type '$data_type' has been given"); } // Allow per-data definition overrides of the used classes, i.e. take over @@ -179,7 +178,7 @@ class TypedDataManager extends DefaultPluginManager { public function createDataDefinition($data_type) { $type_definition = $this->getDefinition($data_type); if (!isset($type_definition)) { - throw new \InvalidArgumentException(format_string('Invalid data type %plugin_id has been given.', array('%plugin_id' => $data_type))); + throw new \InvalidArgumentException("Invalid data type '$data_type' has been given"); } $class = $type_definition['definition_class']; return $class::createFromDataType($data_type); @@ -199,7 +198,7 @@ class TypedDataManager extends DefaultPluginManager { public function createListDataDefinition($item_type) { $type_definition = $this->getDefinition($item_type); if (!isset($type_definition)) { - throw new \InvalidArgumentException(format_string('Invalid data type %plugin_id has been given.', array('%plugin_id' => $item_type))); + throw new \InvalidArgumentException("Invalid data type '$item_type' has been given"); } $class = $type_definition['list_definition_class']; return $class::createFromItemType($item_type); @@ -298,7 +297,7 @@ class TypedDataManager extends DefaultPluginManager { throw new \InvalidArgumentException("The passed object has to either implement the ComplexDataInterface or the ListInterface."); } if (!$definition) { - throw new \InvalidArgumentException('Property ' . SafeMarkup::checkPlain($property_name) . ' is unknown.'); + throw new \InvalidArgumentException("Property $property_name is unknown."); } // Create the prototype without any value, but with initial parenting // so that constructors can set up the objects correclty. diff --git a/core/lib/Drupal/Core/Url.php b/core/lib/Drupal/Core/Url.php index e3496270002..5da8ffb85a7 100644 --- a/core/lib/Drupal/Core/Url.php +++ b/core/lib/Drupal/Core/Url.php @@ -7,7 +7,6 @@ namespace Drupal\Core; -use Drupal\Component\Utility\SafeMarkup; use Drupal\Component\Utility\UrlHelper; use Drupal\Core\DependencyInjection\DependencySerializationTrait; use Drupal\Core\Routing\RouteMatchInterface; @@ -232,7 +231,7 @@ class Url { // because these are URI reserved characters that a scheme name may not // start with. if ((strpos($user_input, '/') !== 0) && (strpos($user_input, '#') !== 0) && (strpos($user_input, '?') !== 0)) { - throw new \InvalidArgumentException(SafeMarkup::format("The user-entered string @user_input must begin with a '/', '?', or '#'.", ['@user_input' => $user_input])); + throw new \InvalidArgumentException("The user-entered string '$user_input' must begin with a '/', '?', or '#'."); } // fromUri() requires an absolute URI, so prepend the appropriate scheme @@ -296,10 +295,10 @@ class Url { public static function fromUri($uri, $options = []) { $uri_parts = parse_url($uri); if ($uri_parts === FALSE) { - throw new \InvalidArgumentException(SafeMarkup::format('The URI "@uri" is malformed.', ['@uri' => $uri])); + throw new \InvalidArgumentException("The URI '$uri' is malformed."); } if (empty($uri_parts['scheme'])) { - throw new \InvalidArgumentException(SafeMarkup::format('The URI "@uri" is invalid. You must use a valid URI scheme.', ['@uri' => $uri])); + throw new \InvalidArgumentException("The URI '$uri' is invalid. You must use a valid URI scheme."); } $uri_parts += ['path' => '']; // Discard empty fragment in $options for consistency with parse_url(). @@ -362,7 +361,7 @@ class Url { protected static function fromEntityUri(array $uri_parts, array $options, $uri) { list($entity_type_id, $entity_id) = explode('/', $uri_parts['path'], 2); if ($uri_parts['scheme'] != 'entity' || $entity_id === '') { - throw new \InvalidArgumentException(SafeMarkup::format('The entity URI "@uri" is invalid. You must specify the entity id in the URL. e.g., entity:node/1 for loading the canonical path to node entity with id 1.', ['@uri' => $uri])); + throw new \InvalidArgumentException("The entity URI '$uri' is invalid. You must specify the entity id in the URL. e.g., entity:node/1 for loading the canonical path to node entity with id 1."); } return new static("entity.$entity_type_id.canonical", [$entity_type_id => $entity_id], $options); @@ -422,13 +421,13 @@ class Url { } else { if ($uri_parts['path'][0] !== '/') { - throw new \InvalidArgumentException(SafeMarkup::format('The internal path component "@path" is invalid. Its path component must have a leading slash, e.g. internal:/foo.', ['@path' => $uri_parts['path']])); + throw new \InvalidArgumentException("The internal path component '{$uri_parts['path']}' is invalid. Its path component must have a leading slash, e.g. internal:/foo."); } // Remove the leading slash. $uri_parts['path'] = substr($uri_parts['path'], 1); if (UrlHelper::isExternal($uri_parts['path'])) { - throw new \InvalidArgumentException(SafeMarkup::format('The internal path component "@path" is external. You are not allowed to specify an external URL together with internal:/.', ['@path' => $uri_parts['path']])); + throw new \InvalidArgumentException("The internal path component '{$uri_parts['path']}' is external. You are not allowed to specify an external URL together with internal:/."); } } @@ -462,7 +461,7 @@ class Url { $route_parts = explode(';', $uri_parts['path'], 2); $route_name = $route_parts[0]; if ($route_name === '') { - throw new \InvalidArgumentException(SafeMarkup::format('The route URI "@uri" is invalid. You must have a route name in the URI. e.g., route:system.admin', ['@uri' => $uri])); + throw new \InvalidArgumentException("The route URI '$uri' is invalid. You must have a route name in the URI. e.g., route:system.admin"); } $route_parameters = []; if (!empty($route_parts[1])) { diff --git a/core/lib/Drupal/Core/Utility/UnroutedUrlAssembler.php b/core/lib/Drupal/Core/Utility/UnroutedUrlAssembler.php index 1e807b3f00c..3c97c4452e7 100644 --- a/core/lib/Drupal/Core/Utility/UnroutedUrlAssembler.php +++ b/core/lib/Drupal/Core/Utility/UnroutedUrlAssembler.php @@ -7,7 +7,6 @@ namespace Drupal\Core\Utility; -use Drupal\Component\Utility\SafeMarkup; use Drupal\Component\Utility\UrlHelper; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\GeneratedUrl; @@ -68,7 +67,7 @@ class UnroutedUrlAssembler implements UnroutedUrlAssemblerInterface { // UrlHelper::isExternal() only returns true for safe protocols. return $this->buildExternalUrl($uri, $options, $collect_bubbleable_metadata); } - throw new \InvalidArgumentException(SafeMarkup::format('The URI "@uri" is invalid. You must use a valid URI scheme. Use base: for a path, e.g., to a Drupal file that needs the base path. Do not use this for internal paths controlled by Drupal.', ['@uri' => $uri])); + throw new \InvalidArgumentException("The URI '$uri' is invalid. You must use a valid URI scheme. Use base: for a path, e.g., to a Drupal file that needs the base path. Do not use this for internal paths controlled by Drupal."); } /** diff --git a/core/modules/block/src/BlockPluginCollection.php b/core/modules/block/src/BlockPluginCollection.php index c1905a79428..b757d232215 100644 --- a/core/modules/block/src/BlockPluginCollection.php +++ b/core/modules/block/src/BlockPluginCollection.php @@ -9,7 +9,6 @@ namespace Drupal\block; use Drupal\Component\Plugin\Exception\PluginException; use Drupal\Component\Plugin\PluginManagerInterface; -use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Plugin\DefaultSingleLazyPluginCollection; /** @@ -56,7 +55,7 @@ class BlockPluginCollection extends DefaultSingleLazyPluginCollection { */ protected function initializePlugin($instance_id) { if (!$instance_id) { - throw new PluginException(SafeMarkup::format("The block '@block' did not specify a plugin.", array('@block' => $this->blockId))); + throw new PluginException("The block '{$this->blockId}' did not specify a plugin."); } try { diff --git a/core/modules/comment/src/Tests/CommentTestTrait.php b/core/modules/comment/src/Tests/CommentTestTrait.php index 58aa9c73be3..d8c54c2ca24 100644 --- a/core/modules/comment/src/Tests/CommentTestTrait.php +++ b/core/modules/comment/src/Tests/CommentTestTrait.php @@ -7,7 +7,6 @@ namespace Drupal\comment\Tests; -use Drupal\Component\Utility\SafeMarkup; use Drupal\Component\Utility\Unicode; use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface; @@ -42,10 +41,7 @@ trait CommentTestTrait { $comment_type_storage = $entity_manager->getStorage('comment_type'); if ($comment_type = $comment_type_storage->load($comment_type_id)) { if ($comment_type->getTargetEntityTypeId() !== $entity_type) { - throw new \InvalidArgumentException(SafeMarkup::format('The given comment type id %id can only be used with the %entity_type entity type', array( - '%id' => $comment_type_id, - '%entity_type' => $entity_type, - ))); + throw new \InvalidArgumentException("The given comment type id $comment_type_id can only be used with the $entity_type entity type"); } } else { diff --git a/core/modules/config/src/Tests/ConfigImporterTest.php b/core/modules/config/src/Tests/ConfigImporterTest.php index ad21c783103..e39baf624ab 100644 --- a/core/modules/config/src/Tests/ConfigImporterTest.php +++ b/core/modules/config/src/Tests/ConfigImporterTest.php @@ -295,8 +295,8 @@ class ConfigImporterTest extends KernelTestBase { $logs = $this->configImporter->getErrors(); $this->assertEqual(count($logs), 1); - $message = SafeMarkup::format('config_test entity with ID @name already exists', array('@name' => 'secondary')); - $this->assertEqual($logs[0], SafeMarkup::format('Unexpected error during import with operation @op for @name: @message.', array('@op' => 'create', '@name' => $name_primary, '@message' => $message))); + $message = SafeMarkup::format("'config_test' entity with ID '@name' already exists", array('@name' => 'secondary')); + $this->assertEqual($logs[0], SafeMarkup::format('Unexpected error during import with operation @op for @name: !message.', array('@op' => 'create', '@name' => $name_primary, '!message' => $message))); } /** diff --git a/core/modules/config_translation/src/ConfigMapperManager.php b/core/modules/config_translation/src/ConfigMapperManager.php index 56b2182eb3c..2731aa0e592 100644 --- a/core/modules/config_translation/src/ConfigMapperManager.php +++ b/core/modules/config_translation/src/ConfigMapperManager.php @@ -7,7 +7,6 @@ namespace Drupal\config_translation; -use Drupal\Component\Utility\SafeMarkup; use Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException; use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Config\TypedConfigManagerInterface; @@ -134,7 +133,7 @@ class ConfigMapperManager extends DefaultPluginManager implements ConfigMapperMa parent::processDefinition($definition, $plugin_id); if (!isset($definition['base_route_name'])) { - throw new InvalidPluginDefinitionException($plugin_id, SafeMarkup::format("The plugin definition of the mapper '%plugin_id' does not contain a base_route_name.", array('%plugin_id' => $plugin_id))); + throw new InvalidPluginDefinitionException($plugin_id, "The plugin definition of the mapper '$plugin_id' does not contain a base_route_name."); } } diff --git a/core/modules/field/src/Entity/FieldConfig.php b/core/modules/field/src/Entity/FieldConfig.php index 500fa426ce4..6054d0221c3 100644 --- a/core/modules/field/src/Entity/FieldConfig.php +++ b/core/modules/field/src/Entity/FieldConfig.php @@ -110,12 +110,12 @@ class FieldConfig extends FieldConfigBase implements FieldConfigInterface { throw new FieldException('Attempt to create a field without a field_name.'); } if (empty($values['entity_type'])) { - throw new FieldException(SafeMarkup::format('Attempt to create a field @field_name without an entity_type.', array('@field_name' => $values['field_name']))); + throw new FieldException("Attempt to create a field '{$values['field_name']}' without an entity_type."); } } // 'bundle' is required in either case. if (empty($values['bundle'])) { - throw new FieldException(SafeMarkup::format('Attempt to create a field @field_name without a bundle.', array('@field_name' => $values['field_name']))); + throw new FieldException("Attempt to create a field '{$values['field_name']}' without a bundle."); } parent::__construct($values, $entity_type); @@ -288,9 +288,10 @@ class FieldConfig extends FieldConfigBase implements FieldConfigInterface { if (!$this->fieldStorage) { $fields = $this->entityManager()->getFieldStorageDefinitions($this->entity_type); if (!isset($fields[$this->field_name])) { - throw new FieldException(SafeMarkup::format('Attempt to create a field @field_name that does not exist on entity type @entity_type.', array('@field_name' => $this->field_name, '@entity_type' => $this->entity_type))); } + throw new FieldException('Attempt to create a field {$this->field_name} that does not exist on entity type {$this->entity_type}.'); + } if (!$fields[$this->field_name] instanceof FieldStorageConfigInterface) { - throw new FieldException(SafeMarkup::format('Attempt to create a configurable field of non-configurable field storage @field_name.', array('@field_name' => $this->field_name, '@entity_type' => $this->entity_type))); + throw new FieldException("Attempt to create a configurable field of non-configurable field storage {$this->field_name}."); } $this->fieldStorage = $fields[$this->field_name]; } diff --git a/core/modules/field/src/Entity/FieldStorageConfig.php b/core/modules/field/src/Entity/FieldStorageConfig.php index 66b6fff4dda..5fff1aa595f 100644 --- a/core/modules/field/src/Entity/FieldStorageConfig.php +++ b/core/modules/field/src/Entity/FieldStorageConfig.php @@ -7,7 +7,6 @@ namespace Drupal\field\Entity; -use Drupal\Component\Utility\SafeMarkup; use Drupal\Component\Utility\Unicode; use Drupal\Core\Config\Entity\ConfigEntityBase; use Drupal\Core\Entity\EntityStorageInterface; @@ -242,13 +241,13 @@ class FieldStorageConfig extends ConfigEntityBase implements FieldStorageConfigI throw new FieldException('Attempt to create a field storage without a field name.'); } if (!preg_match('/^[_a-z]+[_a-z0-9]*$/', $values['field_name'])) { - throw new FieldException(SafeMarkup::format('Attempt to create a field storage @field_name with invalid characters. Only lowercase alphanumeric characters and underscores are allowed, and only lowercase letters and underscore are allowed as the first character', array('@field_name' => $values['field_name']))); + throw new FieldException("Attempt to create a field storage {$values['field_name']} with invalid characters. Only lowercase alphanumeric characters and underscores are allowed, and only lowercase letters and underscore are allowed as the first character"); } if (empty($values['type'])) { - throw new FieldException(SafeMarkup::format('Attempt to create a field storage @field_name with no type.', array('@field_name' => $values['field_name']))); + throw new FieldException("Attempt to create a field storage {$values['field_name']} with no type."); } if (empty($values['entity_type'])) { - throw new FieldException(SafeMarkup::format('Attempt to create a field storage @field_name with no entity_type.', array('@field_name' => $values['field_name']))); + throw new FieldException("Attempt to create a field storage {$values['field_name']} with no entity_type."); } parent::__construct($values, $entity_type); @@ -309,24 +308,19 @@ class FieldStorageConfig extends ConfigEntityBase implements FieldStorageConfigI // We use Unicode::strlen() because the DB layer assumes that column widths // are given in characters rather than bytes. if (Unicode::strlen($this->getName()) > static::NAME_MAX_LENGTH) { - throw new FieldException(SafeMarkup::format( - 'Attempt to create a field storage with an name longer than @max characters: %name', array( - '@max' => static::NAME_MAX_LENGTH, - '%name' => $this->getName(), - ) - )); + throw new FieldException('Attempt to create a field storage with an name longer than ' . static::NAME_MAX_LENGTH . ' characters: ' . $this->getName()); } // Disallow reserved field names. $disallowed_field_names = array_keys($entity_manager->getBaseFieldDefinitions($this->getTargetEntityTypeId())); if (in_array($this->getName(), $disallowed_field_names)) { - throw new FieldException(SafeMarkup::format('Attempt to create field storage %name which is reserved by entity type %type.', array('%name' => $this->getName(), '%type' => $this->getTargetEntityTypeId()))); + throw new FieldException("Attempt to create field storage {$this->getName()} which is reserved by entity type {$this->getTargetEntityTypeId()}."); } // Check that the field type is known. $field_type = $field_type_manager->getDefinition($this->getType(), FALSE); if (!$field_type) { - throw new FieldException(SafeMarkup::format('Attempt to create a field storage of unknown type %type.', array('%type' => $this->getType()))); + throw new FieldException("Attempt to create a field storage of unknown type {$this->getType()}."); } $this->module = $field_type['provider']; diff --git a/core/modules/field/tests/src/Unit/FieldConfigEntityUnitTest.php b/core/modules/field/tests/src/Unit/FieldConfigEntityUnitTest.php index 2bce97d0815..f249c6c15ed 100644 --- a/core/modules/field/tests/src/Unit/FieldConfigEntityUnitTest.php +++ b/core/modules/field/tests/src/Unit/FieldConfigEntityUnitTest.php @@ -178,7 +178,7 @@ class FieldConfigEntityUnitTest extends UnitTestCase { * Test that invalid bundles are handled. * * @expectedException \LogicException - * @expectedExceptionMessage Missing bundle entity, entity type bundle_entity_type, entity id test_bundle_not_exists. + * @expectedExceptionMessage Missing bundle entity, entity type bundle_entity_type, entity id test_bundle_not_exists. */ public function testCalculateDependenciesIncorrectBundle() { $storage = $this->getMock('\Drupal\Core\Config\Entity\ConfigEntityStorageInterface'); diff --git a/core/modules/field_ui/src/Tests/ManageFieldsTest.php b/core/modules/field_ui/src/Tests/ManageFieldsTest.php index 8bd86885ca1..3b2ac3ebab7 100644 --- a/core/modules/field_ui/src/Tests/ManageFieldsTest.php +++ b/core/modules/field_ui/src/Tests/ManageFieldsTest.php @@ -627,7 +627,7 @@ class ManageFieldsTest extends WebTestBase { // The external redirect should not fire. $this->assertUrl('admin/structure/types/manage/article/fields/node.article.body/storage', $options); $this->assertResponse(200); - $this->assertRaw('Attempt to update field Body failed: The internal path component "http://example.com" is external. You are not allowed to specify an external URL together with internal:/..'); + $this->assertRaw('Attempt to update field Body failed: The internal path component 'http://example.com' is external. You are not allowed to specify an external URL together with internal:/..'); } /** diff --git a/core/modules/image/src/Form/ImageEffectFormBase.php b/core/modules/image/src/Form/ImageEffectFormBase.php index 7b7f25b6170..66edd95ba91 100644 --- a/core/modules/image/src/Form/ImageEffectFormBase.php +++ b/core/modules/image/src/Form/ImageEffectFormBase.php @@ -13,7 +13,6 @@ use Drupal\Core\Form\FormStateInterface; use Drupal\image\ConfigurableImageEffectInterface; use Drupal\image\ImageStyleInterface; use Drupal\Component\Plugin\Exception\PluginNotFoundException; -use Drupal\Component\Utility\SafeMarkup; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; /** @@ -61,7 +60,7 @@ abstract class ImageEffectFormBase extends FormBase { $this->imageEffect = $this->prepareImageEffect($image_effect); } catch (PluginNotFoundException $e) { - throw new NotFoundHttpException(SafeMarkup::format("Invalid effect id: '@id'.", array('@id' => $image_effect))); + throw new NotFoundHttpException("Invalid effect id: '$image_effect'."); } $request = $this->getRequest(); diff --git a/core/modules/language/src/Config/LanguageConfigCollectionNameTrait.php b/core/modules/language/src/Config/LanguageConfigCollectionNameTrait.php index 651209ae0d5..00cd1b9f172 100644 --- a/core/modules/language/src/Config/LanguageConfigCollectionNameTrait.php +++ b/core/modules/language/src/Config/LanguageConfigCollectionNameTrait.php @@ -7,8 +7,6 @@ namespace Drupal\language\Config; -use Drupal\Component\Utility\SafeMarkup; - /** * Provides a common trait for working with language override collection names. */ @@ -45,7 +43,7 @@ trait LanguageConfigCollectionNameTrait { protected function getLangcodeFromCollectionName($collection) { preg_match('/^language\.(.*)$/', $collection, $matches); if (!isset($matches[1])) { - throw new \InvalidArgumentException(SafeMarkup::format('!collection is not a valid language override collection', array('!collection' => $collection))); + throw new \InvalidArgumentException("'$collection' is not a valid language override collection"); } return $matches[1]; } diff --git a/core/modules/language/src/Entity/ContentLanguageSettings.php b/core/modules/language/src/Entity/ContentLanguageSettings.php index 76a8a25739c..da69686fed3 100644 --- a/core/modules/language/src/Entity/ContentLanguageSettings.php +++ b/core/modules/language/src/Entity/ContentLanguageSettings.php @@ -7,7 +7,6 @@ namespace Drupal\language\Entity; -use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Config\Entity\ConfigEntityBase; use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Language\LanguageInterface; @@ -200,7 +199,7 @@ class ContentLanguageSettings extends ConfigEntityBase implements ContentLanguag // If the target entity type uses entities to manage its bundles then // depend on the bundle entity. if (!$bundle_entity = $this->entityManager()->getStorage($bundle_entity_type_id)->load($this->target_bundle)) { - throw new \LogicException(SafeMarkup::format('Missing bundle entity, entity type %type, entity id %bundle.', array('%type' => $bundle_entity_type_id, '%bundle' => $this->target_bundle))); + throw new \LogicException("Missing bundle entity, entity type $bundle_entity_type_id, entity id {$this->target_bundle}."); } $this->addDependency('config', $bundle_entity->getConfigDependencyName()); } diff --git a/core/modules/locale/src/StringBase.php b/core/modules/locale/src/StringBase.php index eecd5050057..d0340ef0197 100644 --- a/core/modules/locale/src/StringBase.php +++ b/core/modules/locale/src/StringBase.php @@ -190,9 +190,7 @@ abstract class StringBase implements StringInterface { $storage->save($this); } else { - throw new StringStorageException(SafeMarkup::format('The string cannot be saved because its not bound to a storage: @string', array( - '@string' => $this->getString(), - ))); + throw new StringStorageException('The string cannot be saved because its not bound to a storage: ' . $this->getString()); } return $this; } @@ -206,9 +204,7 @@ abstract class StringBase implements StringInterface { $storage->delete($this); } else { - throw new StringStorageException(SafeMarkup::format('The string cannot be deleted because its not bound to a storage: @string', array( - '@string' => $this->getString(), - ))); + throw new StringStorageException('The string cannot be deleted because its not bound to a storage: ' . $this->getString()); } } return $this; diff --git a/core/modules/locale/src/StringDatabaseStorage.php b/core/modules/locale/src/StringDatabaseStorage.php index 06f9f97dd38..de624849d18 100644 --- a/core/modules/locale/src/StringDatabaseStorage.php +++ b/core/modules/locale/src/StringDatabaseStorage.php @@ -199,9 +199,7 @@ class StringDatabaseStorage implements StringStorageInterface { } } else { - throw new StringStorageException(format_string('The string cannot be deleted because it lacks some key fields: @string', array( - '@string' => $string->getString(), - ))); + throw new StringStorageException('The string cannot be deleted because it lacks some key fields: ' . $string->getString()); } return $this; } @@ -483,9 +481,7 @@ class StringDatabaseStorage implements StringStorageInterface { ->execute(); } else { - throw new StringStorageException(format_string('The string cannot be saved: @string', array( - '@string' => $string->getString(), - ))); + throw new StringStorageException('The string cannot be saved: ' . $string->getString()); } } @@ -516,9 +512,7 @@ class StringDatabaseStorage implements StringStorageInterface { ->execute(); } else { - throw new StringStorageException(format_string('The string cannot be updated: @string', array( - '@string' => $string->getString(), - ))); + throw new StringStorageException('The string cannot be updated: ' . $string->getString()); } } diff --git a/core/modules/menu_link_content/src/Plugin/Menu/MenuLinkContent.php b/core/modules/menu_link_content/src/Plugin/Menu/MenuLinkContent.php index f120b61932c..a9a7d2c6a8a 100644 --- a/core/modules/menu_link_content/src/Plugin/Menu/MenuLinkContent.php +++ b/core/modules/menu_link_content/src/Plugin/Menu/MenuLinkContent.php @@ -8,7 +8,6 @@ namespace Drupal\menu_link_content\Plugin\Menu; use Drupal\Component\Plugin\Exception\PluginException; -use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Language\LanguageManagerInterface; use Drupal\Core\Menu\MenuLinkBase; @@ -138,7 +137,7 @@ class MenuLinkContent extends MenuLinkBase implements ContainerFactoryPluginInte $entity = reset($loaded_entities); } if (!$entity) { - throw new PluginException(SafeMarkup::format('Entity not found through the menu link plugin definition and could not fallback on UUID @uuid', array('@uuid' => $uuid))); + throw new PluginException("Entity not found through the menu link plugin definition and could not fallback on UUID '$uuid'"); } // Clone the entity object to avoid tampering with the static cache. $this->entity = clone $entity; diff --git a/core/modules/migrate/src/Entity/Migration.php b/core/modules/migrate/src/Entity/Migration.php index e3f920cb5d5..c92f975423d 100644 --- a/core/modules/migrate/src/Entity/Migration.php +++ b/core/modules/migrate/src/Entity/Migration.php @@ -7,7 +7,6 @@ namespace Drupal\migrate\Entity; -use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Config\Entity\ConfigEntityBase; use Drupal\migrate\Exception\RequirementsException; use Drupal\migrate\MigrateException; @@ -381,7 +380,7 @@ class Migration extends ConfigEntityBase implements MigrationInterface, Requirem } } if ($missing_migrations) { - throw new RequirementsException(SafeMarkup::format('Missing migrations @requirements.', ['@requirements' => implode(', ', $missing_migrations)]), ['requirements' => $missing_migrations]); + throw new RequirementsException('Missing migrations ' . implode(', ', $missing_migrations) . '.', ['requirements' => $missing_migrations]); } } diff --git a/core/modules/migrate/src/Plugin/migrate/destination/EntityFile.php b/core/modules/migrate/src/Plugin/migrate/destination/EntityFile.php index 817b1c98e2b..57d69092515 100644 --- a/core/modules/migrate/src/Plugin/migrate/destination/EntityFile.php +++ b/core/modules/migrate/src/Plugin/migrate/destination/EntityFile.php @@ -7,7 +7,6 @@ namespace Drupal\migrate\Plugin\migrate\destination; -use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\File\FileSystemInterface; @@ -83,7 +82,7 @@ class EntityFile extends EntityContentBase { // Ensure the source file exists, if it's a local URI or path. if ($this->isLocalUri($source) && !file_exists($source)) { - throw new MigrateException(SafeMarkup::format('File @source does not exist.', ['@source' => $source])); + throw new MigrateException("File '$source' does not exist."); } // If the start and end file is exactly the same, there is nothing to do. @@ -99,7 +98,7 @@ class EntityFile extends EntityContentBase { $success = $this->writeFile($source, $destination, $replace); } else { - throw new MigrateException(SafeMarkup::format('Could not create directory @dir', ['@dir' => $dir])); + throw new MigrateException("Could not create directory '$dir'"); } } @@ -107,7 +106,7 @@ class EntityFile extends EntityContentBase { return parent::import($row, $old_destination_id_values); } else { - throw new MigrateException(SafeMarkup::format('File %source could not be copied to %destination.', ['%source' => $source, '%destination' => $destination])); + throw new MigrateException("File $source could not be copied to $destination."); } } diff --git a/core/modules/migrate/src/Plugin/migrate/process/Concat.php b/core/modules/migrate/src/Plugin/migrate/process/Concat.php index 6e45e5d0234..174818d8037 100644 --- a/core/modules/migrate/src/Plugin/migrate/process/Concat.php +++ b/core/modules/migrate/src/Plugin/migrate/process/Concat.php @@ -7,7 +7,6 @@ namespace Drupal\migrate\Plugin\migrate\process; -use Drupal\Component\Utility\SafeMarkup; use Drupal\migrate\MigrateException; use Drupal\migrate\MigrateExecutableInterface; use Drupal\migrate\ProcessPluginBase; @@ -34,7 +33,7 @@ class Concat extends ProcessPluginBase { return implode($delimiter, $value); } else { - throw new MigrateException(sprintf('%s is not an array', SafeMarkup::checkPlain(var_export($value, TRUE)))); + throw new MigrateException(sprintf('%s is not an array', var_export($value, TRUE))); } } diff --git a/core/modules/migrate/src/Tests/EntityFileTest.php b/core/modules/migrate/src/Tests/EntityFileTest.php index 509e98b6f9d..718e0a7505d 100644 --- a/core/modules/migrate/src/Tests/EntityFileTest.php +++ b/core/modules/migrate/src/Tests/EntityFileTest.php @@ -94,7 +94,7 @@ class EntityFileTest extends KernelTestBase { $this->fail('Expected Drupal\migrate\MigrateException when importing ' . $destination); } catch (MigrateException $e) { - $this->assertIdentical($e->getMessage(), 'File ' . $destination . ' does not exist.'); + $this->assertIdentical($e->getMessage(), "File '$destination' does not exist."); } } diff --git a/core/modules/migrate/tests/src/Unit/TestSqlIdMap.php b/core/modules/migrate/tests/src/Unit/TestSqlIdMap.php index 203bd62dec7..68d80774af4 100644 --- a/core/modules/migrate/tests/src/Unit/TestSqlIdMap.php +++ b/core/modules/migrate/tests/src/Unit/TestSqlIdMap.php @@ -7,7 +7,6 @@ namespace Drupal\Tests\migrate\Unit; -use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Database\Connection; use Drupal\migrate\Entity\MigrationInterface; use Drupal\migrate\MigrateException; @@ -61,7 +60,7 @@ class TestSqlIdMap extends Sql implements \Iterator { 'not null' => FALSE, ); default: - throw new MigrateException(SafeMarkup::format('@type not supported', array('@type' => $id_definition['type']))); + throw new MigrateException($id_definition['type'] . ' not supported'); } } } diff --git a/core/modules/migrate_drupal/src/MigrationStorage.php b/core/modules/migrate_drupal/src/MigrationStorage.php index 06b0c29bc7c..9a33b36078d 100644 --- a/core/modules/migrate_drupal/src/MigrationStorage.php +++ b/core/modules/migrate_drupal/src/MigrationStorage.php @@ -7,7 +7,6 @@ namespace Drupal\migrate_drupal; -use Drupal\Component\Utility\SafeMarkup; use Drupal\Component\Uuid\UuidInterface; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Entity\EntityInterface; @@ -164,7 +163,7 @@ class MigrationStorage extends BaseMigrationStorage { */ public function save(EntityInterface $entity) { if (strpos($entity->id(), ':') !== FALSE) { - throw new EntityStorageException(SafeMarkup::format("Dynamic migration %id can't be saved", array('$%id' => $entity->id()))); + throw new EntityStorageException("Dynamic migration '{$entity->id()}' can't be saved"); } return parent::save($entity); } diff --git a/core/modules/migrate_drupal/src/Plugin/migrate/load/LoadEntity.php b/core/modules/migrate_drupal/src/Plugin/migrate/load/LoadEntity.php index 9edbcd075d7..375fe7bf36e 100644 --- a/core/modules/migrate_drupal/src/Plugin/migrate/load/LoadEntity.php +++ b/core/modules/migrate_drupal/src/Plugin/migrate/load/LoadEntity.php @@ -7,7 +7,6 @@ namespace Drupal\migrate_drupal\Plugin\migrate\load; -use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Plugin\PluginBase; use Drupal\migrate\Entity\MigrationInterface; @@ -44,7 +43,7 @@ class LoadEntity extends PluginBase implements MigrateLoadInterface { throw new MigrateException('Migrations with a load plugin using LoadEntity should have an entity as source.'); } if ($source_plugin->bundleMigrationRequired() && empty($configuration['bundle_migration'])) { - throw new MigrateException(SafeMarkup::format('Source plugin @plugin requires the bundle_migration key to be set.', array('@plugin' => $source_plugin->getPluginId()))); + throw new MigrateException("Source plugin '{$source_plugin->getPluginId()}' requires the bundle_migration key to be set."); } } diff --git a/core/modules/migrate_drupal/src/Plugin/migrate/source/DrupalSqlBase.php b/core/modules/migrate_drupal/src/Plugin/migrate/source/DrupalSqlBase.php index 5257d9401ab..deb7adfdecd 100644 --- a/core/modules/migrate_drupal/src/Plugin/migrate/source/DrupalSqlBase.php +++ b/core/modules/migrate_drupal/src/Plugin/migrate/source/DrupalSqlBase.php @@ -8,7 +8,6 @@ namespace Drupal\migrate_drupal\Plugin\migrate\source; use Drupal\Component\Plugin\DependentPluginInterface; -use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Entity\DependencyTrait; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; @@ -102,11 +101,11 @@ abstract class DrupalSqlBase extends SqlBase implements ContainerFactoryPluginIn if (isset($this->pluginDefinition['source_provider'])) { if ($this->moduleExists($this->pluginDefinition['source_provider'])) { if (isset($this->pluginDefinition['minimum_schema_version']) && !$this->getModuleSchemaVersion($this->pluginDefinition['source_provider']) < $this->pluginDefinition['minimum_schema_version']) { - throw new RequirementsException(SafeMarkup::format('Required minimum schema version @minimum_schema_version', ['@minimum_schema_version' => $this->pluginDefinition['minimum_schema_version']]), ['minimum_schema_version' => $this->pluginDefinition['minimum_schema_version']]); + throw new RequirementsException('Required minimum schema version ' . $this->pluginDefinition['minimum_schema_version'], ['minimum_schema_version' => $this->pluginDefinition['minimum_schema_version']]); } } else { - throw new RequirementsException(SafeMarkup::format('Missing source provider @provider', ['@provider' => $this->pluginDefinition['source_provider']]), ['source_provider' => $this->pluginDefinition['source_provider']]); + throw new RequirementsException('Missing source provider ' . $this->pluginDefinition['source_provider'], ['source_provider' => $this->pluginDefinition['source_provider']]); } } } diff --git a/core/modules/responsive_image/responsive_image.module b/core/modules/responsive_image/responsive_image.module index e7e24650107..86b0a128d64 100644 --- a/core/modules/responsive_image/responsive_image.module +++ b/core/modules/responsive_image/responsive_image.module @@ -5,7 +5,6 @@ * Responsive image display formatter for image fields. */ -use Drupal\Component\Utility\SafeMarkup; use Drupal\Component\Utility\Unicode; use Drupal\Core\Routing\RouteMatchInterface; use \Drupal\Core\Template\Attribute; @@ -333,7 +332,7 @@ function responsive_image_build_source_attributes(ImageInterface $image, array $ // this breakpoint should be merged into one srcset and the sizes // attribute should be merged as well. if (is_null($dimensions['width'])) { - throw new \LogicException(SafeMarkup::format('Could not determine image width for @file using image style with ID: @image_style_name. This image style can not be used for a responsive image style mapping using the \'sizes\' attribute.', array('@file' => $image->getSource(), '@image_style_name' => $image_style_name))); + throw new \LogicException("Could not determine image width for '{$image->getSource()}' using image style with ID: $image_style_name. This image style can not be used for a responsive image style mapping using the 'sizes' attribute."); } // Use the image width as key so we can sort the array later on. // Images within a srcset should be sorted from small to large, since diff --git a/core/modules/rest/src/Plugin/rest/resource/EntityResource.php b/core/modules/rest/src/Plugin/rest/resource/EntityResource.php index 8aa4dc32554..464fe08c0f4 100644 --- a/core/modules/rest/src/Plugin/rest/resource/EntityResource.php +++ b/core/modules/rest/src/Plugin/rest/resource/EntityResource.php @@ -11,7 +11,6 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityStorageException; use Drupal\rest\Plugin\ResourceBase; use Drupal\rest\ResourceResponse; -use Drupal\Component\Utility\SafeMarkup; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Symfony\Component\HttpKernel\Exception\HttpException; @@ -98,7 +97,7 @@ class EntityResource extends ResourceBase { // and 'update', so the 'edit' operation is used here. foreach ($entity->_restSubmittedFields as $key => $field_name) { if (!$entity->get($field_name)->access('edit')) { - throw new AccessDeniedHttpException(SafeMarkup::format('Access denied on creating field @field', array('@field' => $field_name))); + throw new AccessDeniedHttpException("Access denied on creating field '$field_name'"); } } @@ -155,7 +154,7 @@ class EntityResource extends ResourceBase { } if (!$original_entity->get($field_name)->access('edit')) { - throw new AccessDeniedHttpException(SafeMarkup::format('Access denied on updating field @field.', array('@field' => $field_name))); + throw new AccessDeniedHttpException("Access denied on updating field '$field_name'."); } $original_entity->set($field_name, $field->getValue()); } diff --git a/core/modules/simpletest/src/KernelTestBase.php b/core/modules/simpletest/src/KernelTestBase.php index 481b031066d..ba8622b0852 100644 --- a/core/modules/simpletest/src/KernelTestBase.php +++ b/core/modules/simpletest/src/KernelTestBase.php @@ -381,9 +381,7 @@ EOD; protected function installConfig(array $modules) { foreach ($modules as $module) { if (!$this->container->get('module_handler')->moduleExists($module)) { - throw new \RuntimeException(format_string("'@module' module is not enabled.", array( - '@module' => $module, - ))); + throw new \RuntimeException("'$module' module is not enabled"); } \Drupal::service('config.installer')->installDefaultConfig('module', $module); } @@ -411,18 +409,13 @@ EOD; // behavior and non-reproducible test failures, we only allow the schema of // explicitly loaded/enabled modules to be installed. if (!$this->container->get('module_handler')->moduleExists($module)) { - throw new \RuntimeException(format_string("'@module' module is not enabled.", array( - '@module' => $module, - ))); + throw new \RuntimeException("'$module' module is not enabled"); } $tables = (array) $tables; foreach ($tables as $table) { $schema = drupal_get_module_schema($module, $table); if (empty($schema)) { - throw new \RuntimeException(format_string("Unknown '@table' table schema in '@module' module.", array( - '@module' => $module, - '@table' => $table, - ))); + throw new \RuntimeException("Unknown '$table' table schema in '$module' module."); } $this->container->get('database')->schema()->createTable($table, $schema); } diff --git a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Convert.php b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Convert.php index 93b93608d40..a9058714840 100644 --- a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Convert.php +++ b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Convert.php @@ -7,8 +7,6 @@ namespace Drupal\system\Plugin\ImageToolkit\Operation\gd; -use Drupal\Component\Utility\SafeMarkup; - /** * Defines GD2 convert operation. * @@ -38,7 +36,7 @@ class Convert extends GDImageToolkitOperationBase { */ protected function validateArguments(array $arguments) { if (!in_array($arguments['extension'], $this->getToolkit()->getSupportedExtensions())) { - throw new \InvalidArgumentException(SafeMarkup::format("Invalid extension (@value) specified for the image 'convert' operation", array('@value' => $arguments['extension']))); + throw new \InvalidArgumentException("Invalid extension ({$arguments['extension']}) specified for the image 'convert' operation"); } return $arguments; } diff --git a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/CreateNew.php b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/CreateNew.php index 00fecad6373..2b556f73897 100644 --- a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/CreateNew.php +++ b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/CreateNew.php @@ -8,7 +8,6 @@ namespace Drupal\system\Plugin\ImageToolkit\Operation\gd; use Drupal\Component\Utility\Color; -use Drupal\Component\Utility\SafeMarkup; /** * Defines GD2 create_new image operation. @@ -53,7 +52,7 @@ class CreateNew extends GDImageToolkitOperationBase { protected function validateArguments(array $arguments) { // Assure extension is supported. if (!in_array($arguments['extension'], $this->getToolkit()->getSupportedExtensions())) { - throw new \InvalidArgumentException(SafeMarkup::format("Invalid extension (@value) specified for the image 'convert' operation", array('@value' => $arguments['extension']))); + throw new \InvalidArgumentException("Invalid extension ('{$arguments['extension']}') specified for the image 'convert' operation"); } // Assure integers for width and height. @@ -62,15 +61,15 @@ class CreateNew extends GDImageToolkitOperationBase { // Fail when width or height are 0 or negative. if ($arguments['width'] <= 0) { - throw new \InvalidArgumentException(SafeMarkup::format("Invalid width (@value) specified for the image 'create_new' operation", array('@value' => $arguments['width']))); + throw new \InvalidArgumentException("Invalid width ('{$arguments['width']}') specified for the image 'create_new' operation"); } if ($arguments['height'] <= 0) { - throw new \InvalidArgumentException(SafeMarkup::format("Invalid height (@value) specified for the image 'create_new' operation", array('@value' => $arguments['height']))); + throw new \InvalidArgumentException("Invalid height ({$arguments['height']}) specified for the image 'create_new' operation"); } // Assure transparent color is a valid hex string. if ($arguments['transparent_color'] && !Color::validateHex($arguments['transparent_color'])) { - throw new \InvalidArgumentException(SafeMarkup::format("Invalid transparent color (@value) specified for the image 'create_new' operation", array('@value' => $arguments['transparent_color']))); + throw new \InvalidArgumentException("Invalid transparent color ({$arguments['transparent_color']}) specified for the image 'create_new' operation"); } return $arguments; diff --git a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Crop.php b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Crop.php index 21d59f47ded..aed4a2699e6 100644 --- a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Crop.php +++ b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Crop.php @@ -7,8 +7,6 @@ namespace Drupal\system\Plugin\ImageToolkit\Operation\gd; -use Drupal\Component\Utility\SafeMarkup; - /** * Defines GD2 Crop operation. * @@ -67,10 +65,10 @@ class Crop extends GDImageToolkitOperationBase { // Fail when width or height are 0 or negative. if ($arguments['width'] <= 0) { - throw new \InvalidArgumentException(SafeMarkup::format("Invalid width (@value) specified for the image 'crop' operation", array('@value' => $arguments['width']))); + throw new \InvalidArgumentException("Invalid width ('{$arguments['width']}') specified for the image 'crop' operation"); } if ($arguments['height'] <= 0) { - throw new \InvalidArgumentException(SafeMarkup::format("Invalid height (@value) specified for the image 'crop' operation", array('@value' => $arguments['height']))); + throw new \InvalidArgumentException("Invalid height ('{$arguments['height']}') specified for the image 'crop' operation"); } return $arguments; diff --git a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Resize.php b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Resize.php index be72427e43a..2e4494cc7c5 100644 --- a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Resize.php +++ b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Resize.php @@ -7,8 +7,6 @@ namespace Drupal\system\Plugin\ImageToolkit\Operation\gd; -use Drupal\Component\Utility\SafeMarkup; - /** * Defines GD2 resize operation. * @@ -46,10 +44,10 @@ class Resize extends GDImageToolkitOperationBase { // Fail when width or height are 0 or negative. if ($arguments['width'] <= 0) { - throw new \InvalidArgumentException(SafeMarkup::format("Invalid width (@value) specified for the image 'resize' operation", array('@value' => $arguments['width']))); + throw new \InvalidArgumentException("Invalid width ('{$arguments['width']}') specified for the image 'resize' operation"); } if ($arguments['height'] <= 0) { - throw new \InvalidArgumentException(SafeMarkup::format("Invalid height (@value) specified for the image 'resize' operation", array('@value' => $arguments['height']))); + throw new \InvalidArgumentException("Invalid height ('{$arguments['height']}') specified for the image 'resize' operation"); } return $arguments; diff --git a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Scale.php b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Scale.php index 875ce2326d6..c4788780494 100644 --- a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Scale.php +++ b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Scale.php @@ -7,8 +7,6 @@ namespace Drupal\system\Plugin\ImageToolkit\Operation\gd; -use Drupal\Component\Utility\SafeMarkup; - /** * Defines GD2 Scale operation. * @@ -73,10 +71,10 @@ class Scale extends Resize { // Fail when width or height are 0 or negative. if ($arguments['width'] <= 0) { - throw new \InvalidArgumentException(SafeMarkup::format("Invalid width (@value) specified for the image 'scale' operation", array('@value' => $arguments['width']))); + throw new \InvalidArgumentException("Invalid width ('{$arguments['width']}') specified for the image 'scale' operation"); } if ($arguments['height'] <= 0) { - throw new \InvalidArgumentException(SafeMarkup::format("Invalid height (@value) specified for the image 'scale' operation", array('@value' => $arguments['height']))); + throw new \InvalidArgumentException("Invalid height ('{$arguments['height']}') specified for the image 'scale' operation"); } return $arguments; diff --git a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/ScaleAndCrop.php b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/ScaleAndCrop.php index 7d465b8d676..0e09bd421d7 100644 --- a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/ScaleAndCrop.php +++ b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/ScaleAndCrop.php @@ -7,8 +7,6 @@ namespace Drupal\system\Plugin\ImageToolkit\Operation\gd; -use Drupal\Component\Utility\SafeMarkup; - /** * Defines GD2 Scale and crop operation. * @@ -54,10 +52,10 @@ class ScaleAndCrop extends GDImageToolkitOperationBase { // Fail when width or height are 0 or negative. if ($arguments['width'] <= 0) { - throw new \InvalidArgumentException(SafeMarkup::format("Invalid width (@value) specified for the image 'scale_and_crop' operation", array('@value' => $arguments['width']))); + throw new \InvalidArgumentException("Invalid width ('{$arguments['width']}') specified for the image 'scale_and_crop' operation"); } if ($arguments['height'] <= 0) { - throw new \InvalidArgumentException(SafeMarkup::format("Invalid height (@value) specified for the image 'scale_and_crop' operation", array('@value' => $arguments['height']))); + throw new \InvalidArgumentException("Invalid height ('{$arguments['height']}') specified for the image 'scale_and_crop' operation"); } return $arguments; diff --git a/core/modules/system/src/Tests/Plugin/ContextPluginTest.php b/core/modules/system/src/Tests/Plugin/ContextPluginTest.php index 5b04cd524e1..350868960b9 100644 --- a/core/modules/system/src/Tests/Plugin/ContextPluginTest.php +++ b/core/modules/system/src/Tests/Plugin/ContextPluginTest.php @@ -57,7 +57,7 @@ class ContextPluginTest extends KernelTestBase { $plugin->getContextValue('user'); } catch(ContextException $e) { - $this->assertIdentical("The entity:user context is required and not present.", $e->getMessage(), 'Requesting a non-set value of a required context should throw a context exception.'); + $this->assertIdentical("The 'entity:user' context is required and not present.", $e->getMessage(), 'Requesting a non-set value of a required context should throw a context exception.'); } // Try to pass the wrong class type as a context value. diff --git a/core/modules/system/src/Tests/Routing/ExceptionHandlingTest.php b/core/modules/system/src/Tests/Routing/ExceptionHandlingTest.php index ee3c7630865..1b22d5cd1df 100644 --- a/core/modules/system/src/Tests/Routing/ExceptionHandlingTest.php +++ b/core/modules/system/src/Tests/Routing/ExceptionHandlingTest.php @@ -120,4 +120,28 @@ class ExceptionHandlingTest extends KernelTestBase { $this->assertTrue(strpos($response->getContent(), '') === FALSE); } + /** + * Tests exception message escaping. + */ + public function testExceptionEscaping() { + // Enable verbose error logging. + $this->config('system.logging')->set('error_level', ERROR_REPORTING_DISPLAY_VERBOSE)->save(); + + // Using SafeMarkup::format(). + $request = Request::create('/router_test/test24'); + $request->setFormat('html', ['text/html']); + + /** @var \Symfony\Component\HttpKernel\HttpKernelInterface $kernel */ + $kernel = \Drupal::getContainer()->get('http_kernel'); + $response = $kernel->handle($request)->prepare($request); + $this->assertEqual($response->getStatusCode(), Response::HTTP_INTERNAL_SERVER_ERROR); + $this->assertEqual($response->headers->get('Content-type'), 'text/html; charset=UTF-8'); + + // Test message is properly escaped, and that the unescaped string is not + // output at all. + $this->setRawContent($response->getContent()); + $this->assertRaw(SafeMarkup::checkPlain('Escaped content: