当前位置: 首页>>代码示例>>PHP>>正文


PHP InstallationManager::execute方法代码示例

本文整理汇总了PHP中Composer\Installer\InstallationManager::execute方法的典型用法代码示例。如果您正苦于以下问题:PHP InstallationManager::execute方法的具体用法?PHP InstallationManager::execute怎么用?PHP InstallationManager::execute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Composer\Installer\InstallationManager的用法示例。


在下文中一共展示了InstallationManager::execute方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: doInstall


//.........这里部分代码省略.........
         $constraint->setPrettyString($package->getPrettyVersion());
         $request->install($package->getName(), $constraint);
     }
     // if the updateWhitelist is enabled, packages not in it are also fixed
     // to the version specified in the lock, or their currently installed version
     if ($this->update && $this->updateWhitelist) {
         if ($this->locker->isLocked($devMode)) {
             $currentPackages = $this->locker->getLockedRepository($devMode)->getPackages();
         } else {
             $currentPackages = $installedRepo->getPackages();
         }
         // collect links from composer as well as installed packages
         $candidates = array();
         foreach ($links as $link) {
             $candidates[$link->getTarget()] = true;
         }
         foreach ($localRepo->getPackages() as $package) {
             $candidates[$package->getName()] = true;
         }
         // fix them to the version in lock (or currently installed) if they are not updateable
         foreach ($candidates as $candidate => $dummy) {
             foreach ($currentPackages as $curPackage) {
                 if ($curPackage->getName() === $candidate) {
                     if ($this->isUpdateable($curPackage)) {
                         break;
                     }
                     $constraint = new VersionConstraint('=', $curPackage->getVersion());
                     $request->install($curPackage->getName(), $constraint);
                 }
             }
         }
     }
     // force dev packages to have the latest links if we update or install from a (potentially new) lock
     $this->processDevPackages($localRepo, $pool, $policy, $repositories, $lockedRepository, $installFromLock, 'force-links');
     // solve dependencies
     $solver = new Solver($policy, $pool, $installedRepo);
     try {
         $operations = $solver->solve($request);
     } catch (SolverProblemsException $e) {
         $this->io->write('<error>Your requirements could not be resolved to an installable set of packages.</error>');
         $this->io->write($e->getMessage());
         return false;
     }
     if ($devMode) {
         // remove bogus operations that the solver creates for stuff that was force-updated in the non-dev pass
         // TODO this should not be necessary ideally, but it seems to work around the problem quite well
         foreach ($operations as $index => $op) {
             if ('update' === $op->getJobType() && $op->getInitialPackage()->getUniqueName() === $op->getTargetPackage()->getUniqueName() && $op->getInitialPackage()->getSourceReference() === $op->getTargetPackage()->getSourceReference() && $op->getInitialPackage()->getDistReference() === $op->getTargetPackage()->getDistReference()) {
                 unset($operations[$index]);
             }
         }
     }
     // force dev packages to be updated if we update or install from a (potentially new) lock
     $operations = $this->processDevPackages($localRepo, $pool, $policy, $repositories, $lockedRepository, $installFromLock, 'force-updates', $operations);
     // execute operations
     if (!$operations) {
         $this->io->write('Nothing to install or update');
     }
     foreach ($operations as $operation) {
         // collect suggestions
         if ('install' === $operation->getJobType()) {
             foreach ($operation->getPackage()->getSuggests() as $target => $reason) {
                 $this->suggestedPackages[] = array('source' => $operation->getPackage()->getPrettyName(), 'target' => $target, 'reason' => $reason);
             }
         }
         $event = 'Composer\\Script\\ScriptEvents::PRE_PACKAGE_' . strtoupper($operation->getJobType());
         if (defined($event) && $this->runScripts) {
             $this->eventDispatcher->dispatchPackageEvent(constant($event), $this->devMode, $operation);
         }
         // not installing from lock, force dev packages' references if they're in root package refs
         if (!$installFromLock) {
             $package = null;
             if ('update' === $operation->getJobType()) {
                 $package = $operation->getTargetPackage();
             } elseif ('install' === $operation->getJobType()) {
                 $package = $operation->getPackage();
             }
             if ($package && $package->isDev()) {
                 $references = $this->package->getReferences();
                 if (isset($references[$package->getName()])) {
                     $package->setSourceReference($references[$package->getName()]);
                     $package->setDistReference($references[$package->getName()]);
                 }
             }
         }
         // output alias operations in verbose mode, or all ops in dry run
         if ($this->dryRun || $this->verbose && false !== strpos($operation->getJobType(), 'Alias')) {
             $this->io->write('  - ' . $operation);
         }
         $this->installationManager->execute($localRepo, $operation);
         $event = 'Composer\\Script\\ScriptEvents::POST_PACKAGE_' . strtoupper($operation->getJobType());
         if (defined($event) && $this->runScripts) {
             $this->eventDispatcher->dispatchPackageEvent(constant($event), $this->devMode, $operation);
         }
         if (!$this->dryRun) {
             $localRepo->write();
         }
     }
     return true;
 }
