Update to Drupal 8.0.0 beta 14. For more information, see https://drupal.org/node/2544542

This commit is contained in:
Pantheon Automation 2015-08-27 12:03:05 -07:00 committed by Greg Anderson
parent 3b2511d96d
commit 81ccda77eb
2155 changed files with 54307 additions and 46870 deletions

View file

@ -8,9 +8,9 @@
namespace Drupal\Core\Config;
use Drupal\Component\Utility\NestedArray;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Cache\CacheableDependencyInterface;
use Drupal\Core\Cache\RefinableCacheableDependencyInterface;
use Drupal\Core\Cache\RefinableCacheableDependencyTrait;
use \Drupal\Core\DependencyInjection\DependencySerializationTrait;
/**
@ -28,8 +28,9 @@ use \Drupal\Core\DependencyInjection\DependencySerializationTrait;
* @see \Drupal\Core\Config\Config
* @see \Drupal\Core\Theme\ThemeSettings
*/
abstract class ConfigBase implements CacheableDependencyInterface {
abstract class ConfigBase implements RefinableCacheableDependencyInterface {
use DependencySerializationTrait;
use RefinableCacheableDependencyTrait;
/**
* The name of the configuration object.
@ -97,24 +98,17 @@ abstract class ConfigBase implements CacheableDependencyInterface {
public static function validateName($name) {
// The name must be namespaced by owner.
if (strpos($name, '.') === FALSE) {
throw new ConfigNameException(SafeMarkup::format('Missing namespace in Config object name @name.', array(
'@name' => $name,
)));
throw new ConfigNameException("Missing namespace in Config object name $name.");
}
// The name must be shorter than Config::MAX_NAME_LENGTH characters.
if (strlen($name) > self::MAX_NAME_LENGTH) {
throw new ConfigNameException(SafeMarkup::format('Config object name @name exceeds maximum allowed length of @length characters.', array(
'@name' => $name,
'@length' => self::MAX_NAME_LENGTH,
)));
throw new ConfigNameException("Config object name $name exceeds maximum allowed length of " . static::MAX_NAME_LENGTH . " characters.");
}
// The name must not contain any of the following characters:
// : ? * < > " ' / \
if (preg_match('/[:?*<>"\'\/\\\\]/', $name)) {
throw new ConfigNameException(SafeMarkup::format('Invalid character in Config object name @name.', array(
'@name' => $name,
)));
throw new ConfigNameException("Invalid character in Config object name $name.");
}
}
@ -222,7 +216,7 @@ abstract class ConfigBase implements CacheableDependencyInterface {
protected function validateKeys(array $data) {
foreach ($data as $key => $value) {
if (strpos($key, '.') !== FALSE) {
throw new ConfigValueException(SafeMarkup::format('@key key contains a dot which is not supported.', array('@key' => $key)));
throw new ConfigValueException("$key key contains a dot which is not supported.");
}
if (is_array($value)) {
$this->validateKeys($value);
@ -269,21 +263,21 @@ abstract class ConfigBase implements CacheableDependencyInterface {
* {@inheritdoc}
*/
public function getCacheContexts() {
return [];
return $this->cacheContexts;
}
/**
* {@inheritdoc}
*/
public function getCacheTags() {
return ['config:' . $this->name];
return Cache::mergeTags(['config:' . $this->name], $this->cacheTags);
}
/**
* {@inheritdoc}
*/
public function getCacheMaxAge() {
return Cache::PERMANENT;
return $this->cacheMaxAge;
}
}

View file

@ -21,11 +21,16 @@ final class ConfigEvents {
* object is saved. The event listener method receives a
* \Drupal\Core\Config\ConfigCrudEvent instance.
*
* See hook_update_N() documentation for safe configuration API usage and
* restrictions as this event will be fired when configuration is saved by
* hook_update_N().
*
* @Event
*
* @see \Drupal\Core\Config\ConfigCrudEvent
* @see \Drupal\Core\Config\Config::save()
* @see \Drupal\Core\Config\ConfigFactory::onConfigSave()
* @see hook_update_N()
*
* @var string
*/
@ -38,11 +43,16 @@ final class ConfigEvents {
* object is deleted. The event listener method receives a
* \Drupal\Core\Config\ConfigCrudEvent instance.
*
* See hook_update_N() documentation for safe configuration API usage and
* restrictions as this event will be fired when configuration is deleted by
* hook_update_N().
*
* @Event
*
* @see \Drupal\Core\Config\ConfigCrudEvent
* @see \Drupal\Core\Config\Config::delete()
* @see \Drupal\Core\Config\ConfigFactory::onConfigDelete()
* @see hook_update_N()
*
* @var string
*/
@ -55,10 +65,15 @@ final class ConfigEvents {
* object's name is changed. The event listener method receives a
* \Drupal\Core\Config\ConfigRenameEvent instance.
*
* See hook_update_N() documentation for safe configuration API usage and
* restrictions as this event will be fired when configuration is renamed by
* hook_update_N().
*
* @Event
*
* @see \Drupal\Core\Config\ConfigRenameEvent
* @see \Drupal\Core\Config\ConfigFactoryInterface::rename().
* @see \Drupal\Core\Config\ConfigFactoryInterface::rename()
* @see hook_update_N()
*
* @var string
*/

View file

@ -126,6 +126,9 @@ class ConfigFactory implements ConfigFactoryInterface, EventSubscriberInterface
$this->cache[$cache_key]->setSettingsOverride($GLOBALS['config'][$name]);
}
}
$this->propagateConfigOverrideCacheability($cache_key, $name);
return $this->cache[$cache_key];
}
}
@ -183,6 +186,9 @@ class ConfigFactory implements ConfigFactoryInterface, EventSubscriberInterface
$this->cache[$cache_key]->setSettingsOverride($GLOBALS['config'][$name]);
}
}
$this->propagateConfigOverrideCacheability($cache_key, $name);
$list[$name] = $this->cache[$cache_key];
}
}
@ -209,6 +215,20 @@ class ConfigFactory implements ConfigFactoryInterface, EventSubscriberInterface
return $overrides;
}
/**
* Propagates cacheability of config overrides to cached config objects.
*
* @param string $cache_key
* The key of the cached config object to update.
* @param string $name
* The name of the configuration object to construct.
*/
protected function propagateConfigOverrideCacheability($cache_key, $name) {
foreach ($this->configFactoryOverrides as $override) {
$this->cache[$cache_key]->addCacheableDependency($override->getCacheableMetadata($name));
}
}
/**
* {@inheritdoc}
*/

View file

@ -74,7 +74,7 @@ abstract class ConfigFactoryOverrideBase implements EventSubscriberInterface {
}
elseif ($changed) {
// Otherwise set the filtered override values back.
$override->setData($override_data)->save();
$override->setData($override_data)->save(TRUE);
}
}

View file

@ -58,4 +58,15 @@ interface ConfigFactoryOverrideInterface {
*/
public function createConfigObject($name, $collection = StorageInterface::DEFAULT_COLLECTION);
/**
* Gets the cacheability metadata associated with the config factory override.
*
* @param string $name
* The name of the configuration override to get metadata for.
*
* @return \Drupal\Core\Cache\CacheableMetadata
* A cacheable metadata object.
*/
public function getCacheableMetadata($name);
}

View file

@ -11,7 +11,6 @@ use Drupal\Core\Config\Importer\MissingContentEvent;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Extension\ModuleInstallerInterface;
use Drupal\Core\Extension\ThemeHandlerInterface;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Config\Entity\ImportableEntityStorageInterface;
use Drupal\Core\DependencyInjection\DependencySerializationTrait;
use Drupal\Core\Entity\EntityStorageException;
@ -763,7 +762,7 @@ class ConfigImporter {
}
}
catch (\Exception $e) {
$this->logError($this->t('Unexpected error during import with operation @op for @name: @message', array('@op' => $op, '@name' => $name, '@message' => $e->getMessage())));
$this->logError($this->t('Unexpected error during import with operation @op for @name: !message', array('@op' => $op, '@name' => $name, '!message' => $e->getMessage())));
// Error for that operation was logged, mark it as processed so that
// the import can continue.
$this->setProcessedConfiguration($collection, $op, $name);
@ -972,7 +971,7 @@ class ConfigImporter {
// Call to the configuration entity's storage to handle the configuration
// change.
if (!($entity_storage instanceof ImportableEntityStorageInterface)) {
throw new EntityStorageException(SafeMarkup::format('The entity storage "@storage" for the "@entity_type" entity type does not support imports', array('@storage' => get_class($entity_storage), '@entity_type' => $entity_type)));
throw new EntityStorageException(sprintf('The entity storage "%s" for the "%s" entity type does not support imports', get_class($entity_storage), $entity_type));
}
$entity_storage->$method($name, $new_config, $old_config);
$this->setProcessedConfiguration($collection, $op, $name);
@ -1018,7 +1017,7 @@ class ConfigImporter {
// Call to the configuration entity's storage to handle the configuration
// change.
if (!($entity_storage instanceof ImportableEntityStorageInterface)) {
throw new EntityStorageException(SafeMarkup::format('The entity storage "@storage" for the "@entity_type" entity type does not support imports', array('@storage' => get_class($entity_storage), '@entity_type' => $entity_type_id)));
throw new EntityStorageException(sprintf("The entity storage '%s' for the '%s' entity type does not support imports", get_class($entity_storage), $entity_type_id));
}
$entity_storage->importRename($names['old_name'], $new_config, $old_config);
$this->setProcessedConfiguration($collection, 'rename', $rename_name);

View file

@ -7,7 +7,6 @@
namespace Drupal\Core\Config\Entity;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Config\ConfigException;
use Drupal\Core\Config\Schema\SchemaIncompleteException;
@ -192,8 +191,6 @@ abstract class ConfigEntityBase extends Entity implements ConfigEntityInterface
* {@inheritdoc}
*/
public function disable() {
// An entity was disabled, invalidate its own cache tag.
Cache::invalidateTags($this->getCacheTags());
return $this->setStatus(FALSE);
}
@ -280,7 +277,7 @@ abstract class ConfigEntityBase extends Entity implements ConfigEntityInterface
$config_name = $entity_type->getConfigPrefix() . '.' . $this->id();
$definition = $this->getTypedConfig()->getDefinition($config_name);
if (!isset($definition['mapping'])) {
throw new SchemaIncompleteException(SafeMarkup::format('Incomplete or missing schema for @config_name', array('@config_name' => $config_name)));
throw new SchemaIncompleteException("Incomplete or missing schema for $config_name");
}
$properties_to_export = array_combine(array_keys($definition['mapping']), array_keys($definition['mapping']));
}
@ -333,7 +330,7 @@ abstract class ConfigEntityBase extends Entity implements ConfigEntityInterface
->execute();
$matched_entity = reset($matching_entities);
if (!empty($matched_entity) && ($matched_entity != $this->id()) && $matched_entity != $this->getOriginalId()) {
throw new ConfigDuplicateUUIDException(SafeMarkup::format('Attempt to save a configuration entity %id with UUID %uuid when this UUID is already used for %matched', array('%id' => $this->id(), '%uuid' => $this->uuid(), '%matched' => $matched_entity)));
throw new ConfigDuplicateUUIDException("Attempt to save a configuration entity '{$this->id()}' with UUID '{$this->uuid()}' when this UUID is already used for '$matched_entity'");
}
// If this entity is not new, load the original entity for comparison.
@ -341,7 +338,7 @@ abstract class ConfigEntityBase extends Entity implements ConfigEntityInterface
$original = $storage->loadUnchanged($this->getOriginalId());
// Ensure that the UUID cannot be changed for an existing entity.
if ($original && ($original->uuid() != $this->uuid())) {
throw new ConfigDuplicateUUIDException(SafeMarkup::format('Attempt to save a configuration entity %id with UUID %uuid when this entity already exists with UUID %original_uuid', array('%id' => $this->id(), '%uuid' => $this->uuid(), '%original_uuid' => $original->uuid())));
throw new ConfigDuplicateUUIDException("Attempt to save a configuration entity '{$this->id()}' with UUID '{$this->uuid()}' when this entity already exists with UUID '{$original->uuid()}'");
}
}
if (!$this->isSyncing() && !$this->trustedData) {
@ -409,7 +406,7 @@ abstract class ConfigEntityBase extends Entity implements ConfigEntityInterface
/**
* {@inheritdoc}
*/
public function getCacheTags() {
public function getCacheTagsToInvalidate() {
// Use cache tags that match the underlying config object's name.
// @see \Drupal\Core\Config\ConfigBase::getCacheTags()
return ['config:' . $this->getConfigDependencyName()];

View file

@ -7,14 +7,13 @@
namespace Drupal\Core\Config\Entity;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Config\ConfigImporterException;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityMalformedException;
use Drupal\Core\Entity\EntityStorageBase;
use Drupal\Core\Config\Config;
use Drupal\Core\Config\StorageInterface;
use Drupal\Core\Config\Entity\Exception\ConfigEntityIdLengthException;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Component\Uuid\UuidInterface;
@ -184,11 +183,41 @@ class ConfigEntityStorage extends EntityStorageBase implements ConfigEntityStora
}
// Load all of the configuration entities.
$records = array();
/** @var \Drupal\Core\Config\Config[] $configs */
$configs = [];
$records = [];
foreach ($this->configFactory->loadMultiple($names) as $config) {
$records[$config->get($this->idKey)] = $this->overrideFree ? $config->getOriginal(NULL, FALSE) : $config->get();
$id = $config->get($this->idKey);
$records[$id] = $this->overrideFree ? $config->getOriginal(NULL, FALSE) : $config->get();
$configs[$id] = $config;
}
return $this->mapFromStorageRecords($records);
$entities = $this->mapFromStorageRecords($records, $configs);
// Config entities wrap config objects, and therefore they need to inherit
// the cacheability metadata of config objects (to ensure e.g. additional
// cacheability metadata added by config overrides is not lost).
foreach ($entities as $id => $entity) {
// But rather than simply inheriting all cacheability metadata of config
// objects, we need to make sure the self-referring cache tag that is
// present on Config objects is not added to the Config entity. It must be
// removed for 3 reasons:
// 1. When renaming/duplicating a Config entity, the cache tag of the
// original config object would remain present, which would be wrong.
// 2. Some Config entities choose to not use the cache tag that the under-
// lying Config object provides by default (For performance and
// cacheability reasons it may not make sense to have a unique cache
// tag for every Config entity. The DateFormat Config entity specifies
// the 'rendered' cache tag for example, because A) date formats are
// changed extremely rarely, so invalidating all render cache items is
// fine, B) it means fewer cache tags per page.).
// 3. Fewer cache tags is better for performance.
$self_referring_cache_tag = ['config:' . $configs[$id]->getName()];
$config_cacheability = CacheableMetadata::createFromObject($configs[$id]);
$config_cacheability->setCacheTags(array_diff($config_cacheability->getCacheTags(), $self_referring_cache_tag));
$entity->addCacheableDependency($config_cacheability);
}
return $entities;
}
/**
@ -229,10 +258,7 @@ class ConfigEntityStorage extends EntityStorageBase implements ConfigEntityStora
// @todo Consider moving this to a protected method on the parent class, and
// abstracting it for all entity types.
if (strlen($entity->get($this->idKey)) > self::MAX_ID_LENGTH) {
throw new ConfigEntityIdLengthException(SafeMarkup::format('Configuration entity ID @id exceeds maximum allowed length of @length characters.', array(
'@id' => $entity->get($this->idKey),
'@length' => self::MAX_ID_LENGTH,
)));
throw new ConfigEntityIdLengthException("Configuration entity ID {$entity->get($this->idKey)} exceeds maximum allowed length of " . self::MAX_ID_LENGTH . " characters.");
}
return parent::save($entity);
@ -374,7 +400,7 @@ class ConfigEntityStorage extends EntityStorageBase implements ConfigEntityStora
$id = static::getIDFromConfigName($name, $this->entityType->getConfigPrefix());
$entity = $this->load($id);
if (!$entity) {
throw new ConfigImporterException(SafeMarkup::format('Attempt to update non-existing entity "@id".', array('@id' => $id)));
throw new ConfigImporterException("Attempt to update non-existing entity '$id'.");
}
$entity->setSyncing(TRUE);
$entity = $this->updateFromStorageRecord($entity, $new_config->get());

View file

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

View file

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

View file

@ -7,8 +7,6 @@
namespace Drupal\Core\Config;
use Drupal\Component\Utility\SafeMarkup;
/**
* Defines the immutable configuration object.
*
@ -31,21 +29,21 @@ class ImmutableConfig extends Config {
* {@inheritdoc}
*/
public function set($key, $value) {
throw new ImmutableConfigException(SafeMarkup::format('Can not set values on immutable configuration !name:!key. Use \Drupal\Core\Config\ConfigFactoryInterface::getEditable() to retrieve a mutable configuration object', ['!name' => $this->getName(), '!key' => $key]));
throw new ImmutableConfigException("Can not set values on immutable configuration {$this->getName()}:$key. Use \\Drupal\\Core\\Config\\ConfigFactoryInterface::getEditable() to retrieve a mutable configuration object");
}
/**
* {@inheritdoc}
*/
public function clear($key) {
throw new ImmutableConfigException(SafeMarkup::format('Can not clear !key key in immutable configuration !name. Use \Drupal\Core\Config\ConfigFactoryInterface::getEditable() to retrieve a mutable configuration object', ['!name' => $this->getName(), '!key' => $key]));
throw new ImmutableConfigException("Can not clear $key key in immutable configuration {$this->getName()}. Use \\Drupal\\Core\\Config\\ConfigFactoryInterface::getEditable() to retrieve a mutable configuration object");
}
/**
* {@inheritdoc}
*/
public function save($has_trusted_data = FALSE) {
throw new ImmutableConfigException(SafeMarkup::format('Can not save immutable configuration !name. Use \Drupal\Core\Config\ConfigFactoryInterface::getEditable() to retrieve a mutable configuration object', ['!name' => $this->getName()]));
throw new ImmutableConfigException("Can not save immutable configuration {$this->getName()}. Use \\Drupal\\Core\\Config\\ConfigFactoryInterface::getEditable() to retrieve a mutable configuration object");
}
/**
@ -55,7 +53,7 @@ class ImmutableConfig extends Config {
* The configuration object.
*/
public function delete() {
throw new ImmutableConfigException(SafeMarkup::format('Can not delete immutable configuration !name. Use \Drupal\Core\Config\ConfigFactoryInterface::getEditable() to retrieve a mutable configuration object', ['!name' => $this->getName()]));
throw new ImmutableConfigException("Can not delete immutable configuration {$this->getName()}. Use \\Drupal\\Core\\Config\\ConfigFactoryInterface::getEditable() to retrieve a mutable configuration object");
}
}

View file

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

View file

@ -7,7 +7,6 @@
namespace Drupal\Core\Config\Schema;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Config\TypedConfigManagerInterface;
use Drupal\Core\TypedData\TypedData;
@ -94,7 +93,7 @@ abstract class ArrayElement extends TypedData implements \IteratorAggregate, Typ
return $element;
}
else {
throw new \InvalidArgumentException(SafeMarkup::format("The configuration property @key doesn't exist.", array('@key' => $name)));
throw new \InvalidArgumentException("The configuration property $name doesn't exist.");
}
}

