function ConfigManager::findConfigEntityDependenciesAsEntities
Same name and namespace in other branches
- 9 core/lib/Drupal/Core/Config/ConfigManager.php \Drupal\Core\Config\ConfigManager::findConfigEntityDependenciesAsEntities()
- 10 core/lib/Drupal/Core/Config/ConfigManager.php \Drupal\Core\Config\ConfigManager::findConfigEntityDependenciesAsEntities()
Finds config entities that are dependent on extensions or entities.
Parameters
string $type: The type of dependency being checked. Either 'module', 'theme', 'config' or 'content'.
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 value
\Drupal\Core\Config\Entity\ConfigEntityInterface[] An array of dependencies as configuration entities.
Overrides ConfigManagerInterface::findConfigEntityDependenciesAsEntities
1 call to ConfigManager::findConfigEntityDependenciesAsEntities()
- ConfigManager::getConfigEntitiesToChangeOnDependencyRemoval in core/
lib/ Drupal/ Core/ Config/ ConfigManager.php - Lists config entities to update and delete on removal of a dependency.
File
-
core/
lib/ Drupal/ Core/ Config/ ConfigManager.php, line 284
Class
- ConfigManager
- The ConfigManager provides helper functions for the configuration system.
Namespace
Drupal\Core\ConfigCode
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][$config_name] = $id;
}
}
// Align the order of entities returned to the dependency order by first
// populating the keys in the same order.
$entities_to_return = array_fill_keys(array_keys($dependencies), NULL);
foreach ($entities as $entity_type_id => $entities_to_load) {
$storage = $this->entityTypeManager
->getStorage($entity_type_id);
$loaded_entities = $storage->loadMultiple($entities_to_load);
foreach ($loaded_entities as $loaded_entity) {
$entities_to_return[$loaded_entity->getConfigDependencyName()] = $loaded_entity;
}
}
// Return entities list with NULL entries removed.
return array_filter($entities_to_return);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.