Commit b3a3555c authored by catch's avatar catch

Issue #2451359 by alexpott: Remove the ability of collections other than the...

Issue #2451359 by alexpott: Remove the ability of collections other than the default to support configuration entities
parent cf4f0039
......@@ -755,7 +755,7 @@ protected function validate() {
protected function processConfiguration($collection, $op, $name) {
try {
$processed = FALSE;
if ($this->configManager->supportsConfigurationEntities($collection)) {
if ($collection == StorageInterface::DEFAULT_COLLECTION) {
$processed = $this->importInvokeOwner($collection, $op, $name);
}
if (!$processed) {
......
......@@ -175,50 +175,40 @@ public function installOptionalConfig(StorageInterface $storage = NULL, $depende
$profile_storage = NULL;
}
$collection_info = $this->configManager->getConfigCollectionInfo();
$enabled_extensions = $this->getEnabledExtensions();
$existing_config = $this->getActiveStorages()->listAll();
$list = array_filter($storage->listAll(), function($config_name) use ($existing_config) {
// Only list configuration that:
// - does not already exist
// - is a configuration entity (this also excludes config that has an
// implicit dependency on modules that are not yet installed)
return !in_array($config_name, $existing_config) && $this->configManager->getEntityTypeIdByName($config_name);
});
foreach ($collection_info->getCollectionNames() as $collection) {
if (!$this->configManager->supportsConfigurationEntities($collection)) {
continue;
}
$existing_config = $this->getActiveStorages($collection)->listAll();
$list = array_filter($storage->listAll(), function($config_name) use ($existing_config) {
// Only list configuration that:
// - does not already exist
// - is a configuration entity (this also excludes config that has an
// implicit dependency on modules that are not yet installed)
return !in_array($config_name, $existing_config) && $this->configManager->getEntityTypeIdByName($config_name);
});
$all_config = array_merge($existing_config, $list);
$config_to_create = $storage->readMultiple($list);
// Check to see if the corresponding override storage has any overrides.
if ($profile_storage) {
if ($profile_storage->getCollectionName() != $collection) {
$profile_storage = $profile_storage->createCollection($collection);
}
$config_to_create = $profile_storage->readMultiple($list) + $config_to_create;
$all_config = array_merge($existing_config, $list);
$config_to_create = $storage->readMultiple($list);
// Check to see if the corresponding override storage has any overrides.
if ($profile_storage) {
$config_to_create = $profile_storage->readMultiple($list) + $config_to_create;
}
foreach ($config_to_create as $config_name => $data) {
// Exclude configuration where its dependencies cannot be met.
if (!$this->validateDependencies($config_name, $data, $enabled_extensions, $all_config)) {
unset($config_to_create[$config_name]);
}
foreach ($config_to_create as $config_name => $data) {
// Exclude configuration where its dependencies cannot be met.
if (!$this->validateDependencies($config_name, $data, $enabled_extensions, $all_config)) {
// Exclude configuration that does not have a matching dependency.
elseif (!empty($dependency)) {
// Create a light weight dependency object to check dependencies.
$config_entity = new ConfigEntityDependency($config_name, $data);
if (!$config_entity->hasDependency(key($dependency), reset($dependency))) {
unset($config_to_create[$config_name]);
}
// Exclude configuration that does not have a matching dependency.
elseif (!empty($dependency)) {
// Create a light weight dependency object to check dependencies.
$config_entity = new ConfigEntityDependency($config_name, $data);
if (!$config_entity->hasDependency(key($dependency), reset($dependency))) {
unset($config_to_create[$config_name]);
}
}
}
if (!empty($config_to_create)) {
$this->createConfiguration($collection, $config_to_create, TRUE);
}
}
if (!empty($config_to_create)) {
$this->createConfiguration(StorageInterface::DEFAULT_COLLECTION, $config_to_create, TRUE);
}
}
/**
......@@ -261,8 +251,7 @@ protected function getConfigToCreate(StorageInterface $storage, $collection, $pr
*/
protected function createConfiguration($collection, array $config_to_create) {
// Order the configuration to install in the order of dependencies.
$config_entity_support = $this->configManager->supportsConfigurationEntities($collection);
if ($config_entity_support) {
if ($collection == StorageInterface::DEFAULT_COLLECTION) {
$dependency_manager = new ConfigDependencyManager();
$config_names = $dependency_manager
->setData($config_to_create)
......@@ -285,7 +274,7 @@ protected function createConfiguration($collection, array $config_to_create) {
if ($config_to_create[$name] !== FALSE) {
$new_config->setData($config_to_create[$name]);
}
if ($config_entity_support && $entity_type = $this->configManager->getEntityTypeIdByName($name)) {
if ($collection == StorageInterface::DEFAULT_COLLECTION && $entity_type = $this->configManager->getEntityTypeIdByName($name)) {
// If we are syncing do not create configuration entities. Pluggable
// configuration entities can have dependencies on modules that are
// not yet enabled. This approach means that any code that expects
......
......@@ -352,13 +352,6 @@ public function getConfigEntitiesToChangeOnDependencyRemoval($type, array $names
return $return;
}
/**
* {@inheritdoc}
*/
public function supportsConfigurationEntities($collection) {
return $collection == StorageInterface::DEFAULT_COLLECTION;
}
/**
* {@inheritdoc}
*/
......
......@@ -161,17 +161,6 @@ public function findConfigEntityDependentsAsEntities($type, array $names);
*/
public function getConfigEntitiesToChangeOnDependencyRemoval($type, array $names, $dry_run = TRUE);
/**
* Determines if the provided collection supports configuration entities.
*
* @param string $collection
* The collection to check.
*
* @return bool
* TRUE if the collection support configuration entities, FALSE if not.
*/
public function supportsConfigurationEntities($collection);
/**
* Gets available collection information using the event system.
*
......
......@@ -212,7 +212,7 @@ public function createChangelist() {
$this->addChangelistUpdate($collection);
$this->addChangelistDelete($collection);
// Only collections that support configuration entities can have renames.
if ($this->configManager->supportsConfigurationEntities($collection)) {
if ($collection == StorageInterface::DEFAULT_COLLECTION) {
$this->addChangelistRename($collection);
}
}
......@@ -415,7 +415,7 @@ protected function getAndSortConfigData($collection) {
$source_data = $source_storage->readMultiple($source_names);
// If the collection only supports simple configuration do not use
// configuration dependencies.
if ($this->configManager->supportsConfigurationEntities($collection)) {
if ($collection == StorageInterface::DEFAULT_COLLECTION) {
$dependency_manager = new ConfigDependencyManager();
$this->targetNames[$collection] = $dependency_manager->setData($target_data)->sortAll();
$this->sourceNames[$collection] = $dependency_manager->setData($source_data)->sortAll();
......
......@@ -125,9 +125,6 @@ public function testCreateChangelistNoChange() {
$this->targetStorage->expects($this->once())
->method('getAllCollectionNames')
->will($this->returnValue(array()));
$this->configManager->expects($this->any())
->method('supportsConfigurationEntities')
->will($this->returnValue(TRUE));
$this->storageComparer->createChangelist();
$this->assertEmpty($this->storageComparer->getChangelist('create'));
......@@ -162,9 +159,6 @@ public function testCreateChangelistCreate() {
$this->targetStorage->expects($this->once())
->method('getAllCollectionNames')
->will($this->returnValue(array()));
$this->configManager->expects($this->any())
->method('supportsConfigurationEntities')
->will($this->returnValue(TRUE));
$this->storageComparer->createChangelist();
$expected = array(
......@@ -204,9 +198,6 @@ public function testCreateChangelistDelete() {
$this->targetStorage->expects($this->once())
->method('getAllCollectionNames')
->will($this->returnValue(array()));
$this->configManager->expects($this->any())
->method('supportsConfigurationEntities')
->will($this->returnValue(TRUE));
$this->storageComparer->createChangelist();
$expected = array(
......@@ -246,9 +237,6 @@ public function testCreateChangelistUpdate() {
$this->targetStorage->expects($this->once())
->method('getAllCollectionNames')
->will($this->returnValue(array()));
$this->configManager->expects($this->any())
->method('supportsConfigurationEntities')
->will($this->returnValue(TRUE));
$this->storageComparer->createChangelist();
$expected = array(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment