function ConfigDependencyManager::getGraph

Same name in other branches
  1. 9 core/lib/Drupal/Core/Config/Entity/ConfigDependencyManager.php \Drupal\Core\Config\Entity\ConfigDependencyManager::getGraph()
  2. 10 core/lib/Drupal/Core/Config/Entity/ConfigDependencyManager.php \Drupal\Core\Config\Entity\ConfigDependencyManager::getGraph()
  3. 11.x core/lib/Drupal/Core/Config/Entity/ConfigDependencyManager.php \Drupal\Core\Config\Entity\ConfigDependencyManager::getGraph()

Gets the dependency graph of all the config entities.

Return value

array The dependency graph of all the config entities.

3 calls to ConfigDependencyManager::getGraph()
ConfigDependencyManager::createGraphConfigEntityDependencies in core/lib/Drupal/Core/Config/Entity/ConfigDependencyManager.php
Creates a graph of config entity dependencies.
ConfigDependencyManager::getDependentEntities in core/lib/Drupal/Core/Config/Entity/ConfigDependencyManager.php
Gets dependencies.
ConfigDependencyManager::sortAll in core/lib/Drupal/Core/Config/Entity/ConfigDependencyManager.php
Sorts the dependencies in order of most dependent last.

File

core/lib/Drupal/Core/Config/Entity/ConfigDependencyManager.php, line 305

Class

ConfigDependencyManager
Provides a class to discover configuration entity dependencies.

Namespace

Drupal\Core\Config\Entity

Code

protected function getGraph() {
    if (!isset($this->graph)) {
        $graph = [];
        foreach ($this->data as $entity) {
            $graph_key = $entity->getConfigDependencyName();
            if (!isset($graph[$graph_key])) {
                $graph[$graph_key] = [
                    'edges' => [],
                    'name' => $graph_key,
                ];
            }
            // Include all dependencies in the graph so that topographical sorting
            // works.
            foreach (array_merge($entity->getDependencies('config'), $entity->getDependencies('module'), $entity->getDependencies('theme')) as $dependency) {
                $graph[$dependency]['edges'][$graph_key] = TRUE;
                $graph[$dependency]['name'] = $dependency;
            }
        }
        // Ensure that order of the graph is consistent.
        krsort($graph);
        $graph_object = new Graph($graph);
        $this->graph = $graph_object->searchAndSort();
    }
    return $this->graph;
}

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