Move all plugins and their dependencies to the front
parent
e3a23c0047
commit
da6efc9b02
|
@ -745,7 +745,8 @@ class Installer
|
||||||
private function movePluginsToFront(array $operations)
|
private function movePluginsToFront(array $operations)
|
||||||
{
|
{
|
||||||
$installerOps = array();
|
$installerOps = array();
|
||||||
foreach ($operations as $idx => $op) {
|
$installerRequires = array();
|
||||||
|
foreach (array_reverse($operations, true) as $idx => $op) {
|
||||||
if ($op instanceof InstallOperation) {
|
if ($op instanceof InstallOperation) {
|
||||||
$package = $op->getPackage();
|
$package = $op->getPackage();
|
||||||
} elseif ($op instanceof UpdateOperation) {
|
} elseif ($op instanceof UpdateOperation) {
|
||||||
|
@ -754,21 +755,17 @@ class Installer
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($package->getType() === 'composer-plugin' || $package->getType() === 'composer-installer') {
|
if ($package->getType() === 'composer-plugin'
|
||||||
// ignore requirements to platform or composer-plugin-api
|
|| $package->getType() === 'composer-installer'
|
||||||
$requires = array_keys($package->getRequires());
|
|| in_array($package->getName(), $installerRequires)
|
||||||
foreach ($requires as $index => $req) {
|
) {
|
||||||
if ($req === 'composer-plugin-api' || preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $req)) {
|
// capture the requirements for this package so those packages will be moved up as well
|
||||||
unset($requires[$index]);
|
$installerRequires = array_merge($installerRequires, array_keys($package->getRequires()));
|
||||||
}
|
// move the operation to the front
|
||||||
}
|
array_unshift($installerOps, $op);
|
||||||
// if there are no other requirements, move the plugin to the top of the op list
|
|
||||||
if (!count($requires)) {
|
|
||||||
$installerOps[] = $op;
|
|
||||||
unset($operations[$idx]);
|
unset($operations[$idx]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return array_merge($installerOps, $operations);
|
return array_merge($installerOps, $operations);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue