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


PHP Composer::getLocker方法代码示例

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


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

示例1: __construct

 /**
  * Constructor
  *
  * @param Filesystem $filesystem
  */
 public function __construct(Filesystem $filesystem)
 {
     $vendor = $filesystem->getDirectoryRead(DirectoryList::CONFIG)->getAbsolutePath('vendor_path.php');
     $vendorPath = $filesystem->getDirectoryRead(DirectoryList::ROOT)->getAbsolutePath() . (include $vendor);
     // Create Composer
     $io = new \Composer\IO\BufferIO();
     $this->composer = ComposerFactory::create($io, $vendorPath . '/../composer.json');
     $this->locker = $this->composer->getLocker();
 }
开发者ID:kid17,项目名称:magento2,代码行数:14,代码来源:ComposerInformation.php

示例2: init

 /**
  * {@inheritdoc}
  */
 public function init()
 {
     // Retrieve the configuration variables.
     $this->config = $this->composer->getConfig();
     if (isset($this->config)) {
         if ($this->config->has('component-dir')) {
             $this->componentDir = $this->config->get('component-dir');
         }
     }
     // Get the available packages.
     $allPackages = array();
     /** @var \Composer\Package\Locker $locker */
     $locker = $this->composer->getLocker();
     if ($locker !== null && $locker->isLocked()) {
         $lockData = $locker->getLockData();
         $allPackages = $lockData['packages'];
         // Also merge in any of the development packages.
         $dev = isset($lockData['packages-dev']) ? $lockData['packages-dev'] : array();
         foreach ($dev as $package) {
             $allPackages[] = $package;
         }
     }
     // Only add those packages that we can reasonably
     // assume are components into our packages list
     /** @var \Composer\Package\RootPackageInterface $rootPackage */
     $rootPackage = $this->composer->getPackage();
     $rootExtras = $rootPackage ? $rootPackage->getExtra() : array();
     $customComponents = isset($rootExtras['component']) ? $rootExtras['component'] : array();
     foreach ($allPackages as $package) {
         $name = $package['name'];
         if (isset($customComponents[$name]) && is_array($customComponents[$name])) {
             $package['extra'] = array('component' => $customComponents[$name]);
             $this->packages[] = $package;
         } else {
             $extra = isset($package['extra']) ? $package['extra'] : array();
             if (isset($extra['component']) && is_array($extra['component'])) {
                 $this->packages[] = $package;
             }
         }
     }
     // Add the root package to the packages list.
     $root = $this->composer->getPackage();
     if ($root) {
         $dumper = new ArrayDumper();
         $package = $dumper->dump($root);
         $package['is-root'] = true;
         $this->packages[] = $package;
     }
     return true;
 }
开发者ID:SylvainSimon,项目名称:Metinify,代码行数:53,代码来源:Process.php

示例3: __construct

 /**
  * Constructor
  *
  * @param Filesystem $filesystem
  * @param BufferIoFactory $bufferIoFactory
  * @throws \Exception
  */
 public function __construct(Filesystem $filesystem, BufferIoFactory $bufferIoFactory)
 {
     // composer.json is in same directory as vendor
     $vendorPath = $filesystem->getDirectoryRead(DirectoryList::CONFIG)->getAbsolutePath('vendor_path.php');
     $vendorDir = (require "{$vendorPath}");
     $composerJson = $filesystem->getDirectoryRead(DirectoryList::ROOT)->getAbsolutePath() . "/{$vendorDir}/../composer.json";
     $composerJsonRealPath = realpath($composerJson);
     if ($composerJsonRealPath === false) {
         throw new \Exception('Composer file not found: ' . $composerJson);
     }
     putenv('COMPOSER_HOME=' . $filesystem->getDirectoryRead(DirectoryList::COMPOSER_HOME)->getAbsolutePath());
     // Create Composer
     $this->composer = ComposerFactory::create($bufferIoFactory->create(), $composerJson);
     $this->locker = $this->composer->getLocker();
 }
开发者ID:nja78,项目名称:magento2,代码行数:22,代码来源:ComposerInformation.php

示例4: testSetGetLocker

 public function testSetGetLocker()
 {
     $composer = new Composer();
     $locker = $this->getMockBuilder('Composer\\Package\\Locker')->disableOriginalConstructor()->getMock();
     $composer->setLocker($locker);
     $this->assertSame($locker, $composer->getLocker());
 }
开发者ID:alancleaver,项目名称:composer,代码行数:7,代码来源:ComposerTest.php

