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


PHP RepositoryManager::getLocalRepository方法代码示例

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


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

示例1: mapContrib

 public function mapContrib(InstallationManager $im, RepositoryManager $rm)
 {
     $typePathMap = $this->getTypePathMap();
     $typeInstallMap = [];
     $packages = $rm->getLocalRepository()->getCanonicalPackages();
     foreach ($packages as $package) {
         if ($drupalType = $this->getDrupalType($package)) {
             if (!isset($typePathMap[$drupalType])) {
                 continue;
             }
             $installPath = self::changeSlashes($im->getInstaller($package->getType())->getInstallPath($package));
             if (strpos($installPath, $root = $this->getRoot()) !== false) {
                 $installPath = self::changeSlashes($this->getFS()->makePathRelative($installPath, $root));
             }
             $name = explode('/', $package->getPrettyName())[1];
             $mapRef =& $typeInstallMap[$drupalType][rtrim($installPath, DIRECTORY_SEPARATOR)];
             if (in_array($drupalType, ['module', 'theme'])) {
                 $mapRef = sprintf($typePathMap[$drupalType] . DIRECTORY_SEPARATOR . '%s', 'contrib', $name);
             } else {
                 $mapRef = sprintf($typePathMap[$drupalType], $name);
             }
         }
     }
     return array_intersect_key($typeInstallMap, $typePathMap);
 }
开发者ID:mbolli,项目名称:drupal-tangler,代码行数:25,代码来源:Mapper.php

示例2: run

 /**
  * Run installation (or update)
  */
 public function run()
 {
     if ($this->dryRun) {
         $this->verbose = true;
         $this->runScripts = false;
         $this->installationManager->addInstaller(new NoopInstaller());
     }
     if ($this->preferSource) {
         $this->downloadManager->setPreferSource(true);
     }
     // create installed repo, this contains all local packages + platform packages (php & extensions)
     $installedRootPackage = clone $this->package;
     $installedRootPackage->setRequires(array());
     $installedRootPackage->setDevRequires(array());
     $repos = array_merge($this->repositoryManager->getLocalRepositories(), array(new InstalledArrayRepository(array($installedRootPackage)), new PlatformRepository()));
     $installedRepo = new CompositeRepository($repos);
     if ($this->additionalInstalledRepository) {
         $installedRepo->addRepository($this->additionalInstalledRepository);
     }
     $aliases = $this->aliasPackages();
     if ($this->runScripts) {
         // dispatch pre event
         $eventName = $this->update ? ScriptEvents::PRE_UPDATE_CMD : ScriptEvents::PRE_INSTALL_CMD;
         $this->eventDispatcher->dispatchCommandEvent($eventName);
     }
     $this->suggestedPackages = array();
     if (!$this->doInstall($this->repositoryManager->getLocalRepository(), $installedRepo, $aliases)) {
         return false;
     }
     if ($this->devMode) {
         if (!$this->doInstall($this->repositoryManager->getLocalDevRepository(), $installedRepo, $aliases, true)) {
             return false;
         }
     }
     // output suggestions
     foreach ($this->suggestedPackages as $suggestion) {
         if (!$installedRepo->findPackages($suggestion['target'])) {
             $this->io->write($suggestion['source'] . ' suggests installing ' . $suggestion['target'] . ' (' . $suggestion['reason'] . ')');
         }
     }
     if (!$this->dryRun) {
         // write lock
         if ($this->update || !$this->locker->isLocked()) {
             $updatedLock = $this->locker->setLockData($this->repositoryManager->getLocalRepository()->getPackages(), $this->devMode ? $this->repositoryManager->getLocalDevRepository()->getPackages() : null, $aliases, $this->package->getMinimumStability(), $this->package->getStabilityFlags());
             if ($updatedLock) {
                 $this->io->write('<info>Writing lock file</info>');
             }
         }
         // write autoloader
         $this->io->write('<info>Generating autoload files</info>');
         $localRepos = new CompositeRepository($this->repositoryManager->getLocalRepositories());
         $this->autoloadGenerator->dump($localRepos, $this->package, $this->installationManager, $this->installationManager->getVendorPath() . '/composer', true);
         if ($this->runScripts) {
             // dispatch post event
             $eventName = $this->update ? ScriptEvents::POST_UPDATE_CMD : ScriptEvents::POST_INSTALL_CMD;
             $this->eventDispatcher->dispatchCommandEvent($eventName);
         }
     }
     return true;
 }
开发者ID:nicodmf,项目名称:composer,代码行数:63,代码来源:Installer.php

示例3: mapContrib

 public function mapContrib(InstallationManager $im, RepositoryManager $rm)
 {
     $typePathMap = $this->getTypePathMap();
     $typeInstallMap = [];
     $packages = $rm->getLocalRepository()->getCanonicalPackages();
     foreach ($packages as $package) {
         if ($drupalType = $this->getDrupalType($package)) {
             $installPath = $im->getInstaller($package->getType())->getInstallPath($package);
             if (strpos($installPath, $root = $this->getRoot()) !== false) {
                 $installPath = $this->getFS()->makePathRelative($installPath, $root);
             }
             $name = explode('/', $package->getPrettyName())[1];
             $typeInstallMap[$drupalType][rtrim($installPath, '/')] = sprintf($typePathMap[$drupalType] . '/%s', 'contrib', $name);
         }
     }
     return array_intersect_key($typeInstallMap, $typePathMap);
 }
开发者ID:davidbarratt,项目名称:drupal-tangler,代码行数:17,代码来源:Mapper.php

