Issue #2514044 by dawehner, stefan.r, alexpott: Do not use SafeMarkup::format in exceptions

8.0.x
Nathaniel Catchpole 2015-07-28 16:57:01 +01:00
parent 158ca154d1
commit f8629621bb
96 changed files with 236 additions and 389 deletions

View File

@ -174,7 +174,7 @@ function config_get_config_directory($type = CONFIG_ACTIVE_DIRECTORY) {
if (!empty($config_directories[$type])) { if (!empty($config_directories[$type])) {
return $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");
} }
/** /**

View File

@ -244,7 +244,7 @@ class UrlHelper {
$base_parts = parse_url($base_url); $base_parts = parse_url($base_url);
if (empty($base_parts['host']) || empty($url_parts['host'])) { 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'])) { if (!isset($url_parts['path']) || !isset($base_parts['path'])) {

View File

@ -7,7 +7,6 @@
namespace Drupal\Core\Breadcrumb; namespace Drupal\Core\Breadcrumb;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Routing\RouteMatchInterface;
@ -95,7 +94,7 @@ class BreadcrumbManager implements ChainBreadcrumbBuilderInterface {
break; break;
} }
else { 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. // Allow modules to alter the breadcrumb.

View File

@ -8,7 +8,6 @@
namespace Drupal\Core\Config; namespace Drupal\Core\Config;
use Drupal\Component\Utility\NestedArray; use Drupal\Component\Utility\NestedArray;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Cache\Cache; use Drupal\Core\Cache\Cache;
use Drupal\Core\Cache\RefinableCacheableDependencyInterface; use Drupal\Core\Cache\RefinableCacheableDependencyInterface;
use Drupal\Core\Cache\RefinableCacheableDependencyTrait; use Drupal\Core\Cache\RefinableCacheableDependencyTrait;
@ -99,24 +98,17 @@ abstract class ConfigBase implements RefinableCacheableDependencyInterface {
public static function validateName($name) { public static function validateName($name) {
// The name must be namespaced by owner. // The name must be namespaced by owner.
if (strpos($name, '.') === FALSE) { if (strpos($name, '.') === FALSE) {
throw new ConfigNameException(SafeMarkup::format('Missing namespace in Config object name @name.', array( throw new ConfigNameException("Missing namespace in Config object name $name.");
'@name' => $name,
)));
} }
// The name must be shorter than Config::MAX_NAME_LENGTH characters. // The name must be shorter than Config::MAX_NAME_LENGTH characters.
if (strlen($name) > self::MAX_NAME_LENGTH) { if (strlen($name) > self::MAX_NAME_LENGTH) {
throw new ConfigNameException(SafeMarkup::format('Config object name @name exceeds maximum allowed length of @length characters.', array( throw new ConfigNameException("Config object name $name exceeds maximum allowed length of " . static::MAX_NAME_LENGTH . " characters.");
'@name' => $name,
'@length' => self::MAX_NAME_LENGTH,
)));
} }
// The name must not contain any of the following characters: // The name must not contain any of the following characters:
// : ? * < > " ' / \ // : ? * < > " ' / \
if (preg_match('/[:?*<>"\'\/\\\\]/', $name)) { if (preg_match('/[:?*<>"\'\/\\\\]/', $name)) {
throw new ConfigNameException(SafeMarkup::format('Invalid character in Config object name @name.', array( throw new ConfigNameException("Invalid character in Config object name $name.");
'@name' => $name,
)));
} }
} }
@ -224,7 +216,7 @@ abstract class ConfigBase implements RefinableCacheableDependencyInterface {
protected function validateKeys(array $data) { protected function validateKeys(array $data) {
foreach ($data as $key => $value) { foreach ($data as $key => $value) {
if (strpos($key, '.') !== FALSE) { 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)) { if (is_array($value)) {
$this->validateKeys($value); $this->validateKeys($value);

View File

@ -11,7 +11,6 @@ use Drupal\Core\Config\Importer\MissingContentEvent;
use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Extension\ModuleInstallerInterface; use Drupal\Core\Extension\ModuleInstallerInterface;
use Drupal\Core\Extension\ThemeHandlerInterface; use Drupal\Core\Extension\ThemeHandlerInterface;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Config\Entity\ImportableEntityStorageInterface; use Drupal\Core\Config\Entity\ImportableEntityStorageInterface;
use Drupal\Core\DependencyInjection\DependencySerializationTrait; use Drupal\Core\DependencyInjection\DependencySerializationTrait;
use Drupal\Core\Entity\EntityStorageException; use Drupal\Core\Entity\EntityStorageException;
@ -763,7 +762,7 @@ class ConfigImporter {
} }
} }
catch (\Exception $e) { 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 // Error for that operation was logged, mark it as processed so that
// the import can continue. // the import can continue.
$this->setProcessedConfiguration($collection, $op, $name); $this->setProcessedConfiguration($collection, $op, $name);
@ -972,7 +971,7 @@ class ConfigImporter {
// Call to the configuration entity's storage to handle the configuration // Call to the configuration entity's storage to handle the configuration
// change. // change.
if (!($entity_storage instanceof ImportableEntityStorageInterface)) { 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); $entity_storage->$method($name, $new_config, $old_config);
$this->setProcessedConfiguration($collection, $op, $name); $this->setProcessedConfiguration($collection, $op, $name);
@ -1018,7 +1017,7 @@ class ConfigImporter {
// Call to the configuration entity's storage to handle the configuration // Call to the configuration entity's storage to handle the configuration
// change. // change.
if (!($entity_storage instanceof ImportableEntityStorageInterface)) { 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); $entity_storage->importRename($names['old_name'], $new_config, $old_config);
$this->setProcessedConfiguration($collection, 'rename', $rename_name); $this->setProcessedConfiguration($collection, 'rename', $rename_name);

View File

@ -7,7 +7,6 @@
namespace Drupal\Core\Config\Entity; namespace Drupal\Core\Config\Entity;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Cache\Cache; use Drupal\Core\Cache\Cache;
use Drupal\Core\Config\ConfigException; use Drupal\Core\Config\ConfigException;
use Drupal\Core\Config\Schema\SchemaIncompleteException; use Drupal\Core\Config\Schema\SchemaIncompleteException;
@ -278,7 +277,7 @@ abstract class ConfigEntityBase extends Entity implements ConfigEntityInterface
$config_name = $entity_type->getConfigPrefix() . '.' . $this->id(); $config_name = $entity_type->getConfigPrefix() . '.' . $this->id();
$definition = $this->getTypedConfig()->getDefinition($config_name); $definition = $this->getTypedConfig()->getDefinition($config_name);
if (!isset($definition['mapping'])) { 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'])); $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(); ->execute();
$matched_entity = reset($matching_entities); $matched_entity = reset($matching_entities);
if (!empty($matched_entity) && ($matched_entity != $this->id()) && $matched_entity != $this->getOriginalId()) { 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. // 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()); $original = $storage->loadUnchanged($this->getOriginalId());
// Ensure that the UUID cannot be changed for an existing entity. // Ensure that the UUID cannot be changed for an existing entity.
if ($original && ($original->uuid() != $this->uuid())) { 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) { if (!$this->isSyncing() && !$this->trustedData) {

View File

@ -7,7 +7,6 @@
namespace Drupal\Core\Config\Entity; namespace Drupal\Core\Config\Entity;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Cache\CacheableMetadata; use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Config\ConfigImporterException; 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 // @todo Consider moving this to a protected method on the parent class, and
// abstracting it for all entity types. // abstracting it for all entity types.
if (strlen($entity->get($this->idKey)) > self::MAX_ID_LENGTH) { 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( throw new ConfigEntityIdLengthException("Configuration entity ID {$entity->get($this->idKey)} exceeds maximum allowed length of " . self::MAX_ID_LENGTH . " characters.");
'@id' => $entity->get($this->idKey),
'@length' => self::MAX_ID_LENGTH,
)));
} }
return parent::save($entity); return parent::save($entity);
@ -404,7 +400,7 @@ class ConfigEntityStorage extends EntityStorageBase implements ConfigEntityStora
$id = static::getIDFromConfigName($name, $this->entityType->getConfigPrefix()); $id = static::getIDFromConfigName($name, $this->entityType->getConfigPrefix());
$entity = $this->load($id); $entity = $this->load($id);
if (!$entity) { 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->setSyncing(TRUE);
$entity = $this->updateFromStorageRecord($entity, $new_config->get()); $entity = $this->updateFromStorageRecord($entity, $new_config->get());

View File

@ -10,7 +10,6 @@ namespace Drupal\Core\Config\Entity;
use Drupal\Core\Config\Entity\Exception\ConfigEntityStorageClassException; use Drupal\Core\Config\Entity\Exception\ConfigEntityStorageClassException;
use Drupal\Core\Entity\EntityType; use Drupal\Core\Entity\EntityType;
use Drupal\Core\Config\ConfigPrefixLengthException; use Drupal\Core\Config\ConfigPrefixLengthException;
use Drupal\Component\Utility\SafeMarkup;
/** /**
* Provides an implementation of a configuration entity type and its metadata. * 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) { 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( throw new ConfigPrefixLengthException("The configuration file name prefix $config_prefix exceeds the maximum character limit of " . static::PREFIX_LENGTH);
'@config_prefix' => $config_prefix,
'@max_char' => static::PREFIX_LENGTH,
)));
} }
return $config_prefix; return $config_prefix;
} }
@ -158,7 +154,7 @@ class ConfigEntityType extends EntityType implements ConfigEntityTypeInterface {
*/ */
protected function checkStorageClass($class) { protected function checkStorageClass($class) {
if (!is_a($class, 'Drupal\Core\Config\Entity\ConfigEntityStorage', TRUE)) { 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");
} }
} }

View File

@ -9,7 +9,6 @@ namespace Drupal\Core\Config;
use Drupal\Component\Serialization\Yaml; use Drupal\Component\Serialization\Yaml;
use Drupal\Component\Serialization\Exception\InvalidDataTypeException; use Drupal\Component\Serialization\Exception\InvalidDataTypeException;
use Drupal\Component\Utility\SafeMarkup;
/** /**
* Defines the file storage. * Defines the file storage.
@ -101,10 +100,7 @@ class FileStorage implements StorageInterface {
$data = $this->decode($data); $data = $this->decode($data);
} }
catch (InvalidDataTypeException $e) { catch (InvalidDataTypeException $e) {
throw new UnsupportedDataTypeConfigException(SafeMarkup::format('Invalid data type in config @name: !message', array( throw new UnsupportedDataTypeConfigException("Invalid data type in config $name: {$e->getMessage()}");
'@name' => $name,
'!message' => $e->getMessage(),
)));
} }
return $data; return $data;
} }
@ -130,10 +126,7 @@ class FileStorage implements StorageInterface {
$data = $this->encode($data); $data = $this->encode($data);
} }
catch (InvalidDataTypeException $e) { catch (InvalidDataTypeException $e) {
throw new StorageException(SafeMarkup::format('Invalid data type in config @name: !message', array( throw new StorageException("Invalid data type in config $name: {$e->getMessage()}");
'@name' => $name,
'!message' => $e->getMessage(),
)));
} }
$target = $this->getFilePath($name); $target = $this->getFilePath($name);

View File

@ -7,8 +7,6 @@
namespace Drupal\Core\Config; namespace Drupal\Core\Config;
use Drupal\Component\Utility\SafeMarkup;
/** /**
* Defines the immutable configuration object. * Defines the immutable configuration object.
* *
@ -31,21 +29,21 @@ class ImmutableConfig extends Config {
* {@inheritdoc} * {@inheritdoc}
*/ */
public function set($key, $value) { 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} * {@inheritdoc}
*/ */
public function clear($key) { 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} * {@inheritdoc}
*/ */
public function save($has_trusted_data = FALSE) { 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. * The configuration object.
*/ */
public function delete() { 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");
} }
} }

View File

@ -91,9 +91,7 @@ class InstallStorage extends FileStorage {
} }
// If any code in the early installer requests a configuration object that // If any code in the early installer requests a configuration object that
// does not exist anywhere as default config, then that must be mistake. // does not exist anywhere as default config, then that must be mistake.
throw new StorageException(format_string('Missing configuration file: @name', array( throw new StorageException("Missing configuration file: $name");
'@name' => $name,
)));
} }
/** /**

View File

@ -7,7 +7,6 @@
namespace Drupal\Core\Config\Schema; namespace Drupal\Core\Config\Schema;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Config\TypedConfigManagerInterface; use Drupal\Core\Config\TypedConfigManagerInterface;
use Drupal\Core\TypedData\TypedData; use Drupal\Core\TypedData\TypedData;
@ -94,7 +93,7 @@ abstract class ArrayElement extends TypedData implements \IteratorAggregate, Typ
return $element; return $element;
} }
else { 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.");
} }
} }

View File

@ -7,7 +7,6 @@
namespace Drupal\Core\Config; namespace Drupal\Core\Config;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Config\Schema\Ignore; use Drupal\Core\Config\Schema\Ignore;
use Drupal\Core\TypedData\PrimitiveInterface; use Drupal\Core\TypedData\PrimitiveInterface;
use Drupal\Core\TypedData\Type\FloatInterface; use Drupal\Core\TypedData\Type\FloatInterface;
@ -163,10 +162,7 @@ abstract class StorableConfigBase extends ConfigBase {
} }
} }
elseif ($value !== NULL && !is_scalar($value)) { elseif ($value !== NULL && !is_scalar($value)) {
throw new UnsupportedDataTypeConfigException(SafeMarkup::format('Invalid data type for config element @name:@key', array( throw new UnsupportedDataTypeConfigException("Invalid data type for config element {$this->getName()}:$key");
'@name' => $this->getName(),
'@key' => $key,
)));
} }
} }
@ -213,10 +209,7 @@ abstract class StorableConfigBase extends ConfigBase {
else { else {
// Throw exception on any non-scalar or non-array value. // Throw exception on any non-scalar or non-array value.
if (!is_array($value)) { if (!is_array($value)) {
throw new UnsupportedDataTypeConfigException(SafeMarkup::format('Invalid data type for config element @name:@key', array( throw new UnsupportedDataTypeConfigException("Invalid data type for config element {$this->getName()}:$key");
'@name' => $this->getName(),
'@key' => $key,
)));
} }
// Recurse into any nested keys. // Recurse into any nested keys.
foreach ($value as $nested_value_key => $nested_value) { foreach ($value as $nested_value_key => $nested_value) {

View File

@ -7,7 +7,6 @@
namespace Drupal\Core\Config; namespace Drupal\Core\Config;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Cache\MemoryBackend; use Drupal\Core\Cache\MemoryBackend;
use Drupal\Core\Config\Entity\ConfigDependencyManager; use Drupal\Core\Config\Entity\ConfigDependencyManager;
use Drupal\Core\DependencyInjection\DependencySerializationTrait; use Drupal\Core\DependencyInjection\DependencySerializationTrait;
@ -196,7 +195,7 @@ class StorageComparer implements StorageComparerInterface {
// ensure the array is keyed from 0. // ensure the array is keyed from 0.
$this->changelist[$collection][$op] = array_values(array_intersect($sort_order, $this->changelist[$collection][$op])); $this->changelist[$collection][$op] = array_values(array_intersect($sort_order, $this->changelist[$collection][$op]));
if ($count != count($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.");
} }
} }
} }

View File

@ -88,14 +88,14 @@ class ConfigSchemaChecker implements EventSubscriberInterface {
$this->checked[$name . ':' . $checksum] = TRUE; $this->checked[$name . ':' . $checksum] = TRUE;
$errors = $this->checkConfigSchema($this->typedManager, $name, $data); $errors = $this->checkConfigSchema($this->typedManager, $name, $data);
if ($errors === FALSE) { 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)) { elseif (is_array($errors)) {
$text_errors = []; $text_errors = [];
foreach ($errors as $key => $error) { foreach ($errors as $key => $error) {
$text_errors[] = SafeMarkup::format('@key @error', array('@key' => $key, '@error' => $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));
} }
} }
} }

View File

@ -8,7 +8,6 @@
namespace Drupal\Core\Config; namespace Drupal\Core\Config;
use Drupal\Component\Utility\NestedArray; use Drupal\Component\Utility\NestedArray;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Config\Schema\ArrayElement; use Drupal\Core\Config\Schema\ArrayElement;
use Drupal\Core\Config\Schema\ConfigSchemaAlterException; use Drupal\Core\Config\Schema\ConfigSchemaAlterException;
@ -324,18 +323,18 @@ class TypedConfigManager extends TypedDataManager implements TypedConfigManagerI
parent::alterDefinitions($definitions); parent::alterDefinitions($definitions);
$altered_schema = array_keys($definitions); $altered_schema = array_keys($definitions);
if ($discovered_schema != $altered_schema) { if ($discovered_schema != $altered_schema) {
$added_keys = array_diff($altered_schema, $discovered_schema); $added_keys = implode(',', array_diff($altered_schema, $discovered_schema));
$removed_keys = array_diff($discovered_schema, $altered_schema); $removed_keys = implode(',', array_diff($discovered_schema, $altered_schema));
if (!empty($added_keys) && !empty($removed_keys)) { 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)) { 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 { 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);
} }
} }

View File

@ -263,7 +263,7 @@ abstract class ContentEntityBase extends Entity implements \IteratorAggregate, C
*/ */
public function setNewRevision($value = TRUE) { public function setNewRevision($value = TRUE) {
if (!$this->getEntityType()->hasKey('revision')) { 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) { if ($value && !$this->newRevision) {
@ -464,15 +464,14 @@ abstract class ContentEntityBase extends Entity implements \IteratorAggregate, C
*/ */
protected function getTranslatedField($name, $langcode) { protected function getTranslatedField($name, $langcode) {
if ($this->translations[$this->activeLangcode]['status'] == static::TRANSLATION_REMOVED) { 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("The entity object refers to a removed translation ({$this->activeLangcode}) and cannot be manipulated.");
throw new \InvalidArgumentException(SafeMarkup::format($message, array('@langcode' => $this->activeLangcode)));
} }
// Populate $this->fields to speed-up further look-ups and to keep track of // Populate $this->fields to speed-up further look-ups and to keep track of
// fields objects, possibly holding changes to field values. // fields objects, possibly holding changes to field values.
if (!isset($this->fields[$name][$langcode])) { if (!isset($this->fields[$name][$langcode])) {
$definition = $this->getFieldDefinition($name); $definition = $this->getFieldDefinition($name);
if (!$definition) { 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 // Non-translatable fields are always stored with
// LanguageInterface::LANGCODE_DEFAULT as key. // LanguageInterface::LANGCODE_DEFAULT as key.
@ -757,8 +756,7 @@ abstract class ContentEntityBase extends Entity implements \IteratorAggregate, C
} }
if (empty($translation)) { if (empty($translation)) {
$message = 'Invalid translation language (@langcode) specified.'; throw new \InvalidArgumentException("Invalid translation language ($langcode) specified.");
throw new \InvalidArgumentException(SafeMarkup::format($message, array('@langcode' => $langcode)));
} }
return $translation; return $translation;
@ -825,8 +823,7 @@ abstract class ContentEntityBase extends Entity implements \IteratorAggregate, C
public function addTranslation($langcode, array $values = array()) { public function addTranslation($langcode, array $values = array()) {
$this->getLanguages(); $this->getLanguages();
if (!isset($this->languages[$langcode]) || $this->hasTranslation($langcode)) { if (!isset($this->languages[$langcode]) || $this->hasTranslation($langcode)) {
$message = 'Invalid translation language (@langcode) specified.'; throw new \InvalidArgumentException("Invalid translation language ($langcode) specified.");
throw new \InvalidArgumentException(SafeMarkup::format($message, array('@langcode' => $langcode)));
} }
// Instantiate a new empty entity so default values will be populated in the // 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; $this->translations[$langcode]['status'] = static::TRANSLATION_REMOVED;
} }
else { else {
$message = 'The specified translation (@langcode) cannot be removed.'; throw new \InvalidArgumentException("The specified translation ($langcode) cannot be removed.");
throw new \InvalidArgumentException(SafeMarkup::format($message, array('@langcode' => $langcode)));
} }
} }
@ -1010,8 +1006,7 @@ abstract class ContentEntityBase extends Entity implements \IteratorAggregate, C
*/ */
public function createDuplicate() { public function createDuplicate() {
if ($this->translations[$this->activeLangcode]['status'] == static::TRANSLATION_REMOVED) { 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("The entity object refers to a removed translation ({$this->activeLangcode}) and cannot be manipulated.");
throw new \InvalidArgumentException(SafeMarkup::format($message, array('@langcode' => $this->activeLangcode)));
} }
$duplicate = clone $this; $duplicate = clone $this;

View File

@ -7,7 +7,6 @@
namespace Drupal\Core\Entity; namespace Drupal\Core\Entity;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Cache\Cache; use Drupal\Core\Cache\Cache;
use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FieldDefinitionInterface;
@ -83,7 +82,7 @@ abstract class ContentEntityStorageBase extends EntityStorageBase implements Dyn
$bundle = FALSE; $bundle = FALSE;
if ($this->bundleKey) { if ($this->bundleKey) {
if (!isset($values[$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]; $bundle = $values[$this->bundleKey];
} }

View File

@ -195,10 +195,7 @@ abstract class Entity implements EntityInterface {
$uri = call_user_func($uri_callback, $this); $uri = call_user_func($uri_callback, $this);
} }
else { else {
throw new UndefinedLinkTemplateException(SafeMarkup::format('No link template "@rel" found for the "@entity_type" entity type', array( throw new UndefinedLinkTemplateException("No link template '$rel' found for the '{$this->getEntityTypeId()}' entity type");
'@rel' => $rel,
'@entity_type' => $this->getEntityTypeId(),
)));
} }
} }
@ -384,12 +381,7 @@ abstract class Entity implements EntityInterface {
if ($this->getEntityType()->getBundleOf()) { if ($this->getEntityType()->getBundleOf()) {
// Throw an exception if the bundle ID is longer than 32 characters. // Throw an exception if the bundle ID is longer than 32 characters.
if (Unicode::strlen($this->id()) > EntityTypeInterface::BUNDLE_MAX_LENGTH) { if (Unicode::strlen($this->id()) > EntityTypeInterface::BUNDLE_MAX_LENGTH) {
throw new ConfigEntityIdLengthException(SafeMarkup::format( throw new ConfigEntityIdLengthException("Attempt to create a bundle with an ID longer than " . EntityTypeInterface::BUNDLE_MAX_LENGTH . " characters: $this->id().");
'Attempt to create a bundle with an ID longer than @max characters: @id.', array(
'@max' => EntityTypeInterface::BUNDLE_MAX_LENGTH,
'@id' => $this->id(),
)
));
} }
} }
} }

View File

@ -11,7 +11,6 @@ use Drupal\Core\Config\Entity\ConfigEntityBase;
use Drupal\Core\Config\Entity\ConfigEntityInterface; use Drupal\Core\Config\Entity\ConfigEntityInterface;
use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Entity\Display\EntityDisplayInterface; use Drupal\Core\Entity\Display\EntityDisplayInterface;
use Drupal\Component\Utility\SafeMarkup;
/** /**
* Provides a common base class for entity view and form displays. * 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 // If the target entity type uses entities to manage its bundles then
// depend on the bundle entity. // depend on the bundle entity.
if (!$bundle_entity = $this->entityManager()->getStorage($bundle_entity_type_id)->load($this->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()); $this->addDependency('config', $bundle_entity->getConfigDependencyName());
} }

View File

@ -9,7 +9,6 @@ namespace Drupal\Core\Entity;
use Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException; use Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException;
use Drupal\Component\Plugin\Exception\PluginNotFoundException; use Drupal\Component\Plugin\Exception\PluginNotFoundException;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Cache\Cache; use Drupal\Core\Cache\Cache;
use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Config\Entity\ConfigEntityType; 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. // Fail with an exception for non-fieldable entity types.
if (!$entity_type->isSubclassOf('\Drupal\Core\Entity\FieldableEntityInterface')) { 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. // Retrieve base field definitions.
@ -493,28 +492,19 @@ class EntityManager extends DefaultPluginManager implements EntityManagerInterfa
// translatable values. // translatable values.
foreach (array_intersect_key($keys, array_flip(['id', 'revision', 'uuid', 'bundle'])) as $key => $field_name) { foreach (array_intersect_key($keys, array_flip(['id', 'revision', 'uuid', 'bundle'])) as $key => $field_name) {
if (!isset($base_field_definitions[$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( throw new \LogicException("The $field_name field definition does not exist and it is used as $key entity key.");
'@field' => $field_name,
'@key' => $key,
)));
} }
if ($base_field_definitions[$field_name]->isRevisionable()) { 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( throw new \LogicException("The {$base_field_definitions[$field_name]->getLabel()} field cannot be revisionable as it is used as $key entity key.");
'@field' => $base_field_definitions[$field_name]->getLabel(),
'@key' => $key,
)));
} }
if ($base_field_definitions[$field_name]->isTranslatable()) { 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( throw new \LogicException("The {$base_field_definitions[$field_name]->getLabel()} field cannot be translatable as it is used as $key entity key.");
'@field' => $base_field_definitions[$field_name]->getLabel(),
'@key' => $key,
)));
} }
} }
// Make sure translatable entity types define the "langcode" field properly. // 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())) { 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; return $base_field_definitions;

View File

@ -7,7 +7,6 @@
namespace Drupal\Core\Entity; namespace Drupal\Core\Entity;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Entity\Query\QueryInterface; use Drupal\Core\Entity\Query\QueryInterface;
/** /**
@ -422,7 +421,7 @@ abstract class EntityStorageBase extends EntityHandlerBase implements EntityStor
// A new entity should not already exist. // A new entity should not already exist.
if ($id_exists && $entity->isNew()) { 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. // Load the original entity, if any.

View File

@ -7,7 +7,6 @@
namespace Drupal\Core\Entity; namespace Drupal\Core\Entity;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Component\Utility\Unicode; use Drupal\Component\Utility\Unicode;
use Drupal\Core\Entity\Exception\EntityTypeIdLengthException; use Drupal\Core\Entity\Exception\EntityTypeIdLengthException;
use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\Core\StringTranslation\StringTranslationTrait;
@ -245,12 +244,7 @@ class EntityType implements EntityTypeInterface {
public function __construct($definition) { public function __construct($definition) {
// Throw an exception if the entity type ID is longer than 32 characters. // Throw an exception if the entity type ID is longer than 32 characters.
if (Unicode::strlen($definition['id']) > static::ID_MAX_LENGTH) { if (Unicode::strlen($definition['id']) > static::ID_MAX_LENGTH) {
throw new EntityTypeIdLengthException(SafeMarkup::format( throw new EntityTypeIdLengthException('Attempt to create an entity type with an ID longer than ' . static::ID_MAX_LENGTH . " characters: {$definition['id']}.");
'Attempt to create an entity type with an ID longer than @max characters: @id.', array(
'@max' => static::ID_MAX_LENGTH,
'@id' => $definition['id'],
)
));
} }
foreach ($definition as $property => $value) { foreach ($definition as $property => $value) {

View File

@ -7,7 +7,6 @@
namespace Drupal\Core\Entity\KeyValueStore; namespace Drupal\Core\Entity\KeyValueStore;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Component\Uuid\UuidInterface; use Drupal\Component\Uuid\UuidInterface;
use Drupal\Core\Config\Entity\Exception\ConfigEntityIdLengthException; use Drupal\Core\Config\Entity\Exception\ConfigEntityIdLengthException;
use Drupal\Core\Entity\FieldableEntityInterface; 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 // @todo This is not config-specific, but serial IDs will likely never hit
// this limit. Consider renaming the exception class. // this limit. Consider renaming the exception class.
if (strlen($entity->id()) > static::MAX_ID_LENGTH) { if (strlen($entity->id()) > static::MAX_ID_LENGTH) {
throw new ConfigEntityIdLengthException(SafeMarkup::format('Entity ID @id exceeds maximum allowed length of @length characters.', array( throw new ConfigEntityIdLengthException("Entity ID {$entity->id()} exceeds maximum allowed length of " . static::MAX_ID_LENGTH . ' characters.');
'@id' => $entity->id(),
'@length' => static::MAX_ID_LENGTH,
)));
} }
return parent::save($entity); return parent::save($entity);
} }

View File

@ -81,12 +81,12 @@ class EntityAdapter extends TypedData implements \IteratorAggregate, ComplexData
*/ */
public function get($property_name) { public function get($property_name) {
if (!isset($this->entity)) { 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) { if (!$this->entity instanceof FieldableEntityInterface) {
// @todo: Add support for config entities in // @todo: Add support for config entities in
// https://www.drupal.org/node/1818574. // 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. // This will throw an exception for unknown fields.
return $this->entity->get($property_name); 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) { public function set($property_name, $value, $notify = TRUE) {
if (!isset($this->entity)) { 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) { if (!$this->entity instanceof FieldableEntityInterface) {
// @todo: Add support for config entities in // @todo: Add support for config entities in
// https://www.drupal.org/node/1818574. // 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 will throw an exception for unknown fields.
$this->entity->set($property_name, $value, $notify); $this->entity->set($property_name, $value, $notify);
@ -129,7 +129,7 @@ class EntityAdapter extends TypedData implements \IteratorAggregate, ComplexData
*/ */
public function toArray() { public function toArray() {
if (!isset($this->entity)) { 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(); return $this->entity->toArray();
} }

View File

@ -215,7 +215,7 @@ class Tables implements TablesInterface {
$index_prefix .= "$next_index_prefix."; $index_prefix .= "$next_index_prefix.";
} }
else { 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]; return $this->entityTables[$index_prefix . $table];
} }
} }
throw new QueryException(format_string('@property not found', array('@property' => $property))); throw new QueryException("'$property' not found");
} }
/** /**

View File

@ -7,7 +7,6 @@
namespace Drupal\Core\Entity\Sql; namespace Drupal\Core\Entity\Sql;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Entity\ContentEntityTypeInterface; use Drupal\Core\Entity\ContentEntityTypeInterface;
use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\Core\Field\FieldStorageDefinitionInterface;
@ -178,7 +177,7 @@ class DefaultTableMapping implements TableMappingInterface {
} }
if (!isset($result)) { 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; return $result;
@ -211,7 +210,7 @@ class DefaultTableMapping implements TableMappingInterface {
$column_name = !in_array($property_name, $this->getReservedColumns()) ? $field_name . '_' . $property_name : $property_name; $column_name = !in_array($property_name, $this->getReservedColumns()) ? $field_name . '_' . $property_name : $property_name;
} }
else { 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; return $column_name;

View File

@ -7,7 +7,6 @@
namespace Drupal\Core\Entity\Sql; namespace Drupal\Core\Entity\Sql;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Database\Connection; use Drupal\Core\Database\Connection;
use Drupal\Core\Database\Database; use Drupal\Core\Database\Database;
@ -266,7 +265,7 @@ class SqlContentEntityStorage extends ContentEntityStorageBase implements SqlEnt
$this->initTableLayout(); $this->initTableLayout();
} }
else { 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) { foreach ($table_mapping->getFieldNames($table_name) as $field_name) {
if (empty($this->getFieldStorageDefinitions()[$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]; $definition = $this->getFieldStorageDefinitions()[$field_name];
$columns = $table_mapping->getColumnNames($field_name); $columns = $table_mapping->getColumnNames($field_name);

View File

@ -7,7 +7,6 @@
namespace Drupal\Core\Entity\Sql; namespace Drupal\Core\Entity\Sql;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Database\Connection; use Drupal\Core\Database\Connection;
use Drupal\Core\Database\DatabaseException; use Drupal\Core\Database\DatabaseException;
use Drupal\Core\Entity\ContentEntityTypeInterface; use Drupal\Core\Entity\ContentEntityTypeInterface;
@ -286,7 +285,7 @@ class SqlContentEntityStorageSchema implements DynamicallyFieldableEntityStorage
// If a migration is required, we can't proceed. // If a migration is required, we can't proceed.
if ($this->requiresEntityDataMigration($entity_type, $original)) { 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. // 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) { protected function checkEntityType(EntityTypeInterface $entity_type) {
if ($entity_type->id() != $this->entityType->id()) { 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; return TRUE;
} }
@ -530,7 +529,7 @@ class SqlContentEntityStorageSchema implements DynamicallyFieldableEntityStorage
} }
foreach ($table_mapping->getFieldNames($table_name) as $field_name) { foreach ($table_mapping->getFieldNames($table_name) as $field_name) {
if (!isset($storage_definitions[$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. // Add the schema for base field definitions.
elseif ($table_mapping->allowsSharedTableStorage($storage_definitions[$field_name])) { 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. // Check that the schema does not include forbidden column names.
if (array_intersect(array_keys($field_schema['columns']), $this->storage->getTableMapping()->getReservedColumns())) { 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(); $field_name = $storage_definition->getName();
@ -1652,7 +1651,7 @@ class SqlContentEntityStorageSchema implements DynamicallyFieldableEntityStorage
$properties = $storage_definition->getPropertyDefinitions(); $properties = $storage_definition->getPropertyDefinitions();
$table_mapping = $this->storage->getTableMapping(); $table_mapping = $this->storage->getTableMapping();
if (array_intersect(array_keys($schema['columns']), $table_mapping->getReservedColumns())) { 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. // Add field columns.

View File

@ -9,7 +9,6 @@ namespace Drupal\Core\Extension;
use Drupal\Component\Graph\Graph; use Drupal\Component\Graph\Graph;
use Drupal\Component\Utility\NestedArray; use Drupal\Component\Utility\NestedArray;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Cache\Cache; use Drupal\Core\Cache\Cache;
use Drupal\Core\Cache\CacheBackendInterface; 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 a new implementation was added, verify that the function exists.
if (!function_exists($module . '_' . $hook)) { 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()");
} }
} }
} }

View File

@ -13,7 +13,6 @@ use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Config\PreExistingConfigException; use Drupal\Core\Config\PreExistingConfigException;
use Drupal\Core\Config\StorageInterface; use Drupal\Core\Config\StorageInterface;
use Drupal\Core\DrupalKernelInterface; use Drupal\Core\DrupalKernelInterface;
use Drupal\Component\Utility\SafeMarkup;
/** /**
* Default implementation of the module installer. * 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(); $module_list = $module_list ? array_combine($module_list, $module_list) : array();
if ($missing_modules = array_diff_key($module_list, $module_data)) { if ($missing_modules = array_diff_key($module_list, $module_data)) {
// One or more of the given modules doesn't exist. // 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( throw new MissingDependencyException(sprintf('Unable to install modules %s due to missing modules %s.', implode(', ', $module_list), implode(', ', $missing_modules)));
'%modules' => implode(', ', $module_list),
'%missing' => implode(', ', $missing_modules),
)));
} }
// Only process currently uninstalled modules. // Only process currently uninstalled modules.
@ -107,10 +103,7 @@ class ModuleInstaller implements ModuleInstallerInterface {
foreach (array_keys($module_data[$module]->requires) as $dependency) { foreach (array_keys($module_data[$module]->requires) as $dependency) {
if (!isset($module_data[$dependency])) { if (!isset($module_data[$dependency])) {
// The dependency does not exist. // The dependency does not exist.
throw new MissingDependencyException(SafeMarkup::format('Unable to install modules: module %module is missing its dependency module %dependency.', array( throw new MissingDependencyException("Unable to install modules: module '$module' is missing its dependency module $dependency.");
'%module' => $module,
'%dependency' => $dependency,
)));
} }
// Skip already installed modules. // Skip already installed modules.
@ -145,10 +138,7 @@ class ModuleInstaller implements ModuleInstallerInterface {
if (!$enabled) { if (!$enabled) {
// Throw an exception if the module name is too long. // Throw an exception if the module name is too long.
if (strlen($module) > DRUPAL_EXTENSION_NAME_MAX_LENGTH) { 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( throw new ExtensionNameLengthException("Module name '$module' is over the maximum allowed length of " . DRUPAL_EXTENSION_NAME_MAX_LENGTH . ' characters');
'%name' => $module,
'@max' => DRUPAL_EXTENSION_NAME_MAX_LENGTH,
)));
} }
// Check the validity of the default configuration. This will throw // Check the validity of the default configuration. This will throw
@ -329,9 +319,7 @@ class ModuleInstaller implements ModuleInstallerInterface {
foreach ($reasons as $reason) { foreach ($reasons as $reason) {
$reason_message[] = implode(', ', $reason); $reason_message[] = implode(', ', $reason);
} }
throw new ModuleUninstallValidatorException(format_string('The following reasons prevents the modules from being uninstalled: @reasons', array( throw new ModuleUninstallValidatorException('The following reasons prevents the modules from being uninstalled: ' . implode('; ', $reason_message));
'@reasons' => implode('; ', $reason_message),
)));
} }
// Set the actual module weights. // Set the actual module weights.
$module_list = array_map(function ($module) use ($module_data) { $module_list = array_map(function ($module) use ($module_data) {

View File

@ -429,7 +429,7 @@ class ThemeHandler implements ThemeHandlerInterface {
public function getName($theme) { public function getName($theme) {
$themes = $this->listInfo(); $themes = $this->listInfo();
if (!isset($themes[$theme])) { 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']); return SafeMarkup::checkPlain($themes[$theme]->info['name']);
} }

View File

@ -7,7 +7,6 @@
namespace Drupal\Core\Extension; namespace Drupal\Core\Extension;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Asset\AssetCollectionOptimizerInterface; use Drupal\Core\Asset\AssetCollectionOptimizerInterface;
use Drupal\Core\Cache\Cache; use Drupal\Core\Cache\Cache;
use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Config\ConfigFactoryInterface;
@ -113,9 +112,7 @@ class ThemeInstaller implements ThemeInstallerInterface {
if ($missing = array_diff_key($theme_list, $theme_data)) { if ($missing = array_diff_key($theme_list, $theme_data)) {
// One or more of the given themes doesn't exist. // One or more of the given themes doesn't exist.
throw new \InvalidArgumentException(SafeMarkup::format('Unknown themes: !themes.', array( throw new \InvalidArgumentException('Unknown themes: ' . implode(', ', $missing) . '.');
'!themes' => implode(', ', $missing),
)));
} }
// Only process themes that are not installed currently. // 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. // Throw an exception if the theme name is too long.
if (strlen($key) > DRUPAL_EXTENSION_NAME_MAX_LENGTH) { 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( throw new ExtensionNameLengthException("Theme name $key is over the maximum allowed length of " . DRUPAL_EXTENSION_NAME_MAX_LENGTH . ' characters.');
'%name' => $key,
'@max' => DRUPAL_EXTENSION_NAME_MAX_LENGTH,
)));
} }
// Validate default configuration of the theme. If there is existing // Validate default configuration of the theme. If there is existing

View File

@ -7,7 +7,6 @@
namespace Drupal\Core\Field\Entity; namespace Drupal\Core\Field\Entity;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Field\BaseFieldDefinition; use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\Core\Field\FieldConfigBase; 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'); throw new FieldException('Attempt to create a base field bundle override of a field without a field_name');
} }
if (empty($values['entity_type'])) { 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'])) { 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); parent::__construct($values, $entity_type);
@ -188,10 +187,10 @@ class BaseFieldOverride extends FieldConfigBase {
else { else {
// Some updates are always disallowed. // Some updates are always disallowed.
if ($this->entity_type != $this->original->entity_type) { 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)) { 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; $previous_definition = $this->original;
} }

View File

@ -12,7 +12,6 @@ use Drupal\Core\Config\Entity\ConfigEntityBase;
use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Entity\FieldableEntityInterface; use Drupal\Core\Entity\FieldableEntityInterface;
use Drupal\Core\Field\TypedData\FieldItemDataDefinition; use Drupal\Core\Field\TypedData\FieldItemDataDefinition;
use Drupal\Component\Utility\SafeMarkup;
/** /**
* Base class for configurable field definitions. * 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(); $bundle_entity_type_id = $this->entityManager()->getDefinition($this->entity_type)->getBundleEntityType();
if ($bundle_entity_type_id != 'bundle') { if ($bundle_entity_type_id != 'bundle') {
if (!$bundle_entity = $this->entityManager()->getStorage($bundle_entity_type_id)->load($this->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()); $this->addDependency('config', $bundle_entity->getConfigDependencyName());
} }

View File

@ -10,7 +10,6 @@ namespace Drupal\Core\Form;
use Drupal\Component\Utility\Crypt; use Drupal\Component\Utility\Crypt;
use Drupal\Component\Utility\Html; use Drupal\Component\Utility\Html;
use Drupal\Component\Utility\NestedArray; use Drupal\Component\Utility\NestedArray;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Component\Utility\UrlHelper; use Drupal\Component\Utility\UrlHelper;
use Drupal\Core\Access\AccessResultInterface; use Drupal\Core\Access\AccessResultInterface;
use Drupal\Core\Access\CsrfTokenGenerator; use Drupal\Core\Access\CsrfTokenGenerator;
@ -153,7 +152,7 @@ class FormBuilder implements FormBuilderInterface, FormValidatorInterface, FormS
} }
if (!is_object($form_arg) || !($form_arg instanceof FormInterface)) { 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. // Add the $form_arg as the callback object and determine the form ID.

View File

@ -8,7 +8,6 @@
namespace Drupal\Core\ImageToolkit; namespace Drupal\Core\ImageToolkit;
use Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException; use Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Plugin\PluginBase; use Drupal\Core\Plugin\PluginBase;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
@ -114,7 +113,7 @@ abstract class ImageToolkitOperationBase extends PluginBase implements ImageTool
if ($argument['required']) { if ($argument['required']) {
if (!array_key_exists($id, $arguments)) { if (!array_key_exists($id, $arguments)) {
// If the argument is required throw an exception. // 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 { else {
@ -124,7 +123,7 @@ abstract class ImageToolkitOperationBase extends PluginBase implements ImageTool
if (!array_key_exists('default', $argument)) { if (!array_key_exists('default', $argument)) {
// The plugin did not define a default, so throw a plugin exception, // The plugin did not define a default, so throw a plugin exception,
// not an invalid argument 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. // Use the default value if the argument is not passed in.

View File

@ -8,7 +8,6 @@
namespace Drupal\Core\Menu; namespace Drupal\Core\Menu;
use Drupal\Component\Plugin\Exception\PluginException; use Drupal\Component\Plugin\Exception\PluginException;
use Drupal\Component\Utility\SafeMarkup;
/** /**
* A menu link plugin for wrapping another menu link, in sensitive situations. * A menu link plugin for wrapping another menu link, in sensitive situations.
@ -80,7 +79,7 @@ class InaccessibleMenuLink extends MenuLinkBase {
* {@inheritdoc} * {@inheritdoc}
*/ */
public function updateLink(array $new_definition_values, $persist) { 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');
} }
} }

View File

@ -8,7 +8,6 @@
namespace Drupal\Core\Menu; namespace Drupal\Core\Menu;
use Drupal\Component\Plugin\Exception\PluginException; use Drupal\Component\Plugin\Exception\PluginException;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Cache\Cache; use Drupal\Core\Cache\Cache;
use Drupal\Core\Plugin\PluginBase; use Drupal\Core\Plugin\PluginBase;
use Drupal\Core\Url; use Drupal\Core\Url;
@ -170,7 +169,7 @@ abstract class MenuLinkBase extends PluginBase implements MenuLinkInterface {
* {@inheritdoc} * {@inheritdoc}
*/ */
public function deleteLink() { 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");
} }
/** /**

View File

@ -10,7 +10,6 @@ namespace Drupal\Core\Menu;
use Drupal\Component\Plugin\Exception\PluginException; use Drupal\Component\Plugin\Exception\PluginException;
use Drupal\Component\Plugin\Exception\PluginNotFoundException; use Drupal\Component\Plugin\Exception\PluginNotFoundException;
use Drupal\Component\Utility\NestedArray; use Drupal\Component\Utility\NestedArray;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Plugin\Discovery\ContainerDerivativeDiscoveryDecorator; use Drupal\Core\Plugin\Discovery\ContainerDerivativeDiscoveryDecorator;
use Drupal\Core\Plugin\Discovery\YamlDiscovery; use Drupal\Core\Plugin\Discovery\YamlDiscovery;
@ -287,7 +286,7 @@ class MenuLinkManager implements MenuLinkManagerInterface {
} }
} }
else { 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); $this->treeStorage->delete($id);
} }
@ -355,7 +354,7 @@ class MenuLinkManager implements MenuLinkManagerInterface {
*/ */
public function addDefinition($id, array $definition) { public function addDefinition($id, array $definition) {
if ($this->treeStorage->load($id) || $id === '') { 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. // Add defaults, so there is no requirement to specify everything.
$this->processDefinition($definition, $id); $this->processDefinition($definition, $id);
@ -402,7 +401,7 @@ class MenuLinkManager implements MenuLinkManagerInterface {
$id = $instance->getPluginId(); $id = $instance->getPluginId();
if (!$instance->isResettable()) { 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 // Get the original data from disk, reset the override and re-save the menu
// tree for this link. // tree for this link.

View File

@ -8,7 +8,6 @@
namespace Drupal\Core\Menu; namespace Drupal\Core\Menu;
use Drupal\Component\Plugin\Exception\PluginException; use Drupal\Component\Plugin\Exception\PluginException;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Component\Utility\UrlHelper; use Drupal\Component\Utility\UrlHelper;
use Drupal\Core\Cache\Cache; use Drupal\Core\Cache\Cache;
use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Cache\CacheBackendInterface;
@ -476,7 +475,7 @@ class MenuTreeStorage implements MenuTreeStorageInterface {
$limit = $this->maxDepth() - 1; $limit = $this->maxDepth() - 1;
} }
if ($parent['depth'] > $limit) { 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; $fields['depth'] = $parent['depth'] + 1;
$i = 1; $i = 1;
@ -637,7 +636,7 @@ class MenuTreeStorage implements MenuTreeStorageInterface {
foreach ($properties as $name => $value) { foreach ($properties as $name => $value) {
if (!in_array($name, $this->definitionFields(), TRUE)) { if (!in_array($name, $this->definitionFields(), TRUE)) {
$fields = implode(', ', $this->definitionFields()); $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); $query->condition($name, $value);
} }

View File

@ -9,7 +9,6 @@ namespace Drupal\Core\Plugin\Context;
use Drupal\Component\Plugin\Context\Context as ComponentContext; use Drupal\Component\Plugin\Context\Context as ComponentContext;
use Drupal\Component\Plugin\Exception\ContextException; use Drupal\Component\Plugin\Exception\ContextException;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Cache\CacheableDependencyInterface; use Drupal\Core\Cache\CacheableDependencyInterface;
use Drupal\Core\Cache\CacheableMetadata; use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\TypedData\TypedDataInterface; use Drupal\Core\TypedData\TypedDataInterface;
@ -66,7 +65,7 @@ class Context extends ComponentContext implements ContextInterface {
} }
elseif ($definition->isRequired()) { elseif ($definition->isRequired()) {
$type = $definition->getDataType(); $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; return $default_value;
} }

View File

@ -7,7 +7,6 @@
namespace Drupal\Core\Plugin\Context; namespace Drupal\Core\Plugin\Context;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\TypedData\TypedDataTrait; use Drupal\Core\TypedData\TypedDataTrait;
/** /**
@ -245,7 +244,7 @@ class ContextDefinition implements ContextDefinitionInterface {
} }
if (!$definition) { 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()) $definition->setLabel($this->getLabel())
->setDescription($this->getDescription()) ->setDescription($this->getDescription())

View File

@ -8,7 +8,6 @@
namespace Drupal\Core\Plugin\Context; namespace Drupal\Core\Plugin\Context;
use Drupal\Component\Plugin\Exception\ContextException; use Drupal\Component\Plugin\Exception\ContextException;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Cache\CacheableDependencyInterface; use Drupal\Core\Cache\CacheableDependencyInterface;
use Drupal\Core\Plugin\ContextAwarePluginInterface; 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 there are any mappings that were not satisfied, throw an exception.
if (!empty($mappings)) { 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)));
} }
} }

View File

@ -7,7 +7,6 @@
namespace Drupal\Core\Routing; namespace Drupal\Core\Routing;
use Drupal\Component\Utility\SafeMarkup;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\NotAcceptableHttpException; use Symfony\Component\HttpKernel\Exception\NotAcceptableHttpException;
use Symfony\Component\Routing\Route; use Symfony\Component\Routing\Route;
@ -51,7 +50,7 @@ class RequestFormatRouteFilter implements RouteFilterInterface {
// We do not throw a // We do not throw a
// \Symfony\Component\Routing\Exception\ResourceNotFoundException here // \Symfony\Component\Routing\Exception\ResourceNotFoundException here
// because we don't want to return a 404 status code, but rather a 406. // 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.");
} }
} }

View File

@ -87,7 +87,7 @@ class ListDataDefinition extends DataDefinition implements ListDataDefinitionInt
$item_type_definition = \Drupal::typedDataManager() $item_type_definition = \Drupal::typedDataManager()
->getDefinition($this->getItemDefinition()->getDataType()); ->getDefinition($this->getItemDefinition()->getDataType());
if (!$item_type_definition) { 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']; return $item_type_definition['list_class'];
} }

View File

@ -8,7 +8,6 @@
namespace Drupal\Core\TypedData; namespace Drupal\Core\TypedData;
use Drupal\Component\Plugin\Exception\PluginException; use Drupal\Component\Plugin\Exception\PluginException;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\DependencyInjection\ClassResolverInterface; use Drupal\Core\DependencyInjection\ClassResolverInterface;
use Drupal\Core\DependencyInjection\DependencySerializationTrait; use Drupal\Core\DependencyInjection\DependencySerializationTrait;
@ -99,7 +98,7 @@ class TypedDataManager extends DefaultPluginManager {
$type_definition = $this->getDefinition($data_type); $type_definition = $this->getDefinition($data_type);
if (!isset($type_definition)) { 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 // 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) { public function createDataDefinition($data_type) {
$type_definition = $this->getDefinition($data_type); $type_definition = $this->getDefinition($data_type);
if (!isset($type_definition)) { 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']; $class = $type_definition['definition_class'];
return $class::createFromDataType($data_type); return $class::createFromDataType($data_type);
@ -199,7 +198,7 @@ class TypedDataManager extends DefaultPluginManager {
public function createListDataDefinition($item_type) { public function createListDataDefinition($item_type) {
$type_definition = $this->getDefinition($item_type); $type_definition = $this->getDefinition($item_type);
if (!isset($type_definition)) { 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']; $class = $type_definition['list_definition_class'];
return $class::createFromItemType($item_type); 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."); throw new \InvalidArgumentException("The passed object has to either implement the ComplexDataInterface or the ListInterface.");
} }
if (!$definition) { 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 // Create the prototype without any value, but with initial parenting
// so that constructors can set up the objects correclty. // so that constructors can set up the objects correclty.

View File

@ -7,7 +7,6 @@
namespace Drupal\Core; namespace Drupal\Core;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Component\Utility\UrlHelper; use Drupal\Component\Utility\UrlHelper;
use Drupal\Core\DependencyInjection\DependencySerializationTrait; use Drupal\Core\DependencyInjection\DependencySerializationTrait;
use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Routing\RouteMatchInterface;
@ -232,7 +231,7 @@ class Url {
// because these are URI reserved characters that a scheme name may not // because these are URI reserved characters that a scheme name may not
// start with. // start with.
if ((strpos($user_input, '/') !== 0) && (strpos($user_input, '#') !== 0) && (strpos($user_input, '?') !== 0)) { 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 // fromUri() requires an absolute URI, so prepend the appropriate scheme
@ -296,10 +295,10 @@ class Url {
public static function fromUri($uri, $options = []) { public static function fromUri($uri, $options = []) {
$uri_parts = parse_url($uri); $uri_parts = parse_url($uri);
if ($uri_parts === FALSE) { 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'])) { 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' => '']; $uri_parts += ['path' => ''];
// Discard empty fragment in $options for consistency with parse_url(). // 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) { protected static function fromEntityUri(array $uri_parts, array $options, $uri) {
list($entity_type_id, $entity_id) = explode('/', $uri_parts['path'], 2); list($entity_type_id, $entity_id) = explode('/', $uri_parts['path'], 2);
if ($uri_parts['scheme'] != 'entity' || $entity_id === '') { 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); return new static("entity.$entity_type_id.canonical", [$entity_type_id => $entity_id], $options);
@ -422,13 +421,13 @@ class Url {
} }
else { else {
if ($uri_parts['path'][0] !== '/') { 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. // Remove the leading slash.
$uri_parts['path'] = substr($uri_parts['path'], 1); $uri_parts['path'] = substr($uri_parts['path'], 1);
if (UrlHelper::isExternal($uri_parts['path'])) { 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_parts = explode(';', $uri_parts['path'], 2);
$route_name = $route_parts[0]; $route_name = $route_parts[0];
if ($route_name === '') { 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 = []; $route_parameters = [];
if (!empty($route_parts[1])) { if (!empty($route_parts[1])) {

View File

@ -7,7 +7,6 @@
namespace Drupal\Core\Utility; namespace Drupal\Core\Utility;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Component\Utility\UrlHelper; use Drupal\Component\Utility\UrlHelper;
use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\GeneratedUrl; use Drupal\Core\GeneratedUrl;
@ -68,7 +67,7 @@ class UnroutedUrlAssembler implements UnroutedUrlAssemblerInterface {
// UrlHelper::isExternal() only returns true for safe protocols. // UrlHelper::isExternal() only returns true for safe protocols.
return $this->buildExternalUrl($uri, $options, $collect_bubbleable_metadata); 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.");
} }
/** /**

View File

@ -9,7 +9,6 @@ namespace Drupal\block;
use Drupal\Component\Plugin\Exception\PluginException; use Drupal\Component\Plugin\Exception\PluginException;
use Drupal\Component\Plugin\PluginManagerInterface; use Drupal\Component\Plugin\PluginManagerInterface;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Plugin\DefaultSingleLazyPluginCollection; use Drupal\Core\Plugin\DefaultSingleLazyPluginCollection;
/** /**
@ -56,7 +55,7 @@ class BlockPluginCollection extends DefaultSingleLazyPluginCollection {
*/ */
protected function initializePlugin($instance_id) { protected function initializePlugin($instance_id) {
if (!$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 { try {

View File

@ -7,7 +7,6 @@
namespace Drupal\comment\Tests; namespace Drupal\comment\Tests;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Component\Utility\Unicode; use Drupal\Component\Utility\Unicode;
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface; use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
@ -42,10 +41,7 @@ trait CommentTestTrait {
$comment_type_storage = $entity_manager->getStorage('comment_type'); $comment_type_storage = $entity_manager->getStorage('comment_type');
if ($comment_type = $comment_type_storage->load($comment_type_id)) { if ($comment_type = $comment_type_storage->load($comment_type_id)) {
if ($comment_type->getTargetEntityTypeId() !== $entity_type) { 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( throw new \InvalidArgumentException("The given comment type id $comment_type_id can only be used with the $entity_type entity type");
'%id' => $comment_type_id,
'%entity_type' => $entity_type,
)));
} }
} }
else { else {

View File

@ -295,8 +295,8 @@ class ConfigImporterTest extends KernelTestBase {
$logs = $this->configImporter->getErrors(); $logs = $this->configImporter->getErrors();
$this->assertEqual(count($logs), 1); $this->assertEqual(count($logs), 1);
$message = SafeMarkup::format('config_test entity with ID @name already exists', array('@name' => 'secondary')); $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))); $this->assertEqual($logs[0], SafeMarkup::format('Unexpected error during import with operation @op for @name: !message.', array('@op' => 'create', '@name' => $name_primary, '!message' => $message)));
} }
/** /**

View File

@ -7,7 +7,6 @@
namespace Drupal\config_translation; namespace Drupal\config_translation;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException; use Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException;
use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Config\TypedConfigManagerInterface; use Drupal\Core\Config\TypedConfigManagerInterface;
@ -134,7 +133,7 @@ class ConfigMapperManager extends DefaultPluginManager implements ConfigMapperMa
parent::processDefinition($definition, $plugin_id); parent::processDefinition($definition, $plugin_id);
if (!isset($definition['base_route_name'])) { 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.");
} }
} }

View File

@ -110,12 +110,12 @@ class FieldConfig extends FieldConfigBase implements FieldConfigInterface {
throw new FieldException('Attempt to create a field without a field_name.'); throw new FieldException('Attempt to create a field without a field_name.');
} }
if (empty($values['entity_type'])) { 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. // 'bundle' is required in either case.
if (empty($values['bundle'])) { 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); parent::__construct($values, $entity_type);
@ -288,9 +288,10 @@ class FieldConfig extends FieldConfigBase implements FieldConfigInterface {
if (!$this->fieldStorage) { if (!$this->fieldStorage) {
$fields = $this->entityManager()->getFieldStorageDefinitions($this->entity_type); $fields = $this->entityManager()->getFieldStorageDefinitions($this->entity_type);
if (!isset($fields[$this->field_name])) { 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) { 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]; $this->fieldStorage = $fields[$this->field_name];
} }

View File

@ -7,7 +7,6 @@
namespace Drupal\field\Entity; namespace Drupal\field\Entity;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Component\Utility\Unicode; use Drupal\Component\Utility\Unicode;
use Drupal\Core\Config\Entity\ConfigEntityBase; use Drupal\Core\Config\Entity\ConfigEntityBase;
use Drupal\Core\Entity\EntityStorageInterface; 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.'); throw new FieldException('Attempt to create a field storage without a field name.');
} }
if (!preg_match('/^[_a-z]+[_a-z0-9]*$/', $values['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'])) { 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'])) { 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); 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 // We use Unicode::strlen() because the DB layer assumes that column widths
// are given in characters rather than bytes. // are given in characters rather than bytes.
if (Unicode::strlen($this->getName()) > static::NAME_MAX_LENGTH) { if (Unicode::strlen($this->getName()) > static::NAME_MAX_LENGTH) {
throw new FieldException(SafeMarkup::format( throw new FieldException('Attempt to create a field storage with an name longer than ' . static::NAME_MAX_LENGTH . ' characters: ' . $this->getName());
'Attempt to create a field storage with an name longer than @max characters: %name', array(
'@max' => static::NAME_MAX_LENGTH,
'%name' => $this->getName(),
)
));
} }
// Disallow reserved field names. // Disallow reserved field names.
$disallowed_field_names = array_keys($entity_manager->getBaseFieldDefinitions($this->getTargetEntityTypeId())); $disallowed_field_names = array_keys($entity_manager->getBaseFieldDefinitions($this->getTargetEntityTypeId()));
if (in_array($this->getName(), $disallowed_field_names)) { 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. // Check that the field type is known.
$field_type = $field_type_manager->getDefinition($this->getType(), FALSE); $field_type = $field_type_manager->getDefinition($this->getType(), FALSE);
if (!$field_type) { 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']; $this->module = $field_type['provider'];

View File

@ -178,7 +178,7 @@ class FieldConfigEntityUnitTest extends UnitTestCase {
* Test that invalid bundles are handled. * Test that invalid bundles are handled.
* *
* @expectedException \LogicException * @expectedException \LogicException
* @expectedExceptionMessage Missing bundle entity, entity type <em class="placeholder">bundle_entity_type</em>, entity id <em class="placeholder">test_bundle_not_exists</em>. * @expectedExceptionMessage Missing bundle entity, entity type bundle_entity_type, entity id test_bundle_not_exists.
*/ */
public function testCalculateDependenciesIncorrectBundle() { public function testCalculateDependenciesIncorrectBundle() {
$storage = $this->getMock('\Drupal\Core\Config\Entity\ConfigEntityStorageInterface'); $storage = $this->getMock('\Drupal\Core\Config\Entity\ConfigEntityStorageInterface');

View File

@ -627,7 +627,7 @@ class ManageFieldsTest extends WebTestBase {
// The external redirect should not fire. // The external redirect should not fire.
$this->assertUrl('admin/structure/types/manage/article/fields/node.article.body/storage', $options); $this->assertUrl('admin/structure/types/manage/article/fields/node.article.body/storage', $options);
$this->assertResponse(200); $this->assertResponse(200);
$this->assertRaw('Attempt to update field <em class="placeholder">Body</em> failed: <em class="placeholder">The internal path component "http://example.com" is external. You are not allowed to specify an external URL together with internal:/.</em>.'); $this->assertRaw('Attempt to update field <em class="placeholder">Body</em> failed: <em class="placeholder">The internal path component &#039;http://example.com&#039; is external. You are not allowed to specify an external URL together with internal:/.</em>.');
} }
/** /**

View File

@ -13,7 +13,6 @@ use Drupal\Core\Form\FormStateInterface;
use Drupal\image\ConfigurableImageEffectInterface; use Drupal\image\ConfigurableImageEffectInterface;
use Drupal\image\ImageStyleInterface; use Drupal\image\ImageStyleInterface;
use Drupal\Component\Plugin\Exception\PluginNotFoundException; use Drupal\Component\Plugin\Exception\PluginNotFoundException;
use Drupal\Component\Utility\SafeMarkup;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/** /**
@ -61,7 +60,7 @@ abstract class ImageEffectFormBase extends FormBase {
$this->imageEffect = $this->prepareImageEffect($image_effect); $this->imageEffect = $this->prepareImageEffect($image_effect);
} }
catch (PluginNotFoundException $e) { 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(); $request = $this->getRequest();

View File

@ -7,8 +7,6 @@
namespace Drupal\language\Config; namespace Drupal\language\Config;
use Drupal\Component\Utility\SafeMarkup;
/** /**
* Provides a common trait for working with language override collection names. * Provides a common trait for working with language override collection names.
*/ */
@ -45,7 +43,7 @@ trait LanguageConfigCollectionNameTrait {
protected function getLangcodeFromCollectionName($collection) { protected function getLangcodeFromCollectionName($collection) {
preg_match('/^language\.(.*)$/', $collection, $matches); preg_match('/^language\.(.*)$/', $collection, $matches);
if (!isset($matches[1])) { 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]; return $matches[1];
} }

View File

@ -7,7 +7,6 @@
namespace Drupal\language\Entity; namespace Drupal\language\Entity;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Config\Entity\ConfigEntityBase; use Drupal\Core\Config\Entity\ConfigEntityBase;
use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Language\LanguageInterface; 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 // If the target entity type uses entities to manage its bundles then
// depend on the bundle entity. // depend on the bundle entity.
if (!$bundle_entity = $this->entityManager()->getStorage($bundle_entity_type_id)->load($this->target_bundle)) { 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()); $this->addDependency('config', $bundle_entity->getConfigDependencyName());
} }

View File

@ -190,9 +190,7 @@ abstract class StringBase implements StringInterface {
$storage->save($this); $storage->save($this);
} }
else { else {
throw new StringStorageException(SafeMarkup::format('The string cannot be saved because its not bound to a storage: @string', array( throw new StringStorageException('The string cannot be saved because its not bound to a storage: ' . $this->getString());
'@string' => $this->getString(),
)));
} }
return $this; return $this;
} }
@ -206,9 +204,7 @@ abstract class StringBase implements StringInterface {
$storage->delete($this); $storage->delete($this);
} }
else { else {
throw new StringStorageException(SafeMarkup::format('The string cannot be deleted because its not bound to a storage: @string', array( throw new StringStorageException('The string cannot be deleted because its not bound to a storage: ' . $this->getString());
'@string' => $this->getString(),
)));
} }
} }
return $this; return $this;

View File

@ -199,9 +199,7 @@ class StringDatabaseStorage implements StringStorageInterface {
} }
} }
else { else {
throw new StringStorageException(format_string('The string cannot be deleted because it lacks some key fields: @string', array( throw new StringStorageException('The string cannot be deleted because it lacks some key fields: ' . $string->getString());
'@string' => $string->getString(),
)));
} }
return $this; return $this;
} }
@ -483,9 +481,7 @@ class StringDatabaseStorage implements StringStorageInterface {
->execute(); ->execute();
} }
else { else {
throw new StringStorageException(format_string('The string cannot be saved: @string', array( throw new StringStorageException('The string cannot be saved: ' . $string->getString());
'@string' => $string->getString(),
)));
} }
} }
@ -516,9 +512,7 @@ class StringDatabaseStorage implements StringStorageInterface {
->execute(); ->execute();
} }
else { else {
throw new StringStorageException(format_string('The string cannot be updated: @string', array( throw new StringStorageException('The string cannot be updated: ' . $string->getString());
'@string' => $string->getString(),
)));
} }
} }