开发者ID:rkallensee,项目名称:composer,代码行数:101,代码来源:Installer.php

示例2: doInstall


//.........这里部分代码省略.........
         $this->io->writeError('<info>Installing dependencies' . ($withDevReqs ? ' (including require-dev)' : '') . '</info>');
         if ($withDevReqs) {
             $links = array_merge($this->package->getRequires(), $this->package->getDevRequires());
         } else {
             $links = $this->package->getRequires();
         }
         foreach ($links as $link) {
             $request->install($link->getTarget(), $link->getConstraint());
         }
     }
     // force dev packages to have the latest links if we update or install from a (potentially new) lock
     $this->processDevPackages($localRepo, $pool, $policy, $repositories, $lockedRepository, $installFromLock, 'force-links');
     // solve dependencies
     $this->eventDispatcher->dispatchInstallerEvent(InstallerEvents::PRE_DEPENDENCIES_SOLVING, $this->devMode, $policy, $pool, $installedRepo, $request);
     $solver = new Solver($policy, $pool, $installedRepo);
     try {
         $operations = $solver->solve($request, $this->ignorePlatformReqs);
         $this->eventDispatcher->dispatchInstallerEvent(InstallerEvents::POST_DEPENDENCIES_SOLVING, $this->devMode, $policy, $pool, $installedRepo, $request, $operations);
     } catch (SolverProblemsException $e) {
         $this->io->writeError('<error>Your requirements could not be resolved to an installable set of packages.</error>');
         $this->io->writeError($e->getMessage());
         return max(1, $e->getCode());
     }
     // force dev packages to be updated if we update or install from a (potentially new) lock
     $operations = $this->processDevPackages($localRepo, $pool, $policy, $repositories, $lockedRepository, $installFromLock, 'force-updates', $operations);
     // execute operations
     if (!$operations) {
         $this->io->writeError('Nothing to install or update');
     }
     $operations = $this->movePluginsToFront($operations);
     $operations = $this->moveUninstallsToFront($operations);
     foreach ($operations as $operation) {
         // collect suggestions
         if ('install' === $operation->getJobType()) {
             foreach ($operation->getPackage()->getSuggests() as $target => $reason) {
                 $this->suggestedPackages[] = array('source' => $operation->getPackage()->getPrettyName(), 'target' => $target, 'reason' => $reason);
             }
         }
         // not installing from lock, force dev packages' references if they're in root package refs
         if (!$installFromLock) {
             $package = null;
             if ('update' === $operation->getJobType()) {
                 $package = $operation->getTargetPackage();
             } elseif ('install' === $operation->getJobType()) {
                 $package = $operation->getPackage();
             }
             if ($package && $package->isDev()) {
                 $references = $this->package->getReferences();
                 if (isset($references[$package->getName()])) {
                     $package->setSourceReference($references[$package->getName()]);
                     $package->setDistReference($references[$package->getName()]);
                 }
             }
             if ('update' === $operation->getJobType() && $operation->getTargetPackage()->isDev() && $operation->getTargetPackage()->getVersion() === $operation->getInitialPackage()->getVersion() && $operation->getTargetPackage()->getSourceReference() === $operation->getInitialPackage()->getSourceReference()) {
                 if ($this->io->isDebug()) {
                     $this->io->writeError('  - Skipping update of ' . $operation->getTargetPackage()->getPrettyName() . ' to the same reference-locked version');
                     $this->io->writeError('');
                 }
                 continue;
             }
         }
         $event = 'Composer\\Installer\\PackageEvents::PRE_PACKAGE_' . strtoupper($operation->getJobType());
         if (defined($event) && $this->runScripts) {
             $this->eventDispatcher->dispatchPackageEvent(constant($event), $this->devMode, $policy, $pool, $installedRepo, $request, $operations, $operation);
         }
         // output non-alias ops in dry run, output alias ops in debug verbosity
         if ($this->dryRun && false === strpos($operation->getJobType(), 'Alias')) {
             $this->io->writeError('  - ' . $operation);
             $this->io->writeError('');
         } elseif ($this->io->isDebug() && false !== strpos($operation->getJobType(), 'Alias')) {
             $this->io->writeError('  - ' . $operation);
             $this->io->writeError('');
         }
         $this->installationManager->execute($localRepo, $operation);
         // output reasons why the operation was ran, only for install/update operations
         if ($this->verbose && $this->io->isVeryVerbose() && in_array($operation->getJobType(), array('install', 'update'))) {
             $reason = $operation->getReason();
             if ($reason instanceof Rule) {
                 switch ($reason->getReason()) {
                     case Rule::RULE_JOB_INSTALL:
                         $this->io->writeError('    REASON: Required by root: ' . $reason->getPrettyString($pool));
                         $this->io->writeError('');
                         break;
                     case Rule::RULE_PACKAGE_REQUIRES:
                         $this->io->writeError('    REASON: ' . $reason->getPrettyString($pool));
                         $this->io->writeError('');
                         break;
                 }
             }
         }
         $event = 'Composer\\Installer\\PackageEvents::POST_PACKAGE_' . strtoupper($operation->getJobType());
         if (defined($event) && $this->runScripts) {
             $this->eventDispatcher->dispatchPackageEvent(constant($event), $this->devMode, $policy, $pool, $installedRepo, $request, $operations, $operation);
         }
         if (!$this->dryRun) {
             $localRepo->write();
         }
     }
     return 0;
 }
