function ConfigManager::findConfigEntityDependenciesAsEntities

Same name in other branches
  1. 10 core/lib/Drupal/Core/Config/ConfigManager.php \Drupal\Core\Config\ConfigManager::findConfigEntityDependenciesAsEntities()
  2. 11.x core/lib/Drupal/Core/Config/ConfigManager.php \Drupal\Core\Config\ConfigManager::findConfigEntityDependenciesAsEntities()

Overrides ConfigManagerInterface::findConfigEntityDependenciesAsEntities

2 calls to ConfigManager::findConfigEntityDependenciesAsEntities()
ConfigManager::findConfigEntityDependentsAsEntities in core/lib/Drupal/Core/Config/ConfigManager.php
Deprecated method to find config entity dependencies as entities.
ConfigManager::getConfigEntitiesToChangeOnDependencyRemoval in core/lib/Drupal/Core/Config/ConfigManager.php
Lists which config entities to update and delete on removal of a dependency.

File

core/lib/Drupal/Core/Config/ConfigManager.php, line 275

Class

ConfigManager
The ConfigManager provides helper functions for the configuration system.

Namespace

Drupal\Core\Config

Code

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) {
        // Group by entity type to efficient load entities using
        // \Drupal\Core\Entity\EntityStorageInterface::loadMultiple().
        $entity_type_id = $this->getEntityTypeIdByName($config_name);
        // It is possible that a non-configuration entity will be returned if a
        // simple configuration object has a UUID key. This would occur if the
        // dependents of the system module are calculated since system.site has
        // a UUID key.
        if ($entity_type_id) {
            $id = substr($config_name, strlen($definitions[$entity_type_id]->getConfigPrefix()) + 1);
            $entities[$entity_type_id][] = $id;
        }
    }
    $entities_to_return = [];
    foreach ($entities as $entity_type_id => $entities_to_load) {
        $storage = $this->entityTypeManager
            ->getStorage($entity_type_id);
        // Remove the keys since there are potential ID clashes from different
        // configuration entity types.
        $entities_to_return = array_merge($entities_to_return, array_values($storage->loadMultiple($entities_to_load)));
    }
    return $entities_to_return;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.