View file

@ -24,7 +24,7 @@ interface TypedConfigInterface extends TraversableTypedDataInterface {
/**
* Determines whether the data structure is empty.
*
* @return boolean
* @return bool
* TRUE if the data structure is empty, FALSE otherwise.
*/
public function isEmpty();

View file

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

View file

@ -7,7 +7,6 @@
namespace Drupal\Core\Config;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Cache\MemoryBackend;
use Drupal\Core\Config\Entity\ConfigDependencyManager;
use Drupal\Core\DependencyInjection\DependencySerializationTrait;
@ -196,7 +195,7 @@ class StorageComparer implements StorageComparerInterface {
// ensure the array is keyed from 0.
$this->changelist[$collection][$op] = array_values(array_intersect($sort_order, $this->changelist[$collection][$op]));
if ($count != count($this->changelist[$collection][$op])) {
throw new \InvalidArgumentException(SafeMarkup::format('Sorting the @op changelist should not change its length.', array('@op' => $op)));
throw new \InvalidArgumentException("Sorting the $op changelist should not change its length.");
}
}
}

View file

@ -156,7 +156,7 @@ interface StorageInterface {
* (optional) The prefix to search for. If omitted, all configuration
* objects that exist will be deleted.
*
* @return boolean
* @return bool
* TRUE on success, FALSE otherwise.
*/
public function deleteAll($prefix = '');

View file

@ -88,14 +88,14 @@ class ConfigSchemaChecker implements EventSubscriberInterface {
$this->checked[$name . ':' . $checksum] = TRUE;
$errors = $this->checkConfigSchema($this->typedManager, $name, $data);
if ($errors === FALSE) {
throw new SchemaIncompleteException(SafeMarkup::format('No schema for @config_name', array('@config_name' => $name)));
throw new SchemaIncompleteException("No schema for $name");
}
elseif (is_array($errors)) {
$text_errors = [];
foreach ($errors as $key => $error) {
$text_errors[] = SafeMarkup::format('@key @error', array('@key' => $key, '@error' => $error));
}
throw new SchemaIncompleteException(SafeMarkup::format('Schema errors for @config_name with the following errors: @errors', array('@config_name' => $name, '@errors' => implode(', ', $text_errors))));
throw new SchemaIncompleteException("Schema errors for $name with the following errors: " . implode(', ', $text_errors));
}
}
}

