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
Loading
Loading
Loading
Loading
+21 −5
Changes for core/lib/Drupal/Core/Config/ConfigManager.php: 21 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -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.
+43 −1
Changes for core/lib/Drupal/Core/Config/ConfigManagerInterface.php: 43 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -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);

  /**
+1 −1
Changes for core/lib/Drupal/Core/EventSubscriber/ExcludedModulesEventSubscriber.php: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -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();
    }

+1 −1
Changes for core/modules/block_content/tests/src/Functional/BlockContentCreationTest.php: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -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.");
  }
+1 −1
Changes for core/modules/field/tests/src/Functional/Views/FieldUITest.php: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -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.');
  }

Loading