function InstallationManager::execute
Executes solver operation.
Parameters
InstalledRepositoryInterface $repo repository in which to add/remove/update packages:
OperationInterface[] $operations operations to execute:
bool $devMode whether the install is being run in dev mode:
bool $runScripts whether to dispatch script events:
bool $downloadOnly whether to only download packages:
File
-
vendor/
composer/ composer/ src/ Composer/ Installer/ InstallationManager.php, line 181
Class
- InstallationManager
- Package operation manager.
Namespace
Composer\InstallerCode
public function execute(InstalledRepositoryInterface $repo, array $operations, bool $devMode = true, bool $runScripts = true, bool $downloadOnly = false) : void {
/** @var array<callable(): ?PromiseInterface<void|null>> $cleanupPromises */
$cleanupPromises = [];
$signalHandler = SignalHandler::create([
SignalHandler::SIGINT,
SignalHandler::SIGTERM,
SignalHandler::SIGHUP,
], function (string $signal, SignalHandler $handler) use (&$cleanupPromises) {
$this->io
->writeError('Received ' . $signal . ', aborting', true, IOInterface::DEBUG);
$this->runCleanup($cleanupPromises);
$handler->exitWithLastSignal();
});
try {
// execute operations in batches to make sure download-modifying-plugins are installed
// before the other packages get downloaded
$batches = [];
$batch = [];
foreach ($operations as $index => $operation) {
if ($operation instanceof UpdateOperation || $operation instanceof InstallOperation) {
$package = $operation instanceof UpdateOperation ? $operation->getTargetPackage() : $operation->getPackage();
if ($package->getType() === 'composer-plugin') {
$extra = $package->getExtra();
if (isset($extra['plugin-modifies-downloads']) && $extra['plugin-modifies-downloads'] === true) {
if (count($batch) > 0) {
$batches[] = $batch;
}
$batches[] = [
$index => $operation,
];
$batch = [];
continue;
}
}
}
$batch[$index] = $operation;
}
if (count($batch) > 0) {
$batches[] = $batch;
}
foreach ($batches as $batchToExecute) {
$this->downloadAndExecuteBatch($repo, $batchToExecute, $cleanupPromises, $devMode, $runScripts, $downloadOnly, $operations);
}
} catch (\Exception $e) {
$this->runCleanup($cleanupPromises);
throw $e;
} finally {
$signalHandler->unregister();
}
if ($downloadOnly) {
return;
}
// do a last write so that we write the repository even if nothing changed
// as that can trigger an update of some files like InstalledVersions.php if
// running a new composer version
$repo->write($devMode, $this);
}