开发者ID:Flesh192,项目名称:magento,代码行数:101,代码来源:Installer.php

示例3: doInstall


//.........这里部分代码省略.........
         // force update to locked version if it does not match the installed version
         if ($installFromLock) {
             $lockData = $this->locker->getLockData();
             unset($lockedReference);
             foreach ($lockData['packages'] as $lockedPackage) {
                 if (!empty($lockedPackage['source-reference']) && strtolower($lockedPackage['package']) === $package->getName()) {
                     $lockedReference = $lockedPackage['source-reference'];
                     break;
                 }
             }
             if (isset($lockedReference) && $lockedReference !== $package->getSourceReference()) {
                 // changing the source ref to update to will be handled in the operations loop below
                 $operations[] = new UpdateOperation($package, clone $package);
             }
         } else {
             // force update to latest on update
             if ($this->update) {
                 // skip package if the whitelist is enabled and it is not in it
                 if ($this->updateWhitelist && !$this->isUpdateable($package)) {
                     continue;
                 }
                 $newPackage = $this->repositoryManager->findPackage($package->getName(), $package->getVersion());
                 if ($newPackage && $newPackage->getSourceReference() !== $package->getSourceReference()) {
                     $operations[] = new UpdateOperation($package, $newPackage);
                 }
             }
             // force installed package to update to referenced version if it does not match the installed version
             $references = $this->package->getReferences();
             if (isset($references[$package->getName()]) && $references[$package->getName()] !== $package->getSourceReference()) {
                 // changing the source ref to update to will be handled in the operations loop below
                 $operations[] = new UpdateOperation($package, clone $package);
             }
         }
     }
     // execute operations
     if (!$operations) {
         $this->io->write('Nothing to install or update');
     }
     foreach ($operations as $operation) {
         // collect suggestions
         if ('install' === $operation->getJobType()) {
             foreach ($operation->getPackage()->getSuggests() as $target => $reason) {
                 $this->suggestedPackages[] = array('source' => $operation->getPackage()->getPrettyName(), 'target' => $target, 'reason' => $reason);
             }
         }
         $event = 'Composer\\Script\\ScriptEvents::PRE_PACKAGE_' . strtoupper($operation->getJobType());
         if (defined($event) && $this->runScripts) {
             $this->eventDispatcher->dispatchPackageEvent(constant($event), $operation);
         }
         // if installing from lock, restore dev packages' references to their locked state
         if ($installFromLock) {
             $package = null;
             if ('update' === $operation->getJobType()) {
                 $package = $operation->getTargetPackage();
             } elseif ('install' === $operation->getJobType()) {
                 $package = $operation->getPackage();
             }
             if ($package && $package->isDev()) {
                 $lockData = $this->locker->getLockData();
                 foreach ($lockData['packages'] as $lockedPackage) {
                     if (!empty($lockedPackage['source-reference']) && strtolower($lockedPackage['package']) === $package->getName()) {
                         // update commit date to allow recovery in case the commit disappeared
                         if (!empty($lockedPackage['commit-date'])) {
                             $package->setReleaseDate(new \DateTime('@' . $lockedPackage['commit-date']));
                         }
                         $package->setSourceReference($lockedPackage['source-reference']);
                         break;
                     }
                 }
             }
         } else {
             // not installing from lock, force dev packages' references if they're in root package refs
             $package = null;
             if ('update' === $operation->getJobType()) {
                 $package = $operation->getTargetPackage();
             } elseif ('install' === $operation->getJobType()) {
                 $package = $operation->getPackage();
             }
             if ($package && $package->isDev()) {
                 $references = $this->package->getReferences();
                 if (isset($references[$package->getName()])) {
                     $package->setSourceReference($references[$package->getName()]);
                 }
             }
         }
         // output alias operations in verbose mode, or all ops in dry run
         if ($this->dryRun || $this->verbose && false !== strpos($operation->getJobType(), 'Alias')) {
             $this->io->write('  - ' . $operation);
         }
         $this->installationManager->execute($localRepo, $operation);
         $event = 'Composer\\Script\\ScriptEvents::POST_PACKAGE_' . strtoupper($operation->getJobType());
         if (defined($event) && $this->runScripts) {
             $this->eventDispatcher->dispatchPackageEvent(constant($event), $operation);
         }
         if (!$this->dryRun) {
             $localRepo->write();
         }
     }
     return true;
 }
