protected ConfigManager::callOnDependencyRemoval(ConfigEntityInterface $entity, array $dependent_entities, $type, array $names)
Calls an entity's onDependencyRemoval() method.
A helper method to call onDependencyRemoval() with the correct list of affected entities. This list should only contain dependencies on the entity. Configuration and content entity dependencies will be converted into entity objects.
Parameters
\Drupal\Core\Config\Entity\ConfigEntityInterface $entity: The entity to call onDependencyRemoval() on.
\Drupal\Core\Config\Entity\ConfigEntityInterface[] $dependent_entities: The list of dependent configuration entities.
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
bool TRUE if the entity has changed as a result of calling the onDependencyRemoval() method, FALSE if not.
File
- core/lib/Drupal/Core/Config/ConfigManager.php, line 399
Class
- ConfigManager
- The ConfigManager provides helper functions for the configuration system.
Namespace
Drupal\Core\Config
Code
protected function callOnDependencyRemoval(ConfigEntityInterface $entity, array $dependent_entities, $type, array $names) { $entity_dependencies = $entity->getDependencies(); if (empty($entity_dependencies)) { // No dependent entities nothing to do. return FALSE; } $affected_dependencies = array( 'config' => array(), 'content' => array(), 'module' => array(), 'theme' => array(), ); // Work out if any of the entity's dependencies are going to be affected. if (isset($entity_dependencies[$type])) { // Work out which dependencies the entity has in common with the provided // $type and $names. $affected_dependencies[$type] = array_intersect($entity_dependencies[$type], $names); // If the dependencies are entities we need to convert them into objects. if ($type == 'config' || $type == 'content') { $affected_dependencies[$type] = array_map(function($name) use ($type) { if ($type == 'config') { return $this->loadConfigEntityByName($name); } else { // Ignore the bundle. list($entity_type_id, , $uuid) = explode(':', $name); return $this->entityManager->loadEntityByConfigTarget($entity_type_id, $uuid); } }, $affected_dependencies[$type]); } } // Merge any other configuration entities into the list of affected // dependencies if necessary. if (isset($entity_dependencies['config'])) { foreach ($dependent_entities as $dependent_entity) { if (in_array($dependent_entity->getConfigDependencyName(), $entity_dependencies['config'])) { $affected_dependencies['config'][] = $dependent_entity; } } } // Key the entity arrays by config dependency name to make searching easy. foreach (['config', 'content'] as $dependency_type) { $affected_dependencies[$dependency_type] = array_combine( array_map(function($entity) { return $entity->getConfigDependencyName(); }, $affected_dependencies[$dependency_type]), $affected_dependencies[$dependency_type] ); } // Inform the entity. return $entity->onDependencyRemoval($affected_dependencies); }
Please login to continue.