View File

@ -8,7 +8,6 @@
namespace Drupal\menu_link_content\Plugin\Menu; namespace Drupal\menu_link_content\Plugin\Menu;
use Drupal\Component\Plugin\Exception\PluginException; use Drupal\Component\Plugin\Exception\PluginException;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Language\LanguageManagerInterface; use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\Core\Menu\MenuLinkBase; use Drupal\Core\Menu\MenuLinkBase;
@ -138,7 +137,7 @@ class MenuLinkContent extends MenuLinkBase implements ContainerFactoryPluginInte
$entity = reset($loaded_entities); $entity = reset($loaded_entities);
} }
if (!$entity) { 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. // Clone the entity object to avoid tampering with the static cache.
$this->entity = clone $entity; $this->entity = clone $entity;

View File

@ -7,7 +7,6 @@
namespace Drupal\migrate\Entity; namespace Drupal\migrate\Entity;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Config\Entity\ConfigEntityBase; use Drupal\Core\Config\Entity\ConfigEntityBase;
use Drupal\migrate\Exception\RequirementsException; use Drupal\migrate\Exception\RequirementsException;
use Drupal\migrate\MigrateException; use Drupal\migrate\MigrateException;
@ -381,7 +380,7 @@ class Migration extends ConfigEntityBase implements MigrationInterface, Requirem
} }
} }
if ($missing_migrations) { 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]);
} }
} }