开发者ID:4rejin,项目名称:composer,代码行数:101,代码来源:Installer.php

示例4: doInstall


//.........这里部分代码省略.........
     // we also force them to be uninstalled if they are present in the local repo
     if ($this->update) {
         $devPackages = $this->extractDevPackages($operations, $localRepo, $platformRepo, $aliases);
         if (!$this->devMode) {
             $operations = $this->filterDevPackageOperations($devPackages, $operations, $localRepo);
         }
     } else {
         $devPackages = null;
     }
     if ($operations) {
         $installs = $updates = $uninstalls = array();
         foreach ($operations as $operation) {
             if ($operation instanceof InstallOperation) {
                 $installs[] = $operation->getPackage()->getPrettyName() . ':' . $operation->getPackage()->getFullPrettyVersion();
             } elseif ($operation instanceof UpdateOperation) {
                 $updates[] = $operation->getTargetPackage()->getPrettyName() . ':' . $operation->getTargetPackage()->getFullPrettyVersion();
             } elseif ($operation instanceof UninstallOperation) {
                 $uninstalls[] = $operation->getPackage()->getPrettyName();
             }
         }
         $this->io->writeError(sprintf("<info>Package operations: %d install%s, %d update%s, %d removal%s</info>", count($installs), 1 === count($installs) ? '' : 's', count($updates), 1 === count($updates) ? '' : 's', count($uninstalls), 1 === count($uninstalls) ? '' : 's'));
         if ($installs) {
             $this->io->writeError("Installs: " . implode(', ', $installs), true, IOInterface::VERBOSE);
         }
         if ($updates) {
             $this->io->writeError("Updates: " . implode(', ', $updates), true, IOInterface::VERBOSE);
         }
         if ($uninstalls) {
             $this->io->writeError("Removals: " . implode(', ', $uninstalls), true, IOInterface::VERBOSE);
         }
     }
     foreach ($operations as $operation) {
         // collect suggestions
         if ('install' === $operation->getJobType()) {
             $this->suggestedPackagesReporter->addSuggestionsFromPackage($operation->getPackage());
         }
         // updating, force dev packages' references if they're in root package refs
         if ($this->update) {
             $package = null;
             if ('update' === $operation->getJobType()) {
                 $package = $operation->getTargetPackage();
             } elseif ('install' === $operation->getJobType()) {
                 $package = $operation->getPackage();
             }
             if ($package && $package->isDev()) {
                 $references = $this->package->getReferences();
                 if (isset($references[$package->getName()])) {
                     $this->updateInstallReferences($package, $references[$package->getName()]);
                 }
             }
             if ('update' === $operation->getJobType() && $operation->getTargetPackage()->isDev() && $operation->getTargetPackage()->getVersion() === $operation->getInitialPackage()->getVersion() && (!$operation->getTargetPackage()->getSourceReference() || $operation->getTargetPackage()->getSourceReference() === $operation->getInitialPackage()->getSourceReference()) && (!$operation->getTargetPackage()->getDistReference() || $operation->getTargetPackage()->getDistReference() === $operation->getInitialPackage()->getDistReference())) {
                 $this->io->writeError('  - Skipping update of ' . $operation->getTargetPackage()->getPrettyName() . ' to the same reference-locked version', true, IOInterface::DEBUG);
                 $this->io->writeError('', true, IOInterface::DEBUG);
                 continue;
             }
         }
         $event = 'Composer\\Installer\\PackageEvents::PRE_PACKAGE_' . strtoupper($operation->getJobType());
         if (defined($event) && $this->runScripts) {
             $this->eventDispatcher->dispatchPackageEvent(constant($event), $this->devMode, $policy, $pool, $installedRepo, $request, $operations, $operation);
         }
         // output non-alias ops in dry run, output alias ops in debug verbosity
         if ($this->dryRun && false === strpos($operation->getJobType(), 'Alias')) {
             $this->io->writeError('  - ' . $operation);
             $this->io->writeError('');
         } elseif ($this->io->isDebug() && false !== strpos($operation->getJobType(), 'Alias')) {
             $this->io->writeError('  - ' . $operation);
             $this->io->writeError('');
         }
         $this->installationManager->execute($localRepo, $operation);
         // output reasons why the operation was ran, only for install/update operations
         if ($this->verbose && $this->io->isVeryVerbose() && in_array($operation->getJobType(), array('install', 'update'))) {
             $reason = $operation->getReason();
             if ($reason instanceof Rule) {
                 switch ($reason->getReason()) {
                     case Rule::RULE_JOB_INSTALL:
                         $this->io->writeError('    REASON: Required by the root package: ' . $reason->getPrettyString($pool));
                         $this->io->writeError('');
                         break;
                     case Rule::RULE_PACKAGE_REQUIRES:
                         $this->io->writeError('    REASON: ' . $reason->getPrettyString($pool));
                         $this->io->writeError('');
                         break;
                 }
             }
         }
         $event = 'Composer\\Installer\\PackageEvents::POST_PACKAGE_' . strtoupper($operation->getJobType());
         if (defined($event) && $this->runScripts) {
             $this->eventDispatcher->dispatchPackageEvent(constant($event), $this->devMode, $policy, $pool, $installedRepo, $request, $operations, $operation);
         }
         if (!$this->dryRun) {
             $localRepo->write();
         }
     }
     if (!$this->dryRun) {
         // force source/dist urls to be updated for all packages
         $this->processPackageUrls($pool, $policy, $localRepo, $repositories);
         $localRepo->write();
     }
     return array(0, $devPackages);
 }
