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


PHP InstallationManager::isPackageInstalled方法代码示例

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


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

示例1: install

 public static function install(Event $event)
 {
     if (!self::init($event)) {
         return;
     }
     $notInstalled = 0;
     if (!empty(self::$toInstall)) {
         self::$io->write('<info>Installing platform-specific dependencies</info>');
         foreach (self::$toInstall as $package) {
             if (!self::$installer->isPackageInstalled(self::$localRepo, $package)) {
                 self::$installer->install(self::$localRepo, new InstallOperation($package));
                 self::updateBinary($package);
             } else {
                 $notInstalled++;
             }
         }
     }
     if (empty(self::$toInstall) || $notInstalled > 0) {
         self::$io->write('Nothing to install or update in platform-specific dependencies');
     }
 }
开发者ID:REZ1DENT3,项目名称:mystem,代码行数:21,代码来源:MystemBinaryInstaller.php

示例2: doInstall

 protected function doInstall($localRepo, $installedRepo, $platformRepo, $aliases, $withDevReqs)
 {
     // init vars
     $lockedRepository = null;
     $repositories = null;
     // initialize locker to create aliased packages
     $installFromLock = false;
     if (!$this->update && $this->locker->isLocked()) {
         $installFromLock = true;
         try {
             $lockedRepository = $this->locker->getLockedRepository($withDevReqs);
         } catch (\RuntimeException $e) {
             // if there are dev requires, then we really can not install
             if ($this->package->getDevRequires()) {
                 throw $e;
             }
             // no require-dev in composer.json and the lock file was created with no dev info, so skip them
             $lockedRepository = $this->locker->getLockedRepository();
         }
     }
     $this->whitelistUpdateDependencies($localRepo, $withDevReqs, $this->package->getRequires(), $this->package->getDevRequires());
     $this->io->writeError('<info>Loading composer repositories with package information</info>');
     // creating repository pool
     $policy = $this->createPolicy();
     $pool = $this->createPool($withDevReqs, $lockedRepository);
     $pool->addRepository($installedRepo, $aliases);
     if ($installFromLock) {
         $pool->addRepository($lockedRepository, $aliases);
     }
     if (!$installFromLock) {
         $repositories = $this->repositoryManager->getRepositories();
         foreach ($repositories as $repository) {
             $pool->addRepository($repository, $aliases);
         }
     }
     // creating requirements request
     $request = $this->createRequest($pool, $this->package, $platformRepo);
     if (!$installFromLock) {
         // remove unstable packages from the localRepo if they don't match the current stability settings
         $removedUnstablePackages = array();
         foreach ($localRepo->getPackages() as $package) {
             if (!$pool->isPackageAcceptable($package->getNames(), $package->getStability()) && $this->installationManager->isPackageInstalled($localRepo, $package)) {
                 $removedUnstablePackages[$package->getName()] = true;
                 $request->remove($package->getName(), new VersionConstraint('=', $package->getVersion()));
             }
         }
     }
     if ($this->update) {
         $this->io->writeError('<info>Updating dependencies' . ($withDevReqs ? ' (including require-dev)' : '') . '</info>');
         $request->updateAll();
         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());
         }
         // 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->updateWhitelist) {
             if ($this->locker->isLocked()) {
                 try {
                     $currentPackages = $this->locker->getLockedRepository($withDevReqs)->getPackages();
                 } catch (\RuntimeException $e) {
                     // fetch only non-dev packages from lock if doing a dev update fails due to a previously incomplete lock file
                     $currentPackages = $this->locker->getLockedRepository()->getPackages();
                 }
             } else {
                 $currentPackages = $installedRepo->getPackages();
             }
             // collect packages to fixate from root requirements 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) && !isset($removedUnstablePackages[$curPackage->getName()])) {
                             $constraint = new VersionConstraint('=', $curPackage->getVersion());
                             $request->install($curPackage->getName(), $constraint);
                         }
                         break;
                     }
                 }
             }
         }
     } elseif ($installFromLock) {
         $this->io->writeError('<info>Installing dependencies' . ($withDevReqs ? ' (including require-dev)' : '') . ' from lock file</info>');
         if (!$this->locker->isFresh()) {
             $this->io->writeError('<warning>Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. Run update to update them.</warning>');
         }
         foreach ($lockedRepository->getPackages() as $package) {
             $version = $package->getVersion();
             if (isset($aliases[$package->getName()][$version])) {
//.........这里部分代码省略.........
开发者ID:Flesh192,项目名称:magento,代码行数:101,代码来源:Installer.php

示例3: purgePackages

 /**
  * @param WritableRepositoryInterface   $repo repository to purge packages from
  * @param Installer\InstallationManager $im   manager to check whether packages are still installed
  */
 protected function purgePackages(WritableRepositoryInterface $repo, Installer\InstallationManager $im)
 {
     foreach ($repo->getPackages() as $package) {
         if (!$im->isPackageInstalled($repo, $package)) {
             $repo->removePackage($package);
         }
     }
 }
开发者ID:tommygoud,项目名称:composer,代码行数:12,代码来源:Factory.php

示例4: doInstall

 /**
  * @param  RepositoryInterface $localRepo
  * @param  RepositoryInterface $installedRepo
  * @param  PlatformRepository  $platformRepo
  * @param  array               $aliases
  * @return array [int, PackageInterfaces[]|null] with the exit code and an array of dev packages on update, or null on install
  */
 protected function doInstall($localRepo, $installedRepo, $platformRepo, $aliases)
 {
     // init vars
     $lockedRepository = null;
     $repositories = null;
     // initialize locked repo if we are installing from lock or in a partial update
     // and a lock file is present as we need to force install non-whitelisted lock file
     // packages in that case
     if (!$this->update || !empty($this->updateWhitelist) && $this->locker->isLocked()) {
         try {
             $lockedRepository = $this->locker->getLockedRepository($this->devMode);
         } catch (\RuntimeException $e) {
             // if there are dev requires, then we really can not install
             if ($this->package->getDevRequires()) {
                 throw $e;
             }
             // no require-dev in composer.json and the lock file was created with no dev info, so skip them
             $lockedRepository = $this->locker->getLockedRepository();
         }
     }
     $this->whitelistUpdateDependencies($localRepo, $this->package->getRequires(), $this->package->getDevRequires());
     $this->io->writeError('<info>Loading composer repositories with package information</info>');
     // creating repository pool
     $policy = $this->createPolicy();
     $pool = $this->createPool($this->update ? null : $lockedRepository);
     $pool->addRepository($installedRepo, $aliases);
     if ($this->update) {
         $repositories = $this->repositoryManager->getRepositories();
         foreach ($repositories as $repository) {
             $pool->addRepository($repository, $aliases);
         }
     }
     // Add the locked repository after the others in case we are doing a
     // partial update so missing packages can be found there still.
     // For installs from lock it's the only one added so it is first
     if ($lockedRepository) {
         $pool->addRepository($lockedRepository, $aliases);
     }
     // creating requirements request
     $request = $this->createRequest($this->package, $platformRepo);
     if ($this->update) {
         // remove unstable packages from the localRepo if they don't match the current stability settings
         $removedUnstablePackages = array();
         foreach ($localRepo->getPackages() as $package) {
             if (!$pool->isPackageAcceptable($package->getNames(), $package->getStability()) && $this->installationManager->isPackageInstalled($localRepo, $package)) {
                 $removedUnstablePackages[$package->getName()] = true;
                 $request->remove($package->getName(), new Constraint('=', $package->getVersion()));
             }
         }
         $this->io->writeError('<info>Updating dependencies' . ($this->devMode ? ' (including require-dev)' : '') . '</info>');
         $request->updateAll();
         $links = array_merge($this->package->getRequires(), $this->package->getDevRequires());
         foreach ($links as $link) {
             $request->install($link->getTarget(), $link->getConstraint());
         }
         // 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->updateWhitelist) {
             $currentPackages = $this->getCurrentPackages($installedRepo);
             // collect packages to fixate from root requirements as well as installed packages
             $candidates = array();
             foreach ($links as $link) {
                 $candidates[$link->getTarget()] = true;
                 $rootRequires[$link->getTarget()] = $link;
             }
             foreach ($currentPackages 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) && !isset($removedUnstablePackages[$curPackage->getName()])) {
                             $constraint = new Constraint('=', $curPackage->getVersion());
                             $description = $this->locker->isLocked() ? '(locked at' : '(installed at';
                             $requiredAt = isset($rootRequires[$candidate]) ? ', required as ' . $rootRequires[$candidate]->getPrettyConstraint() : '';
                             $constraint->setPrettyString($description . ' ' . $curPackage->getPrettyVersion() . $requiredAt . ')');
                             $request->install($curPackage->getName(), $constraint);
                         }
                         break;
                     }
                 }
             }
         }
     } else {
         $this->io->writeError('<info>Installing dependencies' . ($this->devMode ? ' (including require-dev)' : '') . ' from lock file</info>');
         if (!$this->locker->isFresh()) {
             $this->io->writeError('<warning>Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. Run update to update them.</warning>', true, IOInterface::QUIET);
         }
         foreach ($lockedRepository->getPackages() as $package) {
             $version = $package->getVersion();
             if (isset($aliases[$package->getName()][$version])) {
                 $version = $aliases[$package->getName()][$version]['alias_normalized'];
//.........这里部分代码省略.........
开发者ID:Rudloff,项目名称:composer,代码行数:101,代码来源:Installer.php

示例5: purgePackages

 /**
  * @param Repository\RepositoryManager  $rm
  * @param Installer\InstallationManager $im
  */
 protected function purgePackages(Repository\RepositoryManager $rm, Installer\InstallationManager $im)
 {
     $repo = $rm->getLocalRepository();
     foreach ($repo->getPackages() as $package) {
         if (!$im->isPackageInstalled($repo, $package)) {
             $repo->removePackage($package);
         }
     }
 }
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:13,代码来源:Factory.php

示例6: getFilterOperator

 /**
  * Get the filter root constraint operator.
  *
  * @param PackageInterface $package
  *
  * @return string
  */
 private function getFilterOperator(PackageInterface $package)
 {
     return $this->installationManager->isPackageInstalled($this->installedRepository, $package) ? '>' : '>=';
 }
开发者ID:MvegaR,项目名称:ingSotfware,代码行数:11,代码来源:VcsPackageFilter.php

示例7: purgePackages

 /**
  * @param Repository\RepositoryManager  $rm
  * @param Installer\InstallationManager $im
  */
 protected function purgePackages(Repository\RepositoryManager $rm, Installer\InstallationManager $im)
 {
     foreach ($rm->getLocalRepositories() as $repo) {
         /* @var $repo   Repository\WritableRepositoryInterface */
         foreach ($repo->getPackages() as $package) {
             if (!$im->isPackageInstalled($repo, $package)) {
                 $repo->removePackage($package);
             }
         }
     }
 }
开发者ID:rkallensee,项目名称:composer,代码行数:15,代码来源:Factory.php


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