protected function FeaturesAssignmentForwardDependency::dependencyOrder in Features 8.3
Same name and namespace in other branches
- 8.4 src/Plugin/FeaturesAssignment/FeaturesAssignmentForwardDependency.php \Drupal\features\Plugin\FeaturesAssignment\FeaturesAssignmentForwardDependency::dependencyOrder()
Get config items such that each item comes before anything it depends on.
Parameters
\Drupal\features\ConfigurationItem[] $config_collection: A collection of configuration items.
Return value
string[] The names of configuration items, in dependency order.
1 call to FeaturesAssignmentForwardDependency::dependencyOrder()
- FeaturesAssignmentForwardDependency::assignPackages in src/
Plugin/ FeaturesAssignment/ FeaturesAssignmentForwardDependency.php - Performs package assignment.
File
- src/
Plugin/ FeaturesAssignment/ FeaturesAssignmentForwardDependency.php, line 61
Class
- FeaturesAssignmentForwardDependency
- Class for assigning configuration to packages based on forward dependencies.
Namespace
Drupal\features\Plugin\FeaturesAssignmentCode
protected function dependencyOrder(array $config_collection) {
// Populate a graph.
$graph = [];
foreach ($config_collection as $config) {
$graph[$config
->getName()] = [];
foreach ($config
->getDependents() as $dependent) {
$graph[$config
->getName()]['edges'][$dependent] = 1;
}
}
$graph_object = new Graph($graph);
$graph = $graph_object
->searchAndSort();
// Order by inverse weight.
$weights = array_column($graph, 'weight');
array_multisort($weights, SORT_DESC, $graph);
return array_keys($graph);
}