class ConfigDependencyManager (View source)

Provides a class to discover configuration entity dependencies.

Configuration entities can depend on modules, themes and other configuration entities. The dependency system is used during configuration installation, uninstallation, and synchronization to ensure that configuration entities are handled in the correct order. For example, node types are created before their fields, and both are created before the view display configuration.

The configuration dependency value is structured like this:

Properties

protected ConfigEntityDependency[] $data

The config entity data.

protected array $graph

The directed acyclic graph.

Methods

getDependentEntities(string $type, string $name)

Gets dependencies.

An
prepareMultisort(array $graph, array $keys)

Extracts data from the graph for use in array_multisort().

array
sortAll()

Sorts the dependencies in order of most dependent last.

createGraphConfigEntityDependencies(array $entities_to_check)

Creates a graph of config entity dependencies.

array
getGraph()

Gets the dependency graph of all the config entities.

$this
setData(array $data)

Sets data to calculate dependencies for.

$this
updateData($name, array $dependencies)

Updates one of the lightweight ConfigEntityDependency objects.

Details

ConfigEntityDependency[] getDependentEntities(string $type, string $name)

Gets dependencies.

Parameters

string $type

The type of dependency being checked. Either 'module', 'theme', 'config' or 'content'.

string $name

The specific name to check. If $type equals 'module' or 'theme' then it should be a module name or theme name. In the case of entity it should be the full configuration object name.

Return Value

ConfigEntityDependency[]

An array of config entity dependency objects that are dependent.

protected An prepareMultisort(array $graph, array $keys)

Extracts data from the graph for use in array_multisort().

Parameters

array $graph

The graph to extract data from.

array $keys

The keys whose values to extract.

Return Value

An

array keyed by the $keys passed in. The values are arrays keyed by the row from the graph and the value is the corresponding value for the key from the graph.

array sortAll()

Sorts the dependencies in order of most dependent last.

Return Value

array

The list of entities in order of most dependent last, otherwise alphabetical.

protected ConfigEntityDependency[] createGraphConfigEntityDependencies(array $entities_to_check)

Creates a graph of config entity dependencies.

Parameters

array $entities_to_check

The configuration entity full configuration names to determine the dependencies for.

Return Value

ConfigEntityDependency[]

A graph of config entity dependency objects that are dependent on the supplied entities to check.

protected array getGraph()

Gets the dependency graph of all the config entities.

Return Value

array

The dependency graph of all the config entities.

$this setData(array $data)

Sets data to calculate dependencies for.

The data is converted into lightweight ConfigEntityDependency objects.

Parameters

array $data

Configuration data keyed by configuration object name. Typically the output of \Drupal\Core\Config\StorageInterface::loadMultiple().

Return Value

$this

$this updateData($name, array $dependencies)

Updates one of the lightweight ConfigEntityDependency objects.

Parameters

$name

The configuration dependency name.

array $dependencies

The configuration dependencies. The array is structured like this: @code array( 'config' => array( // An array of configuration entity object names. ), 'content' => array( // An array of content entity configuration dependency names. The default // format is "ENTITY_TYPE_ID:BUNDLE:UUID". ), 'module' => array( // An array of module names. ), 'theme' => array( // An array of theme names. ), ); @endcode

Return Value

$this