FeaturesConfigDependencyManager.php in Features 8.4
File
src/FeaturesConfigDependencyManager.php
View source
<?php
namespace Drupal\features;
use Drupal\Core\Config\Entity\ConfigDependencyManager;
use Drupal\Core\Config\Entity\ConfigEntityDependency;
class FeaturesConfigDependencyManager extends ConfigDependencyManager {
protected $sorted_graph;
public function getDependentEntities($type, $name) {
$dependent_entities = [];
$entities_to_check = [];
if ($type == 'config') {
$entities_to_check[] = $name;
}
else {
if ($type == 'module' || $type == 'theme' || $type == 'content') {
$dependent_entities = array_filter($this->data, function (ConfigEntityDependency $entity) use ($type, $name) {
return $entity
->hasDependency($type, $name);
});
}
foreach ($dependent_entities as $entity) {
$entities_to_check[] = $entity
->getConfigDependencyName();
}
}
$dependencies = array_merge($this
->createGraphConfigEntityDependencies($entities_to_check), $dependent_entities);
if (!$this->sorted_graph) {
$this->sorted_graph = $this
->getGraph();
$sorts = $this
->prepareMultisort($this->sorted_graph, [
'weight',
'name',
]);
array_multisort($sorts['weight'], SORT_DESC, SORT_NUMERIC, $sorts['name'], SORT_ASC, SORT_NATURAL | SORT_FLAG_CASE, $this->sorted_graph);
}
return array_replace(array_intersect_key($this->sorted_graph, $dependencies), $dependencies);
}
public function setData(array $data) {
parent::setData($data);
$this->sorted_graph = NULL;
return $this;
}
}