示例4: mockLocalRepositories

 /**
  * Replace local repositories with InstalledArrayRepository instances
  *
  * This is to prevent any accidental modification of the existing repos on disk
  *
  * @param RepositoryManager $rm
  */
 private function mockLocalRepositories(RepositoryManager $rm)
 {
     $packages = array_map(function ($p) {
         return clone $p;
     }, $rm->getLocalRepository()->getPackages());
     foreach ($packages as $key => $package) {
         if ($package instanceof AliasPackage) {
             unset($packages[$key]);
         }
     }
     $rm->setLocalRepository(new InstalledArrayRepository($packages));
     $packages = array_map(function ($p) {
         return clone $p;
     }, $rm->getLocalDevRepository()->getPackages());
     foreach ($packages as $key => $package) {
         if ($package instanceof AliasPackage) {
             unset($packages[$key]);
         }
     }
     $rm->setLocalDevRepository(new InstalledArrayRepository($packages));
 }
开发者ID:rkallensee,项目名称:composer,代码行数:28,代码来源:Installer.php

示例5: mockLocalRepositories

 /**
  * Replace local repositories with InstalledArrayRepository instances
  *
  * This is to prevent any accidental modification of the existing repos on disk
  *
  * @param RepositoryManager $rm
  */
 private function mockLocalRepositories(RepositoryManager $rm)
 {
     $packages = array();
     foreach ($rm->getLocalRepository()->getPackages() as $package) {
         $packages[(string) $package] = clone $package;
     }
     foreach ($packages as $key => $package) {
         if ($package instanceof AliasPackage) {
             $alias = (string) $package->getAliasOf();
             $packages[$key] = new AliasPackage($packages[$alias], $package->getVersion(), $package->getPrettyVersion());
         }
     }
     $rm->setLocalRepository(new InstalledArrayRepository($packages));
 }
开发者ID:Flesh192,项目名称:magento,代码行数:21,代码来源:Installer.php

示例6: 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

示例7: createInstallationManager

 protected function createInstallationManager(Repository\RepositoryManager $rm, Downloader\DownloadManager $dm, $vendorDir, $binDir, IOInterface $io)
 {
     $im = new Installer\InstallationManager($vendorDir);
     $im->addInstaller(new Installer\LibraryInstaller($vendorDir, $binDir, $dm, $rm->getLocalRepository(), $io, null));
     $im->addInstaller(new Installer\InstallerInstaller($vendorDir, $binDir, $dm, $rm->getLocalRepository(), $io, $im));
     return $im;
 }
开发者ID:roadrunner,项目名称:composer,代码行数:7,代码来源:Factory.php

示例8: run

 /**
  * Run installation (or update)
  *
  * @param Boolean $preferSource
  * @param Boolean $dryRun
  * @param Boolean $verbose
  * @param Boolean $noInstallRecommends
  * @param Boolean $installSuggests
  * @param Boolean $update
  * @param RepositoryInterface $additionalInstalledRepository
  */
 public function run($preferSource = false, $dryRun = false, $verbose = false, $noInstallRecommends = false, $installSuggests = false, $update = false, RepositoryInterface $additionalInstalledRepository = null)
 {
     if ($dryRun) {
         $verbose = true;
     }
     if ($preferSource) {
         $this->downloadManager->setPreferSource(true);
     }
     $this->repositoryManager = $this->repositoryManager;
     // create local repo, this contains all packages that are installed in the local project
     $localRepo = $this->repositoryManager->getLocalRepository();
     // create installed repo, this contains all local packages + platform packages (php & extensions)
     $installedRepo = new CompositeRepository(array($localRepo, new PlatformRepository()));
     if ($additionalInstalledRepository) {
         $installedRepo->addRepository($additionalInstalledRepository);
     }
     // prepare aliased packages
     if (!$update && $this->locker->isLocked()) {
         $aliases = $this->locker->getAliases();
     } else {
         $aliases = $this->package->getAliases();
     }
     foreach ($aliases as $alias) {
         foreach ($this->repositoryManager->findPackages($alias['package'], $alias['version']) as $package) {
             $package->getRepository()->addPackage(new AliasPackage($package, $alias['alias_normalized'], $alias['alias']));
         }
         foreach ($this->repositoryManager->getLocalRepository()->findPackages($alias['package'], $alias['version']) as $package) {
             $this->repositoryManager->getLocalRepository()->addPackage(new AliasPackage($package, $alias['alias_normalized'], $alias['alias']));
             $this->repositoryManager->getLocalRepository()->removePackage($package);
         }
     }
     // creating repository pool
     $pool = new Pool();
     $pool->addRepository($installedRepo);
     foreach ($this->repositoryManager->getRepositories() as $repository) {
         $pool->addRepository($repository);
     }
     // dispatch pre event
     if (!$dryRun) {
         $eventName = $update ? ScriptEvents::PRE_UPDATE_CMD : ScriptEvents::PRE_INSTALL_CMD;
         $this->eventDispatcher->dispatchCommandEvent($eventName);
     }
     // creating requirements request
     $installFromLock = false;
     $request = new Request($pool);
     if ($update) {
         $this->io->write('<info>Updating dependencies</info>');
         $request->updateAll();
         $links = $this->collectLinks($noInstallRecommends, $installSuggests);
         foreach ($links as $link) {
             $request->install($link->getTarget(), $link->getConstraint());
         }
     } elseif ($this->locker->isLocked()) {
         $installFromLock = true;
         $this->io->write('<info>Installing from lock file</info>');
         if (!$this->locker->isFresh()) {
             $this->io->write('<warning>Your lock file is out of sync with your composer.json, run "composer.phar update" to update dependencies</warning>');
         }
         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()) {
//.........这里部分代码省略.........
开发者ID:robo47,项目名称:composer,代码行数:101,代码来源:Installer.php


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