示例5: __construct

 /**
  * Constructor
  *
  * @param MagentoComposerApplicationFactory $applicationFactory
  * @throws \Exception
  */
 public function __construct(
     MagentoComposerApplicationFactory $applicationFactory
 ) {
     $this->application = $applicationFactory->create();
     $this->composer = $this->application->createComposer();
     $this->locker = $this->composer->getLocker();
 }
开发者ID:rafaelstz,项目名称:magento2,代码行数:13,代码来源:ComposerInformation.php

示例6: getLockerData

 /**
  * Returns locker data for given package
  *
  * @param BasePackage
  * @return string
  */
 private function getLockerData(BasePackage $package)
 {
     $data = $this->composer->getLocker()->getLockData();
     foreach ((array) $data['packages'] as $pkgData) {
         if ($pkgData['name'] == $package->getName()) {
             return $pkgData;
         }
     }
     return NULL;
 }
开发者ID:vbuilder,项目名称:composer-plugin,代码行数:16,代码来源:Plugin.php

示例7: create

 /**
  * Create Installer
  *
  * @param  IOInterface       $io
  * @param  Composer          $composer
  * @param  EventDispatcher   $eventDispatcher
  * @param  AutoloadGenerator $autoloadGenerator
  * @return Installer
  */
 public static function create(IOInterface $io, Composer $composer, EventDispatcher $eventDispatcher = null, AutoloadGenerator $autoloadGenerator = null)
 {
     $eventDispatcher = $eventDispatcher ?: new EventDispatcher($composer, $io);
     $autoloadGenerator = $autoloadGenerator ?: new AutoloadGenerator();
     return new static($io, $composer->getConfig(), $composer->getPackage(), $composer->getDownloadManager(), $composer->getRepositoryManager(), $composer->getLocker(), $composer->getInstallationManager(), $eventDispatcher, $autoloadGenerator);
 }
开发者ID:rkallensee,项目名称:composer,代码行数:15,代码来源:Installer.php

示例8: create

 /**
  * Create Installer
  *
  * @param  IOInterface $io
  * @param  Composer    $composer
  * @return Installer
  */
 public static function create(IOInterface $io, Composer $composer)
 {
     return new static($io, $composer->getConfig(), $composer->getPackage(), $composer->getDownloadManager(), $composer->getRepositoryManager(), $composer->getLocker(), $composer->getInstallationManager(), $composer->getEventDispatcher(), $composer->getAutoloadGenerator());
 }
开发者ID:Flesh192,项目名称:magento,代码行数:11,代码来源:Installer.php

示例9: createInstaller

 /**
  * Create an Installer instance.
  *
  * Private static factory, to allow slip-streaming in a mock as needed for
  * testing.
  */
 private static function createInstaller(Composer $composer, IOInterface $io, PackageInterface $package)
 {
     $eventDispatcher = new EventDispatcher($composer, $io);
     return new ComposerInstaller($io, $composer->getConfig(), $package, $composer->getDownloadManager(), $composer->getRepositoryManager(), $composer->getLocker(), $composer->getInstallationManager(), $eventDispatcher, $composer->getAutoloadGenerator());
 }
开发者ID:zendframework,项目名称:zend-skeleton-installer,代码行数:11,代码来源:OptionalPackagesInstaller.php

