Skip to content
Snippets Groups Projects
Unverified Commit 4988dcf9 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2926729 by bircher, daffie, vsujeetkumar: Rename...

Issue #2926729 by bircher, daffie, vsujeetkumar: Rename ConfigManager::findConfigEntityDependentsAsEntities() to be ::findConfigEntityDependenciesAsEntities
parent 52f5af29
No related branches found
No related tags found
No related merge requests found
......@@ -258,7 +258,7 @@ public function getConfigDependencyManager() {
/**
* {@inheritdoc}
*/
public function findConfigEntityDependents($type, array $names, ConfigDependencyManager $dependency_manager = NULL) {
public function findConfigEntityDependencies($type, array $names, ConfigDependencyManager $dependency_manager = NULL) {
if (!$dependency_manager) {
$dependency_manager = $this->getConfigDependencyManager();
}
......@@ -272,8 +272,8 @@ public function findConfigEntityDependents($type, array $names, ConfigDependency
/**
* {@inheritdoc}
*/
public function findConfigEntityDependentsAsEntities($type, array $names, ConfigDependencyManager $dependency_manager = NULL) {
$dependencies = $this->findConfigEntityDependents($type, $names, $dependency_manager);
public function findConfigEntityDependenciesAsEntities($type, array $names, ConfigDependencyManager $dependency_manager = NULL) {
$dependencies = $this->findConfigEntityDependencies($type, $names, $dependency_manager);
$entities = [];
$definitions = $this->entityTypeManager->getDefinitions();
foreach ($dependencies as $config_name => $dependency) {
......@@ -299,6 +299,22 @@ public function findConfigEntityDependentsAsEntities($type, array $names, Config
return $entities_to_return;
}
/**
* {@inheritdoc}
*/
public function findConfigEntityDependents($type, array $names, ConfigDependencyManager $dependency_manager = NULL) {
@trigger_error('ConfigManagerInterface::findConfigEntityDependents() is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Instead you should use ConfigManagerInterface::findConfigEntityDependencies(). See https://www.drupal.org/node/3225357', E_USER_DEPRECATED);
return $this->findConfigEntityDependencies($type, $names, $dependency_manager);
}
/**
* {@inheritdoc}
*/
public function findConfigEntityDependentsAsEntities($type, array $names, ConfigDependencyManager $dependency_manager = NULL) {
@trigger_error('ConfigManagerInterface::findConfigEntityDependentsAsEntities() is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Instead you should use ConfigManagerInterface::findConfigEntityDependenciesAsEntities(). See https://www.drupal.org/node/3225357', E_USER_DEPRECATED);
return $this->findConfigEntityDependenciesAsEntities($type, $names, $dependency_manager);
}
/**
* {@inheritdoc}
*/
......@@ -310,7 +326,7 @@ public function getConfigEntitiesToChangeOnDependencyRemoval($type, array $names
// calling the onDependencyRemoval() method.
// The list of original dependents on $names. This list never changes.
$original_dependents = $this->findConfigEntityDependentsAsEntities($type, $names, $dependency_manager);
$original_dependents = $this->findConfigEntityDependenciesAsEntities($type, $names, $dependency_manager);
// The current list of dependents on $names. This list is recalculated when
// calling an entity's onDependencyRemoval() method results in the entity
......@@ -348,7 +364,7 @@ public function getConfigEntitiesToChangeOnDependencyRemoval($type, array $names
// Based on the updated data rebuild the list of current dependents.
// This will remove entities that are no longer dependent after the
// recalculation.
$current_dependents = $this->findConfigEntityDependentsAsEntities($type, $names, $dependency_manager);
$current_dependents = $this->findConfigEntityDependenciesAsEntities($type, $names, $dependency_manager);
// Rebuild the list of entities that we need to process using the new
// list of current dependents and removing any entities that we've
// already processed.
......
......@@ -114,7 +114,7 @@ public function getConfigDependencyManager();
* @return \Drupal\Core\Config\Entity\ConfigEntityDependency[]
* An array of configuration entity dependency objects.
*/
public function findConfigEntityDependents($type, array $names);
public function findConfigEntityDependencies($type, array $names);
/**
* Finds config entities that are dependent on extensions or entities.
......@@ -130,6 +130,48 @@ public function findConfigEntityDependents($type, array $names);
* @return \Drupal\Core\Config\Entity\ConfigEntityInterface[]
* An array of dependencies as configuration entities.
*/
public function findConfigEntityDependenciesAsEntities($type, array $names);
/**
* Deprecated method to find config entity dependencies.
*
* @param string $type
* The type of dependency being checked. Either 'module', 'theme', 'config'
* or 'content'.
* @param array $names
* The specific names to check. If $type equals 'module' or 'theme' then it
* should be a list of module names or theme names. In the case of 'config'
* or 'content' it should be a list of configuration dependency names.
*
* @return \Drupal\Core\Config\Entity\ConfigEntityDependency[]
* An array of configuration entity dependency objects.
*
* @deprecated in drupal:9.3.0 and is removed from drupal:10.0.0.
* Instead you should use
* ConfigManagerInterface::findConfigEntityDependencies().
* @see https://www.drupal.org/node/3225357
*/
public function findConfigEntityDependents($type, array $names);
/**
* Deprecated method to find config entity dependencies as entities.
*
* @param string $type
* The type of dependency being checked. Either 'module', 'theme', 'config'
* or 'content'.
* @param array $names
* The specific names to check. If $type equals 'module' or 'theme' then it
* should be a list of module names or theme names. In the case of 'config'
* or 'content' it should be a list of configuration dependency names.
*
* @return \Drupal\Core\Config\Entity\ConfigEntityInterface[]
* An array of dependencies as configuration entities.
*
* @deprecated in drupal:9.3.0 and is removed from drupal:10.0.0.
* Instead you should use
* ConfigManagerInterface::findConfigEntityDependenciesAsEntities().
* @see https://www.drupal.org/node/3225357
*/
public function findConfigEntityDependentsAsEntities($type, array $names);
/**
......
......@@ -169,7 +169,7 @@ private function getDependentConfigNames() {
}
// Find all configuration that depends on the configuration found above.
foreach ($this->manager->findConfigEntityDependents('config', array_unique($config)) as $dependent) {
foreach ($this->manager->findConfigEntityDependencies('config', array_unique($config)) as $dependent) {
$config[] = $dependent->getConfigDependencyName();
}
......
......@@ -305,7 +305,7 @@ public function testConfigDependencies() {
$this->drupalGet($url);
$this->submitForm($instance, 'Save block');
$dependencies = \Drupal::service('config.manager')->findConfigEntityDependentsAsEntities('content', [$block->getConfigDependencyName()]);
$dependencies = \Drupal::service('config.manager')->findConfigEntityDependenciesAsEntities('content', [$block->getConfigDependencyName()]);
$block_placement = reset($dependencies);
$this->assertEquals($block_placement_id, $block_placement->id(), "The block placement config entity has a dependency on the block content entity.");
}
......
......@@ -98,7 +98,7 @@ public function testHandlerUI() {
$this->assertEquals([], $view->field['field_name_0']->options['settings']);
// Ensure that the view depends on the field storage.
$dependencies = \Drupal::service('config.manager')->findConfigEntityDependents('config', [$this->fieldStorages[0]->getConfigDependencyName()]);
$dependencies = \Drupal::service('config.manager')->findConfigEntityDependencies('config', [$this->fieldStorages[0]->getConfigDependencyName()]);
$this->assertTrue(isset($dependencies['views.view.test_view_fieldapi']), 'The view is dependent on the field storage.');
}
......
......@@ -93,7 +93,7 @@ public function assertModuleConfig($module) {
}
$this->assertNotEmpty($all_names);
$module_config_dependencies = \Drupal::service('config.manager')->findConfigEntityDependents('module', [$module]);
$module_config_dependencies = \Drupal::service('config.manager')->findConfigEntityDependencies('module', [$module]);
// Look up each default configuration object name in the active
// configuration, and if it exists, remove it from the stack.
$names = $module_file_storage->listAll();
......
......@@ -95,7 +95,7 @@ public function testUninstallPage() {
// Uninstall node testing that the configuration that will be deleted is
// listed.
$node_dependencies = \Drupal::service('config.manager')->findConfigEntityDependentsAsEntities('module', ['node']);
$node_dependencies = \Drupal::service('config.manager')->findConfigEntityDependenciesAsEntities('module', ['node']);
$edit = [];
$edit['uninstall[node]'] = TRUE;
$this->drupalGet('admin/modules/uninstall');
......
......@@ -29,12 +29,12 @@ class ConfigDependencyTest extends EntityKernelTestBase {
public function testNonEntity() {
$this->installConfig(['system']);
$config_manager = \Drupal::service('config.manager');
$dependents = $config_manager->findConfigEntityDependents('module', ['system']);
$dependents = $config_manager->findConfigEntityDependencies('module', ['system']);
$this->assertTrue(isset($dependents['system.site']), 'Simple configuration system.site has a UUID key even though it is not a configuration entity and therefore is found when looking for dependencies of the System module.');
// Ensure that calling
// \Drupal\Core\Config\ConfigManager::findConfigEntityDependentsAsEntities()
// \Drupal\Core\Config\ConfigManager::findConfigEntityDependenciesAsEntities()
// does not try to load system.site as an entity.
$config_manager->findConfigEntityDependentsAsEntities('module', ['system']);
$config_manager->findConfigEntityDependenciesAsEntities('module', ['system']);
}
/**
......@@ -57,11 +57,11 @@ public function testDependencyManagement() {
);
$entity1->save();
$dependents = $config_manager->findConfigEntityDependents('module', ['node']);
$dependents = $config_manager->findConfigEntityDependencies('module', ['node']);
$this->assertTrue(isset($dependents['config_test.dynamic.entity1']), 'config_test.dynamic.entity1 has a dependency on the Node module.');
$dependents = $config_manager->findConfigEntityDependents('module', ['config_test']);
$dependents = $config_manager->findConfigEntityDependencies('module', ['config_test']);
$this->assertTrue(isset($dependents['config_test.dynamic.entity1']), 'config_test.dynamic.entity1 has a dependency on the config_test module.');
$dependents = $config_manager->findConfigEntityDependents('module', ['views']);
$dependents = $config_manager->findConfigEntityDependencies('module', ['views']);
$this->assertFalse(isset($dependents['config_test.dynamic.entity1']), 'config_test.dynamic.entity1 does not have a dependency on the Views module.');
// Ensure that the provider of the config entity is not actually written to
// the dependencies array.
......@@ -78,14 +78,14 @@ public function testDependencyManagement() {
$entity4->save();
// Test getting $entity1's dependencies as configuration dependency objects.
$dependents = $config_manager->findConfigEntityDependents('config', [$entity1->getConfigDependencyName()]);
$dependents = $config_manager->findConfigEntityDependencies('config', [$entity1->getConfigDependencyName()]);
$this->assertFalse(isset($dependents['config_test.dynamic.entity1']), 'config_test.dynamic.entity1 does not have a dependency on itself.');
$this->assertTrue(isset($dependents['config_test.dynamic.entity2']), 'config_test.dynamic.entity2 has a dependency on config_test.dynamic.entity1.');
$this->assertTrue(isset($dependents['config_test.dynamic.entity3']), 'config_test.dynamic.entity3 has a dependency on config_test.dynamic.entity1.');
$this->assertTrue(isset($dependents['config_test.dynamic.entity4']), 'config_test.dynamic.entity4 has a dependency on config_test.dynamic.entity1.');
// Test getting $entity2's dependencies as entities.
$dependents = $config_manager->findConfigEntityDependentsAsEntities('config', [$entity2->getConfigDependencyName()]);
$dependents = $config_manager->findConfigEntityDependenciesAsEntities('config', [$entity2->getConfigDependencyName()]);
$dependent_ids = $this->getDependentIds($dependents);
$this->assertNotContains('config_test:entity1', $dependent_ids, 'config_test.dynamic.entity1 does not have a dependency on config_test.dynamic.entity1.');
$this->assertNotContains('config_test:entity2', $dependent_ids, 'config_test.dynamic.entity2 does not have a dependency on itself.');
......@@ -94,7 +94,7 @@ public function testDependencyManagement() {
// Test getting node module's dependencies as configuration dependency
// objects.
$dependents = $config_manager->findConfigEntityDependents('module', ['node']);
$dependents = $config_manager->findConfigEntityDependencies('module', ['node']);
$this->assertTrue(isset($dependents['config_test.dynamic.entity1']), 'config_test.dynamic.entity1 has a dependency on the Node module.');
$this->assertTrue(isset($dependents['config_test.dynamic.entity2']), 'config_test.dynamic.entity2 has a dependency on the Node module.');
$this->assertTrue(isset($dependents['config_test.dynamic.entity3']), 'config_test.dynamic.entity3 has a dependency on the Node module.');
......@@ -105,7 +105,7 @@ public function testDependencyManagement() {
// no longer depend on node module.
$entity1->setEnforcedDependencies([])->save();
$entity3->setEnforcedDependencies(['module' => ['node'], 'config' => [$entity2->getConfigDependencyName()]])->save();
$dependents = $config_manager->findConfigEntityDependents('module', ['node']);
$dependents = $config_manager->findConfigEntityDependencies('module', ['node']);
$this->assertFalse(isset($dependents['config_test.dynamic.entity1']), 'config_test.dynamic.entity1 does not have a dependency on the Node module.');
$this->assertFalse(isset($dependents['config_test.dynamic.entity2']), 'config_test.dynamic.entity2 does not have a dependency on the Node module.');
$this->assertTrue(isset($dependents['config_test.dynamic.entity3']), 'config_test.dynamic.entity3 has a dependency on the Node module.');
......@@ -118,7 +118,7 @@ public function testDependencyManagement() {
]);
$entity_test->save();
$entity2->setEnforcedDependencies(['config' => [$entity1->getConfigDependencyName()], 'content' => [$entity_test->getConfigDependencyName()]])->save();
$dependents = $config_manager->findConfigEntityDependents('content', [$entity_test->getConfigDependencyName()]);
$dependents = $config_manager->findConfigEntityDependencies('content', [$entity_test->getConfigDependencyName()]);
$this->assertFalse(isset($dependents['config_test.dynamic.entity1']), 'config_test.dynamic.entity1 does not have a dependency on the content entity.');
$this->assertTrue(isset($dependents['config_test.dynamic.entity2']), 'config_test.dynamic.entity2 has a dependency on the content entity.');
$this->assertTrue(isset($dependents['config_test.dynamic.entity3']), 'config_test.dynamic.entity3 has a dependency on the content entity (via entity2).');
......@@ -130,7 +130,7 @@ public function testDependencyManagement() {
$alt_storage->create(['id' => 'entity1', 'dependencies' => ['enforced' => ['config' => [$entity1->getConfigDependencyName()]]]])->save();
$alt_storage->create(['id' => 'entity2', 'dependencies' => ['enforced' => ['module' => ['views']]]])->save();
$dependents = $config_manager->findConfigEntityDependentsAsEntities('config', [$entity1->getConfigDependencyName()]);
$dependents = $config_manager->findConfigEntityDependenciesAsEntities('config', [$entity1->getConfigDependencyName()]);
$dependent_ids = $this->getDependentIds($dependents);
$this->assertNotContains('config_test:entity1', $dependent_ids, 'config_test.dynamic.entity1 does not have a dependency on itself.');
$this->assertContains('config_test:entity2', $dependent_ids, 'config_test.dynamic.entity2 has a dependency on config_test.dynamic.entity1.');
......@@ -139,7 +139,7 @@ public function testDependencyManagement() {
$this->assertContains('config_query_test:entity1', $dependent_ids, 'config_query_test.dynamic.entity1 has a dependency on config_test.dynamic.entity1.');
$this->assertNotContains('config_query_test:entity2', $dependent_ids, 'config_query_test.dynamic.entity2 does not have a dependency on config_test.dynamic.entity1.');
$dependents = $config_manager->findConfigEntityDependentsAsEntities('module', ['node', 'views']);
$dependents = $config_manager->findConfigEntityDependenciesAsEntities('module', ['node', 'views']);
$dependent_ids = $this->getDependentIds($dependents);
$this->assertNotContains('config_test:entity1', $dependent_ids, 'config_test.dynamic.entity1 does not have a dependency on Views or Node.');
$this->assertNotContains('config_test:entity2', $dependent_ids, 'config_test.dynamic.entity2 does not have a dependency on Views or Node.');
......@@ -148,7 +148,7 @@ public function testDependencyManagement() {
$this->assertNotContains('config_query_test:entity1', $dependent_ids, 'config_test.query.entity1 does not have a dependency on Views or Node.');
$this->assertContains('config_query_test:entity2', $dependent_ids, 'config_test.query.entity2 has a dependency on Views or Node.');
$dependents = $config_manager->findConfigEntityDependentsAsEntities('module', ['config_test']);
$dependents = $config_manager->findConfigEntityDependenciesAsEntities('module', ['config_test']);
$dependent_ids = $this->getDependentIds($dependents);
$this->assertContains('config_test:entity1', $dependent_ids, 'config_test.dynamic.entity1 has a dependency on config_test module.');
$this->assertContains('config_test:entity2', $dependent_ids, 'config_test.dynamic.entity2 has a dependency on config_test module.');
......@@ -638,6 +638,26 @@ public function testContentEntityDelete() {
$this->assertTrue(empty($config_entities['unchanged']), 'No dependencies of the content entity will be unchanged.');
}
/**
* @group legacy
*/
public function testFindConfigEntityDependentsDeprecation() {
$this->expectDeprecation('ConfigManagerInterface::findConfigEntityDependents() is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Instead you should use ConfigManagerInterface::findConfigEntityDependencies(). See https://www.drupal.org/node/3225357');
/** @var \Drupal\Core\Config\ConfigManagerInterface $config_manager */
$config_manager = \Drupal::service('config.manager');
$config_manager->findConfigEntityDependents('module', ['system']);
}
/**
* @group legacy
*/
public function testFindConfigEntityDependentsAsEntitiesDeprecation() {
$this->expectDeprecation('ConfigManagerInterface::findConfigEntityDependentsAsEntities() is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Instead you should use ConfigManagerInterface::findConfigEntityDependenciesAsEntities(). See https://www.drupal.org/node/3225357');
/** @var \Drupal\Core\Config\ConfigManagerInterface $config_manager */
$config_manager = \Drupal::service('config.manager');
$config_manager->findConfigEntityDependentsAsEntities('module', ['system']);
}
/**
* Gets a list of identifiers from an array of configuration entities.
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment