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


PHP PackageInterface::getVersion方法代码示例

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


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

示例1: getInstallPath

 /**
  * Return the install path based on package type.
  *
  * Relies on built-in BaseInstaller behaviour with one exception: silverstripe/framework
  * must be installed to 'sapphire' and not 'framework' if the version is <3.0.0
  *
  * @param  PackageInterface $package
  * @param  string           $frameworkType
  * @return string
  */
 public function getInstallPath(PackageInterface $package, $frameworkType = '')
 {
     if ($package->getName() == 'silverstripe/framework' && preg_match('/^\\d+\\.\\d+\\.\\d+/', $package->getVersion()) && version_compare($package->getVersion(), '2.999.999') < 0) {
         return $this->templatePath($this->locations['module'], array('name' => 'sapphire'));
     } else {
         return parent::getInstallPath($package, $frameworkType);
     }
 }
开发者ID:santikrass,项目名称:apache,代码行数:18,代码来源:SilverStripeInstaller.php

示例2: uninstall

 public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
 {
     $this->initGingerBackend();
     $extra = $package->getExtra();
     $uninstallPluginCommand = new Cqrs\UninstallPluginCommand(array('plugin_name' => $package->getName(), 'plugin_type' => $package->getType(), 'plugin_namespace' => $extra['plugin-namespace'], 'plugin_version' => $package->getVersion()));
     $this->getServiceManager()->get('malocher.cqrs.gate')->getBus()->invokeCommand($uninstallPluginCommand);
     parent::uninstall($repo, $package);
 }
开发者ID:gingerwfms,项目名称:ginger-plugin-installer,代码行数:8,代码来源:GingerInstaller.php

示例3: versionCompare

 public function versionCompare(PackageInterface $a, PackageInterface $b, $operator)
 {
     if ($this->preferStable && ($stabA = $a->getStability()) !== ($stabB = $b->getStability())) {
         return BasePackage::$stabilities[$stabA] < BasePackage::$stabilities[$stabB];
     }
     $constraint = new VersionConstraint($operator, $b->getVersion());
     $version = new VersionConstraint('==', $a->getVersion());
     return $constraint->matchSpecific($version, true);
 }
开发者ID:aminembarki,项目名称:composer,代码行数:9,代码来源:DefaultPolicy.php

示例4: dump

 public function dump(PackageInterface $package)
 {
     $keys = array('binaries' => 'bin', 'type', 'extra', 'installationSource' => 'installation-source', 'autoload', 'notificationUrl' => 'notification-url', 'includePaths' => 'include-path');
     $data = array();
     $data['name'] = $package->getPrettyName();
     $data['version'] = $package->getPrettyVersion();
     $data['version_normalized'] = $package->getVersion();
     if ($package->getTargetDir()) {
         $data['target-dir'] = $package->getTargetDir();
     }
     if ($package->getSourceType()) {
         $data['source']['type'] = $package->getSourceType();
         $data['source']['url'] = $package->getSourceUrl();
         $data['source']['reference'] = $package->getSourceReference();
     }
     if ($package->getDistType()) {
         $data['dist']['type'] = $package->getDistType();
         $data['dist']['url'] = $package->getDistUrl();
         $data['dist']['reference'] = $package->getDistReference();
         $data['dist']['shasum'] = $package->getDistSha1Checksum();
     }
     if ($package->getArchiveExcludes()) {
         $data['archive']['exclude'] = $package->getArchiveExcludes();
     }
     foreach (BasePackage::$supportedLinkTypes as $type => $opts) {
         if ($links = $package->{'get' . ucfirst($opts['method'])}()) {
             foreach ($links as $link) {
                 $data[$type][$link->getTarget()] = $link->getPrettyConstraint();
             }
             ksort($data[$type]);
         }
     }
     if ($packages = $package->getSuggests()) {
         ksort($packages);
         $data['suggest'] = $packages;
     }
     if ($package->getReleaseDate()) {
         $data['time'] = $package->getReleaseDate()->format('Y-m-d H:i:s');
     }
     $data = $this->dumpValues($package, $keys, $data);
     if ($package instanceof CompletePackageInterface) {
         $keys = array('scripts', 'license', 'authors', 'description', 'homepage', 'keywords', 'repositories', 'support');
         $data = $this->dumpValues($package, $keys, $data);
         if (isset($data['keywords']) && is_array($data['keywords'])) {
             sort($data['keywords']);
         }
     }
     if ($package instanceof RootPackageInterface) {
         $minimumStability = $package->getMinimumStability();
         if ($minimumStability) {
             $data['minimum-stability'] = $minimumStability;
         }
     }
     return $data;
 }
开发者ID:itillawarra,项目名称:cmfive,代码行数:55,代码来源:ArrayDumper.php

示例5: notifyInstall

 /**
  * {@inheritDoc}
  */
 public function notifyInstall(PackageInterface $package)
 {
     if (!$this->notifyUrl || !$this->config->get('notify-on-install')) {
         return;
     }
     // TODO use an optional curl_multi pool for all the notifications
     $url = str_replace('%package%', $package->getPrettyName(), $this->notifyUrl);
     $params = array('version' => $package->getPrettyVersion(), 'version_normalized' => $package->getVersion());
     $opts = array('http' => array('method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => http_build_query($params, '', '&'), 'timeout' => 3));
     $context = stream_context_create($opts);
     @file_get_contents($url, false, $context);
 }
开发者ID:rufinus,项目名称:composer,代码行数:15,代码来源:ComposerRepository.php

示例6: setRootPackage

 protected function setRootPackage(PackageInterface $package)
 {
     $info = ['name' => $package->getName(), 'version' => $package->getVersion()];
     $alias = $this->generatePackagetAlias($package);
     if (!empty($alias)) {
         $info['alias'] = $alias;
     }
     $extra = $package->getExtra();
     if (isset($extra[self::EXTRA_BOOTSTRAP])) {
         $info['bootstrap'] = $extra[self::EXTRA_BOOTSTRAP];
     }
     $this->savePackage($info);
 }
开发者ID:deesoft,项目名称:yii2-composer,代码行数:13,代码来源:Installer.php

示例7: addPackage

 protected function addPackage(PackageInterface $package)
 {
     $extension = ['name' => $package->getName(), 'version' => $package->getVersion()];
     $alias = $this->generateDefaultAlias($package);
     if (!empty($alias)) {
         $extension['alias'] = $alias;
     }
     $extra = $package->getExtra();
     if (isset($extra[self::EXTRA_BOOTSTRAP])) {
         $extension['bootstrap'] = $extra[self::EXTRA_BOOTSTRAP];
     }
     $extensions = $this->loadExtensions();
     $extensions[$package->getName()] = $extension;
     $this->saveExtensions($extensions);
 }
开发者ID:selenzo,项目名称:bsuir,代码行数:15,代码来源:Installer.php

示例8: dump

 public function dump(PackageInterface $package)
 {
     $keys = array('binaries' => 'bin', 'scripts', 'type', 'extra', 'installationSource' => 'installation-source', 'license', 'authors', 'description', 'homepage', 'keywords', 'autoload', 'repositories', 'includePaths' => 'include-path', 'support');
     $data = array();
     $data['name'] = $package->getPrettyName();
     $data['version'] = $package->getPrettyVersion();
     $data['version_normalized'] = $package->getVersion();
     if ($package->getTargetDir()) {
         $data['target-dir'] = $package->getTargetDir();
     }
     if ($package->getReleaseDate()) {
         $data['time'] = $package->getReleaseDate()->format('Y-m-d H:i:s');
     }
     if ($package->getSourceType()) {
         $data['source']['type'] = $package->getSourceType();
         $data['source']['url'] = $package->getSourceUrl();
         $data['source']['reference'] = $package->getSourceReference();
     }
     if ($package->getDistType()) {
         $data['dist']['type'] = $package->getDistType();
         $data['dist']['url'] = $package->getDistUrl();
         $data['dist']['reference'] = $package->getDistReference();
         $data['dist']['shasum'] = $package->getDistSha1Checksum();
     }
     foreach (BasePackage::$supportedLinkTypes as $type => $opts) {
         if ($links = $package->{'get' . ucfirst($opts['method'])}()) {
             foreach ($links as $link) {
                 $data[$type][$link->getTarget()] = $link->getPrettyConstraint();
             }
         }
     }
     if ($packages = $package->getSuggests()) {
         $data['suggest'] = $packages;
     }
     foreach ($keys as $method => $key) {
         if (is_numeric($method)) {
             $method = $key;
         }
         $getter = 'get' . ucfirst($method);
         $value = $package->{$getter}();
         if (null !== $value && !(is_array($value) && 0 === count($value))) {
             $data[$key] = $value;
         }
     }
     return $data;
 }
开发者ID:nicodmf,项目名称:composer,代码行数:46,代码来源:ArrayDumper.php

示例9: findRecommendedRequireVersion

 /**
  * Given a concrete version, this returns a ~ constraint (when possible)
  * that should be used, for example, in composer.json.
  *
  * For example:
  *  * 1.2.1         -> ~1.2
  *  * 1.2           -> ~1.2
  *  * v3.2.1        -> ~3.2
  *  * 2.0-beta.1    -> ~2.0@beta
  *  * dev-master    -> ~2.1@dev      (dev version with alias)
  *  * dev-master    -> dev-master    (dev versions are untouched)
  *
  * @param PackageInterface $package
  * @return string
  */
 public function findRecommendedRequireVersion(PackageInterface $package)
 {
     $version = $package->getVersion();
     if (!$package->isDev()) {
         return $this->transformVersion($version, $package->getPrettyVersion(), $package->getStability());
     }
     $loader = new ArrayLoader($this->getParser());
     $dumper = new ArrayDumper();
     $extra = $loader->getBranchAlias($dumper->dump($package));
     if ($extra) {
         $extra = preg_replace('{^(\\d+\\.\\d+\\.\\d+)(\\.9999999)-dev$}', '$1.0', $extra, -1, $count);
         if ($count) {
             $extra = str_replace('.9999999', '.0', $extra);
             return $this->transformVersion($extra, $extra, 'dev');
         }
     }
     return $package->getPrettyVersion();
 }
开发者ID:composer-fork,项目名称:composer,代码行数:33,代码来源:VersionSelector.php

示例10: _validatePackage

 /**
  * @param PackageInterface $package
  *
  * @throws \InvalidArgumentException
  * @return string
  */
 protected function _validatePackage(PackageInterface $package)
 {
     $_packageName = $package->getPrettyName();
     $_parts = explode('/', $_packageName, 2);
     $this->_extra = Option::clean($package->getExtra());
     $this->_config = Option::get($this->_extra, 'config', array());
     $this->_plugIn = static::DSP_PLUGIN_PACKAGE_TYPE == $package->getType();
     //	Only install DreamFactory packages if not a plug-in
     if (static::PACKAGE_PREFIX != ($_vendor = @current($_parts)) && !$this->_plugIn) {
         throw new \InvalidArgumentException('This package is not a DreamFactory package and cannot be installed by this installer.' . PHP_EOL . '  * Name: ' . $_packageName . PHP_EOL . '  * Parts: ' . implode(' / ', $_parts) . PHP_EOL);
     }
     //	Effectively /docRoot/shared/[vendor]/[namespace]/[package]
     Log::debug('Package "' . $_packageName . '" installation type: ' . ($this->_plugIn ? 'Plug-in' : 'Package'));
     $this->_packageName = $_packageName;
     $this->_installPath = $this->_buildInstallPath($_vendor, @end($_parts));
     //	Link path for plug-ins
     $_extra = Option::clean($package->getExtra());
     $this->_linkName = Option::get($_extra, 'link_name', $_parts[1]);
     //	Relative to composer.json... i.e. web/[link_name]
     $this->_linkPath = trim(static::PLUG_IN_LINK_PATH . '/' . $this->_linkName, '/');
     Log::info('Platform Installer Debug > ' . $_packageName . ' > Version ' . $package->getVersion());
     Log::debug('  * Install path: ' . $this->_installPath);
     if ($this->_plugIn) {
         Log::debug('  *    Link name: ' . $this->_linkName);
         Log::debug('  *    Link path: ' . $this->_linkPath);
     }
     return true;
 }
开发者ID:pkdevboxy,项目名称:lib-platform-installer,代码行数:34,代码来源:PlatformInstaller.php

示例11: __toString

 public function __toString()
 {
     return parent::__toString() . ' (alias of ' . $this->aliasOf->getVersion() . ')';
 }
开发者ID:neon64,项目名称:composer,代码行数:4,代码来源:AliasPackage.php

示例12: getLatestVersion

 public function getLatestVersion()
 {
     return $this->latestPackage->getVersion();
 }
开发者ID:mathielen,项目名称:package-manager,代码行数:4,代码来源:InstalledPackage.php

示例13: versionCompare

 public function versionCompare(PackageInterface $a, PackageInterface $b, $operator)
 {
     $constraint = new VersionConstraint($operator, $b->getVersion());
     $version = new VersionConstraint('==', $a->getVersion());
     return $constraint->matchSpecific($version);
 }
开发者ID:nicodmf,项目名称:composer,代码行数:6,代码来源:DefaultPolicy.php

示例14: updateInformation

 private function updateInformation(OutputInterface $output, RegistryInterface $doctrine, $package, PackageInterface $data)
 {
     $em = $doctrine->getEntityManager();
     $version = new Version();
     $version->setName($package->getName());
     $version->setNormalizedVersion(preg_replace('{-dev$}i', '', $data->getVersion()));
     // check if we have that version yet
     foreach ($package->getVersions() as $existingVersion) {
         if ($existingVersion->equals($version)) {
             // avoid updating newer versions, in case two branches have the same version in their composer.json
             if ($existingVersion->getReleasedAt() > $data->getReleaseDate()) {
                 return;
             }
             if ($existingVersion->getDevelopment()) {
                 $version = $existingVersion;
                 break;
             }
             return;
         }
     }
     $version->setVersion($data->getPrettyVersion());
     $version->setDevelopment(substr($data->getVersion(), -4) === '-dev');
     $em->persist($version);
     $version->setDescription($data->getDescription());
     $package->setDescription($data->getDescription());
     $version->setHomepage($data->getHomepage());
     $version->setLicense($data->getLicense() ?: array());
     $version->setPackage($package);
     $version->setUpdatedAt(new \DateTime());
     $version->setReleasedAt($data->getReleaseDate());
     if ($data->getSourceType()) {
         $source['type'] = $data->getSourceType();
         $source['url'] = $data->getSourceUrl();
         $source['reference'] = $data->getSourceReference();
         $version->setSource($source);
     }
     if ($data->getDistType()) {
         $dist['type'] = $data->getDistType();
         $dist['url'] = $data->getDistUrl();
         $dist['reference'] = $data->getDistReference();
         $dist['shasum'] = $data->getDistSha1Checksum();
         $version->setDist($dist);
     }
     if ($data->getType()) {
         $version->setType($data->getType());
         if ($data->getType() && $data->getType() !== $package->getType()) {
             $package->setType($data->getType());
         }
     }
     $version->setTargetDir($data->getTargetDir());
     $version->setAutoload($data->getAutoload());
     $version->setExtra($data->getExtra());
     $version->setBinaries($data->getBinaries());
     $version->getTags()->clear();
     if ($data->getKeywords()) {
         foreach ($data->getKeywords() as $keyword) {
             $version->addTag(Tag::getByName($em, $keyword, true));
         }
     }
     $version->getAuthors()->clear();
     if ($data->getAuthors()) {
         foreach ($data->getAuthors() as $authorData) {
             $author = null;
             // skip authors with no information
             if (empty($authorData['email']) && empty($authorData['name'])) {
                 continue;
             }
             if (!empty($authorData['email'])) {
                 $author = $doctrine->getRepository('PackagistWebBundle:Author')->findOneByEmail($authorData['email']);
             }
             if (!$author && !empty($authorData['homepage'])) {
                 $author = $doctrine->getRepository('PackagistWebBundle:Author')->findOneBy(array('name' => $authorData['name'], 'homepage' => $authorData['homepage']));
             }
             if (!$author && !empty($authorData['name'])) {
                 $author = $doctrine->getRepository('PackagistWebBundle:Author')->findOneByNameAndPackage($authorData['name'], $package);
             }
             if (!$author) {
                 $author = new Author();
                 $em->persist($author);
             }
             foreach (array('email', 'name', 'homepage') as $field) {
                 if (isset($authorData[$field])) {
                     $author->{'set' . $field}($authorData[$field]);
                 }
             }
             $author->setUpdatedAt(new \DateTime());
             if (!$version->getAuthors()->contains($author)) {
                 $version->addAuthor($author);
             }
             if (!$author->getVersions()->contains($version)) {
                 $author->addVersion($version);
             }
         }
     }
     foreach ($this->supportedLinkTypes as $linkType => $linkEntity) {
         $links = array();
         foreach ($data->{'get' . $linkType . 's'}() as $link) {
             $links[$link->getTarget()] = $link->getPrettyConstraint();
         }
         foreach ($version->{'get' . $linkType}() as $link) {
//.........这里部分代码省略.........
开发者ID:nesQuick,项目名称:packagist,代码行数:101,代码来源:UpdatePackagesCommand.php

示例15: find_latest_package

 /**
  * Given a package, this finds the latest package matching it
  *
  * @param  PackageInterface $package
  * @param  Composer         $composer
  * @param  string           $phpVersion
  * @param  bool             $minorOnly
  *
  * @return PackageInterface|null
  */
 private function find_latest_package(PackageInterface $package, Composer $composer, $phpVersion, $minorOnly = false)
 {
     // find the latest version allowed in this pool
     $name = $package->getName();
     $versionSelector = new VersionSelector($this->get_pool($composer));
     $stability = $composer->getPackage()->getMinimumStability();
     $flags = $composer->getPackage()->getStabilityFlags();
     if (isset($flags[$name])) {
         $stability = array_search($flags[$name], BasePackage::$stabilities, true);
     }
     $bestStability = $stability;
     if ($composer->getPackage()->getPreferStable()) {
         $bestStability = $package->getStability();
     }
     $targetVersion = null;
     if (0 === strpos($package->getVersion(), 'dev-')) {
         $targetVersion = $package->getVersion();
     }
     if ($targetVersion === null && $minorOnly) {
         $targetVersion = '^' . $package->getVersion();
     }
     return $versionSelector->findBestCandidate($name, $targetVersion, $phpVersion, $bestStability);
 }
开发者ID:wp-cli,项目名称:wp-cli,代码行数:33,代码来源:package.php


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