View file

@ -8,7 +8,6 @@
namespace Drupal\Core\Config;
use Drupal\Component\Utility\NestedArray;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Config\Schema\ArrayElement;
use Drupal\Core\Config\Schema\ConfigSchemaAlterException;
@ -17,7 +16,7 @@ use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\TypedData\TypedDataManager;
/**
* Manages config type plugins.
* Manages config schema type plugins.
*/
class TypedConfigManager extends TypedDataManager implements TypedConfigManagerInterface {
@ -324,18 +323,18 @@ class TypedConfigManager extends TypedDataManager implements TypedConfigManagerI
parent::alterDefinitions($definitions);
$altered_schema = array_keys($definitions);
if ($discovered_schema != $altered_schema) {
$added_keys = array_diff($altered_schema, $discovered_schema);
$removed_keys = array_diff($discovered_schema, $altered_schema);
$added_keys = implode(',', array_diff($altered_schema, $discovered_schema));
$removed_keys = implode(',', array_diff($discovered_schema, $altered_schema));
if (!empty($added_keys) && !empty($removed_keys)) {
$message = 'Invoking hook_config_schema_info_alter() has added (@added) and removed (@removed) schema definitions';
$message = "Invoking hook_config_schema_info_alter() has added ($added_keys) and removed ($removed_keys) schema definitions";
}
elseif (!empty($added_keys)) {
$message = 'Invoking hook_config_schema_info_alter() has added (@added) schema definitions';
$message = "Invoking hook_config_schema_info_alter() has added ($added_keys) schema definitions";
}
else {
$message = 'Invoking hook_config_schema_info_alter() has removed (@removed) schema definitions';
$message = "Invoking hook_config_schema_info_alter() has removed ($removed_keys) schema definitions";
}
throw new ConfigSchemaAlterException(SafeMarkup::format($message, ['@added' => implode(',', $added_keys), '@removed' => implode(',', $removed_keys)]));
throw new ConfigSchemaAlterException($message);
}
}

View file

@ -12,9 +12,12 @@ use Drupal\Component\Plugin\PluginManagerInterface;
use Drupal\Core\TypedData\DataDefinitionInterface;
/**
* Defines an interface for typed configuration manager.
* Defines an interface for managing config schema type plugins.
*
* @package Drupal\Core\Config
* @see \Drupal\Core\Config\TypedConfigManager
* @see \Drupal\Core\Config\Schema\ConfigSchemaDiscovery
* @see hook_config_schema_info_alter()
* @see https://www.drupal.org/node/1905070
*/
Interface TypedConfigManagerInterface extends PluginManagerInterface, CachedDiscoveryInterface {