View File

@ -7,7 +7,6 @@
namespace Drupal\migrate\Plugin\migrate\destination; namespace Drupal\migrate\Plugin\migrate\destination;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\File\FileSystemInterface; 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. // Ensure the source file exists, if it's a local URI or path.
if ($this->isLocalUri($source) && !file_exists($source)) { 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. // 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); $success = $this->writeFile($source, $destination, $replace);
} }
else { 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); return parent::import($row, $old_destination_id_values);
} }
else { 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.");
} }
} }

View File

@ -7,7 +7,6 @@
namespace Drupal\migrate\Plugin\migrate\process; namespace Drupal\migrate\Plugin\migrate\process;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\migrate\MigrateException; use Drupal\migrate\MigrateException;
use Drupal\migrate\MigrateExecutableInterface; use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\ProcessPluginBase; use Drupal\migrate\ProcessPluginBase;
@ -34,7 +33,7 @@ class Concat extends ProcessPluginBase {
return implode($delimiter, $value); return implode($delimiter, $value);
} }
else { 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)));
} }
} }

View File

@ -94,7 +94,7 @@ class EntityFileTest extends KernelTestBase {
$this->fail('Expected Drupal\migrate\MigrateException when importing ' . $destination); $this->fail('Expected Drupal\migrate\MigrateException when importing ' . $destination);
} }
catch (MigrateException $e) { catch (MigrateException $e) {
$this->assertIdentical($e->getMessage(), 'File ' . $destination . ' does not exist.'); $this->assertIdentical($e->getMessage(), "File '$destination' does not exist.");
} }
} }