示例10: install

 public function install(IOInterface $io, Composer $composer, EventDispatcher $eventDispatcher, $preferSource = false, $dryRun = false, $verbose = false, $noInstallRecommends = false, $installSuggests = false, $update = false, RepositoryInterface $additionalInstalledRepository = null)
 {
     if ($dryRun) {
         $verbose = true;
     }
     if ($preferSource) {
         $composer->getDownloadManager()->setPreferSource(true);
     }
     // create local repo, this contains all packages that are installed in the local project
     $localRepo = $composer->getRepositoryManager()->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);
     }
     // creating repository pool
     $pool = new Pool();
     $pool->addRepository($installedRepo);
     foreach ($composer->getRepositoryManager()->getRepositories() as $repository) {
         $pool->addRepository($repository);
     }
     // dispatch pre event
     if (!$dryRun) {
         $eventName = $update ? ScriptEvents::PRE_UPDATE_CMD : ScriptEvents::PRE_INSTALL_CMD;
         $eventDispatcher->dispatchCommandEvent($eventName);
     }
     // creating requirements request
     $installFromLock = false;
     $request = new Request($pool);
     if ($update) {
         $io->write('<info>Updating dependencies</info>');
         $installedPackages = $installedRepo->getPackages();
         $links = $this->collectLinks($composer->getPackage(), $noInstallRecommends, $installSuggests);
         $request->updateAll();
         foreach ($links as $link) {
             $request->install($link->getTarget(), $link->getConstraint());
         }
     } elseif ($composer->getLocker()->isLocked()) {
         $installFromLock = true;
         $io->write('<info>Installing from lock file</info>');
         if (!$composer->getLocker()->isFresh()) {
             $io->write('<warning>Your lock file is out of sync with your composer.json, run "composer.phar update" to update dependencies</warning>');
         }
         foreach ($composer->getLocker()->getLockedPackages() as $package) {
             $constraint = new VersionConstraint('=', $package->getVersion());
             $request->install($package->getName(), $constraint);
         }
     } else {
         $io->write('<info>Installing dependencies</info>');
         $links = $this->collectLinks($composer->getPackage(), $noInstallRecommends, $installSuggests);
         foreach ($links as $link) {
             $request->install($link->getTarget(), $link->getConstraint());
         }
     }
     // prepare solver
     $installationManager = $composer->getInstallationManager();
     $policy = new DependencyResolver\DefaultPolicy();
     $solver = new DependencyResolver\Solver($policy, $pool, $installedRepo);
     // solve dependencies
     $operations = $solver->solve($request);
     // execute operations
     if (!$operations) {
         $io->write('<info>Nothing to install/update</info>');
     }
     // force dev packages to be updated to latest reference on update
     if ($update) {
         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() && $package === $operation->getInitialPackage() || 'uninstall' === $operation->getJobType() && $package === $operation->getPackage()) {
                     continue 2;
                 }
             }
             // force update
             $newPackage = $composer->getRepositoryManager()->findPackage($package->getName(), $package->getVersion());
             if ($newPackage && $newPackage->getSourceReference() !== $package->getSourceReference()) {
                 $operations[] = new UpdateOperation($package, $newPackage);
             }
         }
     }
     foreach ($operations as $operation) {
         if ($verbose) {
             $io->write((string) $operation);
         }
         if (!$dryRun) {
             $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 = $composer->getLocker()->getLockData();
//.........这里部分代码省略.........
开发者ID:natxet,项目名称:composer,代码行数:101,代码来源:InstallCommand.php

示例11: generateVersionsClass

 private static function generateVersionsClass(Composer $composer) : string
 {
     return sprintf(self::$generatedClassTemplate, var_export(iterator_to_array(self::getVersions($composer->getLocker(), $composer->getPackage())), true));
 }
开发者ID:WyriHaximus,项目名称:PackageVersions,代码行数:4,代码来源:Installer.php

示例12: getVersion

 /**
  * Returns the PhantomJS version number.
  *
  * Firstly, we search for a version number in the local repository,
  * secondly, in the root package.
  * A version specification of "dev-master#<commit-reference>" is disallowed.
  *
  * @param Composer $composer
  * @return string $version Version
  */
 public static function getVersion($composer)
 {
     // try getting the version from the local repository
     $packages = $composer->getRepositoryManager()->getLocalRepository()->getCanonicalPackages();
     foreach ($packages as $package) {
         if ($package->getName() === self::PACKAGE_NAME) {
             $version = $package->getPrettyVersion();
             break;
         }
     }
     // let's take a look at the aliases
     if ($package->getVersion() === '9999999-dev') {
         // this indicates the version alias???
         $aliases = $composer->getLocker()->getAliases();
         foreach ($aliases as $idx => $alias) {
             if ($alias['package'] === self::PACKAGE_NAME) {
                 return $alias['alias'];
             }
         }
     }
     // let's take a look at the root package
     if (!empty($version)) {
         $version = self::getRequiredVersion($composer->getPackage());
     }
     // fallback to the hardcoded latest version, if "dev-master" was set
     if ($version === 'dev-master') {
         return self::getLatestPhantomJsVersion();
     }
     // grab version from commit-reference, e.g. "dev-master#<commit-ref> as version"
     if (preg_match('/dev-master#(?:.*)(\\d.\\d.\\d)/i', $version, $matches)) {
         return $matches[1];
     }
     // grab version from a Composer patch version tag with a patch level, like "1.9.8-p02"
     if (preg_match('/(\\d.\\d.\\d)(?:(?:-p\\d{2})?)/i', $version, $matches)) {
         return $matches[1];
     }
     return $version;
 }
开发者ID:mayrop,项目名称:phantomjs-installer,代码行数:48,代码来源:Installer.php


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