开发者ID:Rudloff,项目名称:composer,代码行数:101,代码来源:Installer.php

示例5: doInstall


//.........这里部分代码省略.........
     }
     // prepare solver
     $policy = new DefaultPolicy();
     $solver = new Solver($policy, $pool, $installedRepo);
     // solve dependencies
     try {
         $operations = $solver->solve($request);
     } catch (SolverProblemsException $e) {
         $this->io->write('<error>Your requirements could not be solved to an installable set of packages.</error>');
         $this->io->write($e->getMessage());
         return false;
     }
     // force dev packages to be updated if we update or install from a (potentially new) lock
     if ($this->update || $installFromLock) {
         foreach ($localRepo->getPackages() as $package) {
             // skip non-dev packages
             if (!$package->isDev()) {
                 continue;
             }
             // skip packages that will be updated/uninstalled
             foreach ($operations as $operation) {
                 if ('update' === $operation->getJobType() && $operation->getInitialPackage()->equals($package) || 'uninstall' === $operation->getJobType() && $operation->getPackage()->equals($package)) {
                     continue 2;
                 }
             }
             // force update to latest on update
             if ($this->update) {
                 $newPackage = $this->repositoryManager->findPackage($package->getName(), $package->getVersion());
                 if ($newPackage && $newPackage->getSourceReference() !== $package->getSourceReference()) {
                     $operations[] = new UpdateOperation($package, $newPackage);
                 }
             } elseif ($installFromLock) {
                 // force update to locked version if it does not match the installed version
                 $lockData = $this->locker->getLockData();
                 unset($lockedReference);
                 foreach ($lockData['packages'] as $lockedPackage) {
                     if (!empty($lockedPackage['source-reference']) && strtolower($lockedPackage['package']) === $package->getName()) {
                         $lockedReference = $lockedPackage['source-reference'];
                         break;
                     }
                 }
                 if (isset($lockedReference) && $lockedReference !== $package->getSourceReference()) {
                     // changing the source ref to update to will be handled in the operations loop below
                     $operations[] = new UpdateOperation($package, $package);
                 }
             }
         }
     }
     // anti-alias local repository to allow updates to work fine
     foreach ($localRepo->getPackages() as $package) {
         if ($package instanceof AliasPackage) {
             $package->getRepository()->addPackage(clone $package->getAliasOf());
             $package->getRepository()->removePackage($package);
         }
     }
     // execute operations
     if (!$operations) {
         $this->io->write('Nothing to install or update');
     }
     foreach ($operations as $operation) {
         if ($this->verbose) {
             $this->io->write((string) $operation);
         }
         // collect suggestions
         if ('install' === $operation->getJobType()) {
             foreach ($operation->getPackage()->getSuggests() as $target => $reason) {
                 $this->suggestedPackages[] = array('source' => $operation->getPackage()->getPrettyName(), 'target' => $target, 'reason' => $reason);
             }
         }
         if (!$this->dryRun) {
             $this->eventDispatcher->dispatchPackageEvent(constant('Composer\\Script\\ScriptEvents::PRE_PACKAGE_' . strtoupper($operation->getJobType())), $operation);
             // if installing from lock, restore dev packages' references to their locked state
             if ($installFromLock) {
                 $package = null;
                 if ('update' === $operation->getJobType()) {
                     $package = $operation->getTargetPackage();
                 } elseif ('install' === $operation->getJobType()) {
                     $package = $operation->getPackage();
                 }
                 if ($package && $package->isDev()) {
                     $lockData = $this->locker->getLockData();
                     foreach ($lockData['packages'] as $lockedPackage) {
                         if (!empty($lockedPackage['source-reference']) && strtolower($lockedPackage['package']) === $package->getName()) {
                             $package->setSourceReference($lockedPackage['source-reference']);
                             break;
                         }
                     }
                 }
             }
             $this->installationManager->execute($localRepo, $operation);
             $this->eventDispatcher->dispatchPackageEvent(constant('Composer\\Script\\ScriptEvents::POST_PACKAGE_' . strtoupper($operation->getJobType())), $operation);
             $localRepo->write();
         }
     }
     // reload local repository for the dev pass to work ok with aliases since it was anti-aliased above
     if (!$devMode) {
         $localRepo->reload();
     }
     return true;
 }