View File

@ -7,7 +7,6 @@
namespace Drupal\Tests\migrate\Unit; namespace Drupal\Tests\migrate\Unit;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Database\Connection; use Drupal\Core\Database\Connection;
use Drupal\migrate\Entity\MigrationInterface; use Drupal\migrate\Entity\MigrationInterface;
use Drupal\migrate\MigrateException; use Drupal\migrate\MigrateException;
@ -61,7 +60,7 @@ class TestSqlIdMap extends Sql implements \Iterator {
'not null' => FALSE, 'not null' => FALSE,
); );
default: default:
throw new MigrateException(SafeMarkup::format('@type not supported', array('@type' => $id_definition['type']))); throw new MigrateException($id_definition['type'] . ' not supported');
} }
} }
} }

View File

@ -7,7 +7,6 @@
namespace Drupal\migrate_drupal; namespace Drupal\migrate_drupal;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Component\Uuid\UuidInterface; use Drupal\Component\Uuid\UuidInterface;
use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityInterface;
@ -164,7 +163,7 @@ class MigrationStorage extends BaseMigrationStorage {
*/ */
public function save(EntityInterface $entity) { public function save(EntityInterface $entity) {
if (strpos($entity->id(), ':') !== FALSE) { 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); return parent::save($entity);
} }

View File

@ -7,7 +7,6 @@
namespace Drupal\migrate_drupal\Plugin\migrate\load; namespace Drupal\migrate_drupal\Plugin\migrate\load;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Plugin\PluginBase; use Drupal\Core\Plugin\PluginBase;
use Drupal\migrate\Entity\MigrationInterface; 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.'); throw new MigrateException('Migrations with a load plugin using LoadEntity should have an entity as source.');
} }
if ($source_plugin->bundleMigrationRequired() && empty($configuration['bundle_migration'])) { 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.");
} }
} }

View File

@ -8,7 +8,6 @@
namespace Drupal\migrate_drupal\Plugin\migrate\source; namespace Drupal\migrate_drupal\Plugin\migrate\source;
use Drupal\Component\Plugin\DependentPluginInterface; use Drupal\Component\Plugin\DependentPluginInterface;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Entity\DependencyTrait; use Drupal\Core\Entity\DependencyTrait;
use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
@ -102,11 +101,11 @@ abstract class DrupalSqlBase extends SqlBase implements ContainerFactoryPluginIn
if (isset($this->pluginDefinition['source_provider'])) { if (isset($this->pluginDefinition['source_provider'])) {
if ($this->moduleExists($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']) { 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 { 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']]);
} }
} }
} }

View File

@ -5,7 +5,6 @@
* Responsive image display formatter for image fields. * Responsive image display formatter for image fields.
*/ */
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Component\Utility\Unicode; use Drupal\Component\Utility\Unicode;
use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Routing\RouteMatchInterface;
use \Drupal\Core\Template\Attribute; 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 // this breakpoint should be merged into one srcset and the sizes
// attribute should be merged as well. // attribute should be merged as well.
if (is_null($dimensions['width'])) { 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. // 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 // Images within a srcset should be sorted from small to large, since

View File

@ -11,7 +11,6 @@ use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityStorageException; use Drupal\Core\Entity\EntityStorageException;
use Drupal\rest\Plugin\ResourceBase; use Drupal\rest\Plugin\ResourceBase;
use Drupal\rest\ResourceResponse; use Drupal\rest\ResourceResponse;
use Drupal\Component\Utility\SafeMarkup;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
use Symfony\Component\HttpKernel\Exception\HttpException; use Symfony\Component\HttpKernel\Exception\HttpException;
@ -98,7 +97,7 @@ class EntityResource extends ResourceBase {
// and 'update', so the 'edit' operation is used here. // and 'update', so the 'edit' operation is used here.
foreach ($entity->_restSubmittedFields as $key => $field_name) { foreach ($entity->_restSubmittedFields as $key => $field_name) {
if (!$entity->get($field_name)->access('edit')) { 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')) { 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()); $original_entity->set($field_name, $field->getValue());
} }

View File

@ -381,9 +381,7 @@ EOD;
protected function installConfig(array $modules) { protected function installConfig(array $modules) {
foreach ($modules as $module) { foreach ($modules as $module) {
if (!$this->container->get('module_handler')->moduleExists($module)) { if (!$this->container->get('module_handler')->moduleExists($module)) {
throw new \RuntimeException(format_string("'@module' module is not enabled.", array( throw new \RuntimeException("'$module' module is not enabled");
'@module' => $module,
)));
} }
\Drupal::service('config.installer')->installDefaultConfig('module', $module); \Drupal::service('config.installer')->installDefaultConfig('module', $module);
} }
@ -411,18 +409,13 @@ EOD;
// behavior and non-reproducible test failures, we only allow the schema of // behavior and non-reproducible test failures, we only allow the schema of
// explicitly loaded/enabled modules to be installed. // explicitly loaded/enabled modules to be installed.
if (!$this->container->get('module_handler')->moduleExists($module)) { if (!$this->container->get('module_handler')->moduleExists($module)) {
throw new \RuntimeException(format_string("'@module' module is not enabled.", array( throw new \RuntimeException("'$module' module is not enabled");
'@module' => $module,
)));
} }
$tables = (array) $tables; $tables = (array) $tables;
foreach ($tables as $table) { foreach ($tables as $table) {
$schema = drupal_get_module_schema($module, $table); $schema = drupal_get_module_schema($module, $table);
if (empty($schema)) { if (empty($schema)) {
throw new \RuntimeException(format_string("Unknown '@table' table schema in '@module' module.", array( throw new \RuntimeException("Unknown '$table' table schema in '$module' module.");
'@module' => $module,
'@table' => $table,
)));
} }
$this->container->get('database')->schema()->createTable($table, $schema); $this->container->get('database')->schema()->createTable($table, $schema);
} }

View File

@ -7,8 +7,6 @@
namespace Drupal\system\Plugin\ImageToolkit\Operation\gd; namespace Drupal\system\Plugin\ImageToolkit\Operation\gd;
use Drupal\Component\Utility\SafeMarkup;
/** /**
* Defines GD2 convert operation. * Defines GD2 convert operation.
* *
@ -38,7 +36,7 @@ class Convert extends GDImageToolkitOperationBase {
*/ */
protected function validateArguments(array $arguments) { protected function validateArguments(array $arguments) {
if (!in_array($arguments['extension'], $this->getToolkit()->getSupportedExtensions())) { 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; return $arguments;
} }

View File

@ -8,7 +8,6 @@
namespace Drupal\system\Plugin\ImageToolkit\Operation\gd; namespace Drupal\system\Plugin\ImageToolkit\Operation\gd;
use Drupal\Component\Utility\Color; use Drupal\Component\Utility\Color;
use Drupal\Component\Utility\SafeMarkup;
/** /**
* Defines GD2 create_new image operation. * Defines GD2 create_new image operation.
@ -53,7 +52,7 @@ class CreateNew extends GDImageToolkitOperationBase {
protected function validateArguments(array $arguments) { protected function validateArguments(array $arguments) {
// Assure extension is supported. // Assure extension is supported.
if (!in_array($arguments['extension'], $this->getToolkit()->getSupportedExtensions())) { 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. // Assure integers for width and height.
@ -62,15 +61,15 @@ class CreateNew extends GDImageToolkitOperationBase {
// Fail when width or height are 0 or negative. // Fail when width or height are 0 or negative.
if ($arguments['width'] <= 0) { 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) { 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. // Assure transparent color is a valid hex string.
if ($arguments['transparent_color'] && !Color::validateHex($arguments['transparent_color'])) { 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; return $arguments;

View File

@ -7,8 +7,6 @@
namespace Drupal\system\Plugin\ImageToolkit\Operation\gd; namespace Drupal\system\Plugin\ImageToolkit\Operation\gd;
use Drupal\Component\Utility\SafeMarkup;
/** /**
* Defines GD2 Crop operation. * Defines GD2 Crop operation.
* *
@ -67,10 +65,10 @@ class Crop extends GDImageToolkitOperationBase {
// Fail when width or height are 0 or negative. // Fail when width or height are 0 or negative.
if ($arguments['width'] <= 0) { 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) { 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; return $arguments;

View File

@ -7,8 +7,6 @@
namespace Drupal\system\Plugin\ImageToolkit\Operation\gd; namespace Drupal\system\Plugin\ImageToolkit\Operation\gd;
use Drupal\Component\Utility\SafeMarkup;
/** /**
* Defines GD2 resize operation. * Defines GD2 resize operation.
* *
@ -46,10 +44,10 @@ class Resize extends GDImageToolkitOperationBase {
// Fail when width or height are 0 or negative. // Fail when width or height are 0 or negative.
if ($arguments['width'] <= 0) { 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) { 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; return $arguments;

View File

@ -7,8 +7,6 @@
namespace Drupal\system\Plugin\ImageToolkit\Operation\gd; namespace Drupal\system\Plugin\ImageToolkit\Operation\gd;
use Drupal\Component\Utility\SafeMarkup;
/** /**
* Defines GD2 Scale operation. * Defines GD2 Scale operation.
* *
@ -73,10 +71,10 @@ class Scale extends Resize {
// Fail when width or height are 0 or negative. // Fail when width or height are 0 or negative.
if ($arguments['width'] <= 0) { 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) { 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; return $arguments;

View File

@ -7,8 +7,6 @@
namespace Drupal\system\Plugin\ImageToolkit\Operation\gd; namespace Drupal\system\Plugin\ImageToolkit\Operation\gd;
use Drupal\Component\Utility\SafeMarkup;
/** /**
* Defines GD2 Scale and crop operation. * Defines GD2 Scale and crop operation.
* *
@ -54,10 +52,10 @@ class ScaleAndCrop extends GDImageToolkitOperationBase {
// Fail when width or height are 0 or negative. // Fail when width or height are 0 or negative.
if ($arguments['width'] <= 0) { 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) { 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; return $arguments;

View File

@ -57,7 +57,7 @@ class ContextPluginTest extends KernelTestBase {
$plugin->getContextValue('user'); $plugin->getContextValue('user');
} }
catch(ContextException $e) { 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. // Try to pass the wrong class type as a context value.

View File

@ -120,4 +120,28 @@ class ExceptionHandlingTest extends KernelTestBase {
$this->assertTrue(strpos($response->getContent(), '<script>alert(\'xss\')</script>') === FALSE); $this->assertTrue(strpos($response->getContent(), '<script>alert(\'xss\')</script>') === 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: <p> <br> <h3>'));
$this->assertNoRaw('<p> <br> <h3>');
}
} }

View File

@ -7,7 +7,6 @@
namespace Drupal\accept_header_routing_test\Routing; namespace Drupal\accept_header_routing_test\Routing;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Routing\RouteFilterInterface; use Drupal\Core\Routing\RouteFilterInterface;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\NotAcceptableHttpException; use Symfony\Component\HttpKernel\Exception\NotAcceptableHttpException;
@ -62,7 +61,7 @@ class AcceptHeaderMatcher implements RouteFilterInterface {
// We do not throw a // We do not throw a
// \Symfony\Component\Routing\Exception\ResourceNotFoundException here // \Symfony\Component\Routing\Exception\ResourceNotFoundException here
// because we don't want to return a 404 status code, but rather a 406. // 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 formats @formats.', array('@formats' => implode(' ', $acceptable_mime_types)))); throw new NotAcceptableHttpException('No route found for the specified formats ' . implode(' ', $acceptable_mime_types));
} }
/** /**

View File

@ -148,6 +148,13 @@ router_test.23:
requirements: requirements:
_access: 'TRUE' _access: 'TRUE'
router_test.24:
path: '/router_test/test24'
defaults:
_controller: '\Drupal\router_test\TestControllers::test24'
requirements:
_access: 'TRUE'
router_test.hierarchy_parent: router_test.hierarchy_parent:
path: '/menu-test/parent' path: '/menu-test/parent'
defaults: defaults:

View File

@ -76,14 +76,7 @@ class TestControllers {
* This can be used to test if the generated backtrace is properly escaped. * This can be used to test if the generated backtrace is properly escaped.
*/ */
public function test10() { public function test10() {
// Remove the exception logger from the event dispatcher. We are going to $this->removeExceptionLogger();
// throw an exception to check if it is properly escaped when rendered as a
// backtrace. The exception logger does a call to error_log() which is not
// handled by the Simpletest error handler and would cause a test failure.
$event_dispatcher = \Drupal::service('event_dispatcher');
$exception_logger = \Drupal::service('exception.logger');
$event_dispatcher->removeSubscriber($exception_logger);
$this->throwException('<script>alert(\'xss\')</script>'); $this->throwException('<script>alert(\'xss\')</script>');
} }
@ -108,6 +101,11 @@ class TestControllers {
return new HtmlResponse('test23'); return new HtmlResponse('test23');
} }
public function test24() {
$this->removeExceptionLogger();
throw new \Exception('Escaped content: <p> <br> <h3>');
}
/** /**
* Throws an exception. * Throws an exception.
* *
@ -121,4 +119,14 @@ class TestControllers {
throw new \Exception($message); throw new \Exception($message);
} }
protected function removeExceptionLogger() {
// Remove the exception logger from the event dispatcher. We are going to
// throw an exception to check if it is properly escaped when rendered as a
// backtrace. The exception logger does a call to error_log() which is not
// handled by the Simpletest error handler and would cause a test failure.
$event_dispatcher = \Drupal::service('event_dispatcher');
$exception_logger = \Drupal::service('exception.logger');
$event_dispatcher->removeSubscriber($exception_logger);
}
} }

View File

@ -7,7 +7,6 @@
namespace Drupal\user; namespace Drupal\user;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface; use Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface;
use Drupal\Core\Lock\LockBackendInterface; use Drupal\Core\Lock\LockBackendInterface;
use Drupal\Core\Session\AccountProxyInterface; use Drupal\Core\Session\AccountProxyInterface;
@ -122,10 +121,7 @@ class PrivateTempStore {
if (!$this->lockBackend->acquire($key)) { if (!$this->lockBackend->acquire($key)) {
$this->lockBackend->wait($key); $this->lockBackend->wait($key);
if (!$this->lockBackend->acquire($key)) { if (!$this->lockBackend->acquire($key)) {
throw new TempStoreException(SafeMarkup::format("Couldn't acquire lock to update item %key in %collection temporary storage.", array( throw new TempStoreException("Couldn't acquire lock to update item '$key' in '{$this->storage->getCollectionName()}' temporary storage.");
'%key' => $key,
'%collection' => $this->storage->getCollectionName(),
)));
} }
} }
@ -180,10 +176,7 @@ class PrivateTempStore {
if (!$this->lockBackend->acquire($key)) { if (!$this->lockBackend->acquire($key)) {
$this->lockBackend->wait($key); $this->lockBackend->wait($key);
if (!$this->lockBackend->acquire($key)) { if (!$this->lockBackend->acquire($key)) {
throw new TempStoreException(SafeMarkup::format("Couldn't acquire lock to delete item %key from %collection temporary storage.", array( throw new TempStoreException("Couldn't acquire lock to delete item '$key' from '{$this->storage->getCollectionName()}' temporary storage.");
'%key' => $key,
'%collection' => $this->storage->getCollectionName(),
)));
} }
} }
$this->storage->delete($key); $this->storage->delete($key);

View File

@ -7,7 +7,6 @@
namespace Drupal\user; namespace Drupal\user;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface; use Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface;
use Drupal\Core\Lock\LockBackendInterface; use Drupal\Core\Lock\LockBackendInterface;
use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\RequestStack;
@ -196,10 +195,7 @@ class SharedTempStore {
if (!$this->lockBackend->acquire($key)) { if (!$this->lockBackend->acquire($key)) {
$this->lockBackend->wait($key); $this->lockBackend->wait($key);
if (!$this->lockBackend->acquire($key)) { if (!$this->lockBackend->acquire($key)) {
throw new TempStoreException(SafeMarkup::format("Couldn't acquire lock to update item %key in %collection temporary storage.", array( throw new TempStoreException("Couldn't acquire lock to update item '$key' in '{$this->storage->getCollectionName()}' temporary storage.");
'%key' => $key,
'%collection' => $this->storage->getCollectionName(),
)));
} }
} }
@ -242,10 +238,7 @@ class SharedTempStore {
if (!$this->lockBackend->acquire($key)) { if (!$this->lockBackend->acquire($key)) {
$this->lockBackend->wait($key); $this->lockBackend->wait($key);
if (!$this->lockBackend->acquire($key)) { if (!$this->lockBackend->acquire($key)) {
throw new TempStoreException(SafeMarkup::format("Couldn't acquire lock to delete item %key from %collection temporary storage.", array( throw new TempStoreException("Couldn't acquire lock to delete item '$key' from {$this->storage->getCollectionName()} temporary storage.");
'%key' => $key,
'%collection' => $this->storage->getCollectionName(),
)));
} }
} }
$this->storage->delete($key); $this->storage->delete($key);

View File

@ -721,7 +721,7 @@ abstract class HandlerBase extends PluginBase implements ViewsHandlerInterface {
return $views_data['table']['entity type']; return $views_data['table']['entity type'];
} }
else { else {
throw new \Exception(SafeMarkup::format('No entity type for field @field on view @view', array('@field' => $this->options['id'], '@view' => $this->view->storage->id()))); throw new \Exception("No entity type for field {$this->options['id']} on view {$this->view->storage->id()}");
} }
} }

View File

@ -1454,7 +1454,7 @@ class Sql extends QueryPluginBase {
drupal_set_message($e->getMessage(), 'error'); drupal_set_message($e->getMessage(), 'error');
} }
else { else {
throw new DatabaseExceptionWrapper(format_string('Exception in @label[@view_name]: @message', array('@label' => $view->storage->label(), '@view_name' => $view->storage->id(), '@message' => $e->getMessage()))); throw new DatabaseExceptionWrapper("Exception in {$view->storage->label()}[$view->storage->id()]: {$e->getMessage()}");
} }
} }

View File

@ -9,7 +9,6 @@ namespace Drupal\views;
use Drupal\Component\Utility\Html; use Drupal\Component\Utility\Html;
use Drupal\Core\Cache\Cache; use Drupal\Core\Cache\Cache;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\DependencyInjection\DependencySerializationTrait; use Drupal\Core\DependencyInjection\DependencySerializationTrait;
use Drupal\Core\Form\FormState; use Drupal\Core\Form\FormState;
use Drupal\Core\Routing\RouteProviderInterface; use Drupal\Core\Routing\RouteProviderInterface;
@ -1874,7 +1873,7 @@ class ViewExecutable implements \Serializable {
public function getUrlInfo($display_id = '') { public function getUrlInfo($display_id = '') {
$this->initDisplay(); $this->initDisplay();
if (!$this->display_handler instanceof DisplayRouterInterface) { if (!$this->display_handler instanceof DisplayRouterInterface) {
throw new \InvalidArgumentException(SafeMarkup::format('You cannot generate a URL for the display @display_id', ['@display_id' => $display_id])); throw new \InvalidArgumentException("You cannot generate a URL for the display '$display_id'");
} }
return $this->display_handler->getUrlInfo(); return $this->display_handler->getUrlInfo();
} }

View File

@ -413,17 +413,12 @@ class ConfigTest extends UnitTestCase {
// Name missing namespace (dot). // Name missing namespace (dot).
array( array(
'MissingNamespace', 'MissingNamespace',
SafeMarkup::format('Missing namespace in Config object name MissingNamespace.', array( 'Missing namespace in Config object name MissingNamespace.',
'@name' => 'MissingNamespace',
)),
), ),
// Exceeds length (max length plus an extra dot). // Exceeds length (max length plus an extra dot).
array( array(
str_repeat('a', Config::MAX_NAME_LENGTH) . ".", str_repeat('a', Config::MAX_NAME_LENGTH) . ".",
SafeMarkup::format('Config object name @name exceeds maximum allowed length of @length characters.', array( 'Config object name ' . str_repeat('a', Config::MAX_NAME_LENGTH) . '. exceeds maximum allowed length of ' . Config::MAX_NAME_LENGTH . ' characters.',
'@name' => str_repeat('a', Config::MAX_NAME_LENGTH) . ".",
'@length' => Config::MAX_NAME_LENGTH,
)),
), ),
); );
// Name must not contain : ? * < > " ' / \ // Name must not contain : ? * < > " ' / \
@ -431,9 +426,7 @@ class ConfigTest extends UnitTestCase {
$name = 'name.' . $char; $name = 'name.' . $char;
$return[] = array( $return[] = array(
$name, $name,
SafeMarkup::format('Invalid character in Config object name @name.', array( "Invalid character in Config object name $name.",
'@name' => $name,
)),
); );
} }
return $return; return $return;

View File

@ -9,7 +9,6 @@ namespace Drupal\Tests\Core\Config\Entity;
use Drupal\Tests\UnitTestCase; use Drupal\Tests\UnitTestCase;
use Drupal\Core\Config\Entity\ConfigEntityType; use Drupal\Core\Config\Entity\ConfigEntityType;
use Drupal\Component\Utility\SafeMarkup;
/** /**
* @coversDefaultClass \Drupal\Core\Config\Entity\ConfigEntityType * @coversDefaultClass \Drupal\Core\Config\Entity\ConfigEntityType
@ -41,8 +40,6 @@ class ConfigEntityTypeTest extends UnitTestCase {
* @covers ::getConfigPrefix * @covers ::getConfigPrefix
*/ */
public function testConfigPrefixLengthExceeds() { public function testConfigPrefixLengthExceeds() {
$message_text = 'The configuration file name prefix @config_prefix exceeds the maximum character limit of @max_char.';
// A provider length of 24 and config_prefix length of 59 (+1 for the .) // A provider length of 24 and config_prefix length of 59 (+1 for the .)
// results in a config length of 84, which is too long. // results in a config length of 84, which is too long.
$definition = array( $definition = array(
@ -50,10 +47,10 @@ class ConfigEntityTypeTest extends UnitTestCase {
'config_prefix' => $this->randomMachineName(59), 'config_prefix' => $this->randomMachineName(59),
); );
$config_entity = $this->setUpConfigEntityType($definition); $config_entity = $this->setUpConfigEntityType($definition);
$this->setExpectedException('\Drupal\Core\Config\ConfigPrefixLengthException', SafeMarkup::format($message_text, array( $this->setExpectedException(
'@config_prefix' => $definition['provider'] . '.' . $definition['config_prefix'], '\Drupal\Core\Config\ConfigPrefixLengthException',
'@max_char' => ConfigEntityType::PREFIX_LENGTH, "The configuration file name prefix {$definition['provider']}.{$definition['config_prefix']} exceeds the maximum character limit of " . ConfigEntityType::PREFIX_LENGTH
))); );
$this->assertEmpty($config_entity->getConfigPrefix()); $this->assertEmpty($config_entity->getConfigPrefix());
} }

View File

@ -110,7 +110,7 @@ class EntityUrlTest extends UnitTestCase {
* @covers ::urlInfo * @covers ::urlInfo
* *
* @expectedException \Drupal\Core\Entity\Exception\UndefinedLinkTemplateException * @expectedException \Drupal\Core\Entity\Exception\UndefinedLinkTemplateException
* @expectedExceptionMessage No link template "canonical" found for the "test_entity_type" entity type * @expectedExceptionMessage No link template 'canonical' found for the 'test_entity_type' entity type
* *
* @dataProvider providerTestUrlInfoForInvalidLinkTemplate * @dataProvider providerTestUrlInfoForInvalidLinkTemplate
*/ */

View File

@ -466,7 +466,7 @@ class KeyValueEntityStorageTest extends UnitTestCase {
* @covers ::doSave * @covers ::doSave
* *
* @expectedException \Drupal\Core\Entity\EntityStorageException * @expectedException \Drupal\Core\Entity\EntityStorageException
* @expectedExceptionMessage test_entity_type entity with ID foo already exists * @expectedExceptionMessage 'test_entity_type' entity with ID 'foo' already exists
*/ */
public function testSaveDuplicate() { public function testSaveDuplicate() {
$this->setUpKeyValueEntityStorage(); $this->setUpKeyValueEntityStorage();

View File

@ -291,7 +291,7 @@ class DefaultTableMappingTest extends UnitTestCase {
* The name of the column to be processed. * The name of the column to be processed.
* *
* @expectedException \Drupal\Core\Entity\Sql\SqlContentEntityStorageException * @expectedException \Drupal\Core\Entity\Sql\SqlContentEntityStorageException
* @expectedExceptionMessage Column information not available for the "test" field. * @expectedExceptionMessage Column information not available for the 'test' field.
* *
* @covers ::getFieldColumnName * @covers ::getFieldColumnName
* *
@ -437,7 +437,7 @@ class DefaultTableMappingTest extends UnitTestCase {
* Tests DefaultTableMapping::getFieldTableName() with an invalid parameter. * Tests DefaultTableMapping::getFieldTableName() with an invalid parameter.
* *
* @expectedException \Drupal\Core\Entity\Sql\SqlContentEntityStorageException * @expectedException \Drupal\Core\Entity\Sql\SqlContentEntityStorageException
* @expectedExceptionMessage Table information not available for the "invalid_field_name" field. * @expectedExceptionMessage Table information not available for the 'invalid_field_name' field.
* *
* @covers ::getFieldTableName * @covers ::getFieldTableName
*/ */

View File

@ -779,7 +779,7 @@ class UrlTest extends UnitTestCase {
/** /**
* @expectedException \InvalidArgumentException * @expectedException \InvalidArgumentException
* @expectedExceptionMessage The route URI "route:" is invalid. * @expectedExceptionMessage The route URI 'route:' is invalid.
*/ */
public function testFromRouteUriWithMissingRouteName() { public function testFromRouteUriWithMissingRouteName() {
Url::fromUri('route:'); Url::fromUri('route:');