protected function adjustDependency($targets, $bundles)
{
$this->stdout("Creating new bundle configuration...\n");
$map = [];
foreach ($targets as $name => $target) {
foreach ($target->depends as $bundle) {
$map[$bundle] = $name;
}
}
foreach ($targets as $name => $target) {
$depends = [];
foreach ($target->depends as $bn) {
foreach ($bundles[$bn]->depends as $bundle) {
$depends[$map[$bundle]] = true;
}
}
unset($depends[$name]);
$target->depends = array_keys($depends);
}
// detect possible circular dependencies
foreach ($targets as $name => $target) {
$registered = [];
$this->registerBundle($targets, $name, $registered);
}
foreach ($map as $bundle => $target) {
$sourceBundle = $bundles[$bundle];
$depends = $sourceBundle->depends;
if (!$this->isBundleExternal($sourceBundle)) {
$depends[] = $target;
}
$targetBundle = clone $sourceBundle;
$targetBundle->depends = $depends;
$targets[$bundle] = $targetBundle;
}
return $targets;
}