Update to Drupal 8.2.0. For more information, see https://www.drupal.org/project/drupal/releases/8.2.0
This commit is contained in:
parent
2f563ab520
commit
f1c8716f57
1732 changed files with 52334 additions and 11780 deletions
|
@ -24,7 +24,7 @@ class ConfigCollectionInfo extends Event {
|
|||
*
|
||||
* @param string $collection
|
||||
* Collection name to add.
|
||||
* @param \Drupal\Core\Config\ConfigFactoryOverrideInterface
|
||||
* @param \Drupal\Core\Config\ConfigFactoryOverrideInterface $override_service
|
||||
* (optional) The configuration factory override service responsible for the
|
||||
* collection.
|
||||
*
|
||||
|
@ -63,7 +63,7 @@ class ConfigCollectionInfo extends Event {
|
|||
* @param string $collection
|
||||
* The configuration collection.
|
||||
*
|
||||
* @return \Drupal\Core\Config\ConfigFactoryOverrideInterface|NULL
|
||||
* @return \Drupal\Core\Config\ConfigFactoryOverrideInterface|null
|
||||
* The override service responsible for the collection if one exists. NULL
|
||||
* if not.
|
||||
*/
|
||||
|
|
|
@ -19,7 +19,7 @@ class ConfigCrudEvent extends Event {
|
|||
/**
|
||||
* Constructs a configuration event object.
|
||||
*
|
||||
* @param \Drupal\Core\Config\Config
|
||||
* @param \Drupal\Core\Config\Config $config
|
||||
* Configuration object.
|
||||
*/
|
||||
public function __construct(Config $config) {
|
||||
|
|
|
@ -511,6 +511,7 @@ class ConfigInstaller implements ConfigInstallerInterface {
|
|||
* TRUE if the dependencies are met, FALSE if not.
|
||||
*/
|
||||
protected function validateDependencies($config_name, array $data, array $enabled_extensions, array $all_config) {
|
||||
list($provider) = explode('.', $config_name, 2);
|
||||
if (isset($data['dependencies'])) {
|
||||
$all_dependencies = $data['dependencies'];
|
||||
|
||||
|
@ -521,7 +522,6 @@ class ConfigInstaller implements ConfigInstallerInterface {
|
|||
}
|
||||
// Ensure the configuration entity type provider is in the list of
|
||||
// dependencies.
|
||||
list($provider) = explode('.', $config_name, 2);
|
||||
if (!isset($all_dependencies['module'])) {
|
||||
$all_dependencies['module'][] = $provider;
|
||||
}
|
||||
|
@ -548,6 +548,10 @@ class ConfigInstaller implements ConfigInstallerInterface {
|
|||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Simple config or a config entity without dependencies.
|
||||
return in_array($provider, $enabled_extensions, TRUE);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ interface ConfigInstallerInterface {
|
|||
* - it's a configuration entity.
|
||||
* - its dependencies can be met.
|
||||
*
|
||||
* @param \Drupal\Core\Config\StorageInterface
|
||||
* @param \Drupal\Core\Config\StorageInterface $storage
|
||||
* (optional) The configuration storage to search for optional
|
||||
* configuration. If not provided, all enabled extension's optional
|
||||
* configuration directories will be searched.
|
||||
|
|
|
@ -3,12 +3,12 @@
|
|||
namespace Drupal\Core\Config;
|
||||
|
||||
use Drupal\Component\Diff\Diff;
|
||||
use Drupal\Component\Serialization\Yaml;
|
||||
use Drupal\Core\Config\Entity\ConfigDependencyManager;
|
||||
use Drupal\Core\Config\Entity\ConfigEntityInterface;
|
||||
use Drupal\Core\Config\Entity\ConfigEntityTypeInterface;
|
||||
use Drupal\Core\Entity\EntityManagerInterface;
|
||||
use Drupal\Core\Entity\EntityTypeInterface;
|
||||
use Drupal\Core\Serialization\Yaml;
|
||||
use Drupal\Core\StringTranslation\StringTranslationTrait;
|
||||
use Drupal\Core\StringTranslation\TranslationInterface;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
|
|
|
@ -37,7 +37,7 @@ class ConfigModuleOverridesEvent extends Event {
|
|||
*
|
||||
* @param array $names
|
||||
* A list of configuration names.
|
||||
* @param \Drupal\Core\Language\LanguageInterface
|
||||
* @param \Drupal\Core\Language\LanguageInterface $language
|
||||
* (optional) The language for this configuration.
|
||||
*/
|
||||
public function __construct(array $names, LanguageInterface $language = NULL) {
|
||||
|
|
|
@ -174,10 +174,34 @@ class ConfigDependencyManager {
|
|||
// always after field storages. This is because field storages need to be
|
||||
// created before a field.
|
||||
$graph = $this->getGraph();
|
||||
uasort($graph, array($this, 'sortGraph'));
|
||||
$sorts = $this->prepareMultisort($graph, ['weight', 'name']);
|
||||
array_multisort($sorts['weight'], SORT_DESC, SORT_NUMERIC, $sorts['name'], SORT_ASC, SORT_NATURAL | SORT_FLAG_CASE, $graph);
|
||||
return array_replace(array_intersect_key($graph, $dependencies), $dependencies);
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts data from the graph for use in array_multisort().
|
||||
*
|
||||
* @param array $graph
|
||||
* The graph to extract data from.
|
||||
* @param array $keys
|
||||
* The keys whose values to extract.
|
||||
*
|
||||
* @return
|
||||
* An array keyed by the $keys passed in. The values are arrays keyed by the
|
||||
* row from the graph and the value is the corresponding value for the key
|
||||
* from the graph.
|
||||
*/
|
||||
protected function prepareMultisort($graph, $keys) {
|
||||
$return = array_fill_keys($keys, []);
|
||||
foreach ($graph as $graph_key => $graph_row) {
|
||||
foreach ($keys as $key) {
|
||||
$return[$key][$graph_key] = $graph_row[$key];
|
||||
}
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts the dependencies in order of most dependent last.
|
||||
*
|
||||
|
@ -189,7 +213,8 @@ class ConfigDependencyManager {
|
|||
$graph = $this->getGraph();
|
||||
// Sort by weight and alphabetically. The most dependent entities
|
||||
// are last and entities with the same weight are alphabetically ordered.
|
||||
uasort($graph, array($this, 'sortGraphByWeight'));
|
||||
$sorts = $this->prepareMultisort($graph, ['weight', 'name']);
|
||||
array_multisort($sorts['weight'], SORT_ASC, SORT_NUMERIC, $sorts['name'], SORT_ASC, SORT_NATURAL | SORT_FLAG_CASE, $graph);
|
||||
// Use array_intersect_key() to exclude modules and themes from the list.
|
||||
return array_keys(array_intersect_key($graph, $this->data));
|
||||
}
|
||||
|
@ -197,6 +222,10 @@ class ConfigDependencyManager {
|
|||
/**
|
||||
* Sorts the dependency graph by weight and alphabetically.
|
||||
*
|
||||
* @deprecated in Drupal 8.2.0, will be removed before Drupal 9.0.0. Use
|
||||
* \Drupal\Core\Config\Entity\ConfigDependencyManager::prepareMultisort() and
|
||||
* array_multisort() instead.
|
||||
*
|
||||
* @param array $a
|
||||
* First item for comparison. The compared items should be associative
|
||||
* arrays that include a 'weight' and a 'name' key.
|
||||
|
@ -218,6 +247,10 @@ class ConfigDependencyManager {
|
|||
/**
|
||||
* Sorts the dependency graph by reverse weight and alphabetically.
|
||||
*
|
||||
* @deprecated in Drupal 8.2.0, will be removed before Drupal 9.0.0. Use
|
||||
* \Drupal\Core\Config\Entity\ConfigDependencyManager::prepareMultisort() and
|
||||
* array_multisort() instead.
|
||||
*
|
||||
* @param array $a
|
||||
* First item for comparison. The compared items should be associative
|
||||
* arrays that include a 'weight' and a 'name' key.
|
||||
|
|
|
@ -65,7 +65,7 @@ interface ConfigEntityTypeInterface extends EntityTypeInterface {
|
|||
/**
|
||||
* Gets the config entity properties to export if declared on the annotation.
|
||||
*
|
||||
* @return array|NULL
|
||||
* @return array|null
|
||||
* The properties to export or NULL if they can not be determine from the
|
||||
* config entity type annotation.
|
||||
*/
|
||||
|
|
|
@ -135,7 +135,7 @@ abstract class DraggableListBuilder extends ConfigEntityListBuilder implements F
|
|||
$form['actions']['#type'] = 'actions';
|
||||
$form['actions']['submit'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Save order'),
|
||||
'#value' => t('Save'),
|
||||
'#button_type' => 'primary',
|
||||
);
|
||||
|
||||
|
|
|
@ -66,8 +66,8 @@ class QueryFactory implements QueryFactoryInterface, EventSubscriberInterface {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getAggregate(EntityTypeInterface $entity_type, $conjunction) {
|
||||
throw new QueryException('Aggregation over configuration entities is not supported');
|
||||
public function getAggregate(EntityTypeInterface $entity_type, $conjunction) {
|
||||
throw new QueryException('Aggregation over configuration entities is not supported');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -189,7 +189,7 @@ class QueryFactory implements QueryFactoryInterface, EventSubscriberInterface {
|
|||
* @param int $start
|
||||
* Which position of $parts we are processing. Defaults to 0.
|
||||
*
|
||||
* @return array|NULL
|
||||
* @return array|null
|
||||
* The array of configuration values the match the provided key. NULL if
|
||||
* the configuration object does not have a value that corresponds to the
|
||||
* key.
|
||||
|
|
|
@ -44,9 +44,8 @@ class ExtensionInstallStorage extends InstallStorage {
|
|||
* search and to get overrides from.
|
||||
*/
|
||||
public function __construct(StorageInterface $config_storage, $directory = self::CONFIG_INSTALL_DIRECTORY, $collection = StorageInterface::DEFAULT_COLLECTION, $include_profile = TRUE) {
|
||||
parent::__construct($directory, $collection);
|
||||
$this->configStorage = $config_storage;
|
||||
$this->directory = $directory;
|
||||
$this->collection = $collection;
|
||||
$this->includeProfile = $include_profile;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,8 +2,9 @@
|
|||
|
||||
namespace Drupal\Core\Config;
|
||||
|
||||
use Drupal\Component\Serialization\Yaml;
|
||||
use Drupal\Component\FileCache\FileCacheFactory;
|
||||
use Drupal\Component\Serialization\Exception\InvalidDataTypeException;
|
||||
use Drupal\Core\Serialization\Yaml;
|
||||
|
||||
/**
|
||||
* Defines the file storage.
|
||||
|
@ -24,6 +25,13 @@ class FileStorage implements StorageInterface {
|
|||
*/
|
||||
protected $directory = '';
|
||||
|
||||
/**
|
||||
* The file cache object.
|
||||
*
|
||||
* @var \Drupal\Component\FileCache\FileCacheInterface
|
||||
*/
|
||||
protected $fileCache;
|
||||
|
||||
/**
|
||||
* Constructs a new FileStorage.
|
||||
*
|
||||
|
@ -36,6 +44,11 @@ class FileStorage implements StorageInterface {
|
|||
public function __construct($directory, $collection = StorageInterface::DEFAULT_COLLECTION) {
|
||||
$this->directory = $directory;
|
||||
$this->collection = $collection;
|
||||
|
||||
// Use a NULL File Cache backend by default. This will ensure only the
|
||||
// internal statc caching of FileCache is used and thus avoids blowing up
|
||||
// the APCu cache.
|
||||
$this->fileCache = FileCacheFactory::get('config', ['cache_backend_class' => NULL]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -90,7 +103,12 @@ class FileStorage implements StorageInterface {
|
|||
if (!$this->exists($name)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$filepath = $this->getFilePath($name);
|
||||
if ($data = $this->fileCache->get($filepath)) {
|
||||
return $data;
|
||||
}
|
||||
|
||||
$data = file_get_contents($filepath);
|
||||
try {
|
||||
$data = $this->decode($data);
|
||||
|
@ -98,6 +116,8 @@ class FileStorage implements StorageInterface {
|
|||
catch (InvalidDataTypeException $e) {
|
||||
throw new UnsupportedDataTypeConfigException('Invalid data type in config ' . $name . ', found in file' . $filepath . ' : ' . $e->getMessage());
|
||||
}
|
||||
$this->fileCache->set($filepath, $data);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
@ -119,18 +139,18 @@ class FileStorage implements StorageInterface {
|
|||
*/
|
||||
public function write($name, array $data) {
|
||||
try {
|
||||
$data = $this->encode($data);
|
||||
$encoded_data = $this->encode($data);
|
||||
}
|
||||
catch (InvalidDataTypeException $e) {
|
||||
throw new StorageException("Invalid data type in config $name: {$e->getMessage()}");
|
||||
}
|
||||
|
||||
$target = $this->getFilePath($name);
|
||||
$status = @file_put_contents($target, $data);
|
||||
$status = @file_put_contents($target, $encoded_data);
|
||||
if ($status === FALSE) {
|
||||
// Try to make sure the directory exists and try writing again.
|
||||
$this->ensureStorage();
|
||||
$status = @file_put_contents($target, $data);
|
||||
$status = @file_put_contents($target, $encoded_data);
|
||||
}
|
||||
if ($status === FALSE) {
|
||||
throw new StorageException('Failed to write configuration file: ' . $this->getFilePath($name));
|
||||
|
@ -138,6 +158,9 @@ class FileStorage implements StorageInterface {
|
|||
else {
|
||||
drupal_chmod($target);
|
||||
}
|
||||
|
||||
$this->fileCache->set($target, $data);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -152,6 +175,7 @@ class FileStorage implements StorageInterface {
|
|||
}
|
||||
return FALSE;
|
||||
}
|
||||
$this->fileCache->delete($this->getFilePath($name));
|
||||
return drupal_unlink($this->getFilePath($name));
|
||||
}
|
||||
|
||||
|
@ -163,6 +187,8 @@ class FileStorage implements StorageInterface {
|
|||
if ($status === FALSE) {
|
||||
throw new StorageException('Failed to rename configuration file from: ' . $this->getFilePath($name) . ' to: ' . $this->getFilePath($new_name));
|
||||
}
|
||||
$this->fileCache->delete($this->getFilePath($name));
|
||||
$this->fileCache->delete($this->getFilePath($new_name));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -58,8 +58,7 @@ class InstallStorage extends FileStorage {
|
|||
* default collection.
|
||||
*/
|
||||
public function __construct($directory = self::CONFIG_INSTALL_DIRECTORY, $collection = StorageInterface::DEFAULT_COLLECTION) {
|
||||
$this->directory = $directory;
|
||||
$this->collection = $collection;
|
||||
parent::__construct($directory, $collection);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Reference in a new issue