开发者ID:nlegoff,项目名称:composer,代码行数:101,代码来源:Installer.php

示例6: run


//.........这里部分代码省略.........
         }
         foreach ($this->locker->getLockedPackages() as $package) {
             $version = $package->getVersion();
             foreach ($aliases as $alias) {
                 if ($alias['package'] === $package->getName() && $alias['version'] === $package->getVersion()) {
                     $version = $alias['alias'];
                     break;
                 }
             }
             $constraint = new VersionConstraint('=', $version);
             $request->install($package->getName(), $constraint);
         }
     } else {
         $this->io->write('<info>Installing dependencies</info>');
         $links = $this->collectLinks($noInstallRecommends, $installSuggests);
         foreach ($links as $link) {
             $request->install($link->getTarget(), $link->getConstraint());
         }
     }
     // prepare solver
     $policy = new DefaultPolicy();
     $solver = new Solver($policy, $pool, $installedRepo);
     // solve dependencies
     $operations = $solver->solve($request);
     // force dev packages to be updated to latest reference on update
     if ($update) {
         foreach ($localRepo->getPackages() as $package) {
             if ($package instanceof AliasPackage) {
                 $package = $package->getAliasOf();
             }
             // skip non-dev packages
             if (!$package->isDev()) {
                 continue;
             }
             // skip packages that will be updated/uninstalled
             foreach ($operations as $operation) {
                 if ('update' === $operation->getJobType() && $package === $operation->getInitialPackage() || 'uninstall' === $operation->getJobType() && $package === $operation->getPackage()) {
                     continue 2;
                 }
             }
             // force update
             $newPackage = $this->repositoryManager->findPackage($package->getName(), $package->getVersion());
             if ($newPackage && $newPackage->getSourceReference() !== $package->getSourceReference()) {
                 $operations[] = new UpdateOperation($package, $newPackage);
             }
         }
     }
     // anti-alias local repository to allow updates to work fine
     foreach ($this->repositoryManager->getLocalRepository()->getPackages() as $package) {
         if ($package instanceof AliasPackage) {
             $this->repositoryManager->getLocalRepository()->addPackage(clone $package->getAliasOf());
             $this->repositoryManager->getLocalRepository()->removePackage($package);
         }
     }
     // execute operations
     if (!$operations) {
         $this->io->write('<info>Nothing to install/update</info>');
     }
     foreach ($operations as $operation) {
         if ($verbose) {
             $this->io->write((string) $operation);
         }
         if (!$dryRun) {
             $this->eventDispatcher->dispatchPackageEvent(constant('Composer\\Script\\ScriptEvents::PRE_PACKAGE_' . strtoupper($operation->getJobType())), $operation);
             // if installing from lock, restore dev packages' references to their locked state
             if ($installFromLock) {
                 $package = null;
                 if ('update' === $operation->getJobType()) {
                     $package = $operation->getTargetPackage();
                 } elseif ('install' === $operation->getJobType()) {
                     $package = $operation->getPackage();
                 }
                 if ($package && $package->isDev()) {
                     $lockData = $this->locker->getLockData();
                     foreach ($lockData['packages'] as $lockedPackage) {
                         if (!empty($lockedPackage['source-reference']) && strtolower($lockedPackage['package']) === $package->getName()) {
                             $package->setSourceReference($lockedPackage['source-reference']);
                             break;
                         }
                     }
                 }
             }
             $this->installationManager->execute($operation);
             $this->eventDispatcher->dispatchPackageEvent(constant('Composer\\Script\\ScriptEvents::POST_PACKAGE_' . strtoupper($operation->getJobType())), $operation);
         }
     }
     if (!$dryRun) {
         if ($update || !$this->locker->isLocked()) {
             $this->locker->setLockData($localRepo->getPackages(), $aliases);
             $this->io->write('<info>Writing lock file</info>');
         }
         $localRepo->write();
         $this->io->write('<info>Generating autoload files</info>');
         $generator = new AutoloadGenerator();
         $generator->dump($localRepo, $this->package, $this->installationManager, $this->installationManager->getVendorPath() . '/.composer');
         // dispatch post event
         $eventName = $update ? ScriptEvents::POST_UPDATE_CMD : ScriptEvents::POST_INSTALL_CMD;
         $this->eventDispatcher->dispatchCommandEvent($eventName);
     }
 }
开发者ID:robo47,项目名称:composer,代码行数:101,代码来源:Installer.php


注:本文中的Composer\Installer\InstallationManager::execute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。