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


PHP Composer::getPackage方法代码示例

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


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

示例1: resolveFeatureBranch

 public function resolveFeatureBranch(Event $event)
 {
     if (empty($this->featureBranchRepositories)) {
         $this->io->write('No feature branches configured, continuing!');
         return;
     }
     $package = $this->composer->getPackage();
     if ($package->isDev()) {
         $featureBranchConstraint = new Constraint('=', $this->versionParser->normalize($package->getVersion()));
         $featureBranchConstraint->setPrettyString($package->getVersion());
         $requires = $package->getRequires();
         $this->io->write(sprintf("<info>Checking for feature branch '%s'</info>", $featureBranchConstraint->getPrettyString()));
         foreach ($requires as $key => $require) {
             if ($this->hasFeatureBranch($require, $featureBranchConstraint)) {
                 $requires[$key] = new Link($require->getSource(), $require->getTarget(), $featureBranchConstraint, 'requires', $featureBranchConstraint->getPrettyString());
             } else {
                 $fallbackBranch = $this->getFallbackBranch($require);
                 if ($fallbackBranch !== false) {
                     $fallbackConstraint = new Constraint('=', $this->versionParser->normalize($fallbackBranch));
                     $fallbackConstraint->setPrettyString($fallbackBranch);
                     $requires[$key] = new Link($require->getSource(), $require->getTarget(), $fallbackConstraint, 'requires', $fallbackConstraint->getPrettyString());
                 }
             }
             $this->io->write('');
         }
         $package->setRequires($requires);
     }
 }
开发者ID:crusepartnership,项目名称:feature-branch-plugin,代码行数:28,代码来源:FeatureBranchPlugin.php

示例2: getPackageInstallPath

 public static function getPackageInstallPath(PackageInterface $package, Composer $composer)
 {
     $prettyName = $package->getPrettyName();
     if (strpos($prettyName, '/') !== false) {
         list($vendor, $name) = explode('/', $prettyName);
     } else {
         $vendor = '';
         $name = $prettyName;
     }
     $availableVars = compact('name', 'vendor');
     $extra = $package->getExtra();
     if (!empty($extra['installer-name'])) {
         $availableVars['name'] = $extra['installer-name'];
     }
     if ($composer->getPackage()) {
         $extra = $composer->getPackage()->getExtra();
         if (!empty($extra['installer-paths'])) {
             $customPath = self::mapCustomInstallPaths($extra['installer-paths'], $prettyName);
             if (false !== $customPath) {
                 return self::templatePath($customPath, $availableVars);
             }
         }
     }
     return NULL;
 }
开发者ID:mnsami,项目名称:composer-custom-directory-installer,代码行数:25,代码来源:PackageUtils.php

示例3: onPostUpdate

 public function onPostUpdate(Event $event)
 {
     $requires = [];
     $overrides = [];
     $resolutions = [];
     if ($event->isDevMode()) {
         $extra = $this->composer->getPackage()->getExtra();
         $bower = isset($extra['bower']) ? $extra['bower'] : [];
         if (isset($bower['require-dev'])) {
             $requires = $this->_mergeDependencyVersions($requires, $bower['require-dev']);
         }
     }
     $packages = [$this->composer->getPackage()];
     $packages = array_merge($packages, $this->composer->getRepositoryManager()->getLocalRepository()->getCanonicalPackages());
     foreach ($packages as $package) {
         if ($package instanceof CompletePackage) {
             $extra = $package->getExtra();
             $bower = isset($extra['bower']) ? $extra['bower'] : [];
             if (isset($bower['require'])) {
                 $requires = $this->_mergeDependencyVersions($requires, $bower['require']);
             }
             if (isset($bower['overrides'])) {
                 $overrides = array_merge_recursive($overrides, $bower['overrides']);
             }
             if (isset($bower['resolutions'])) {
                 $resolutions = $bower['resolutions'];
             }
         }
     }
     if (!$requires) {
         $this->info("No Bower packages are required by the application or by any installed Composer package");
     }
     $dependencies = $this->_installBower($requires, $overrides, $resolutions);
     $this->info((count($dependencies) ?: "No") . " bower packages are installed");
 }
开发者ID:php-kit,项目名称:composer-bower-plugin,代码行数:35,代码来源:Plugin.php

示例4: getConsoleCommands

 public static function getConsoleCommands(Composer $composer)
 {
     $commands = array(array('yiic', 'migrate'));
     if ($composer->getPackage()) {
         $extra = $composer->getPackage()->getExtra();
         if (!empty($extra['yiicomposer-console-commands'])) {
             $tmp = $extra['yiicomposer-console-commands'];
         }
         if (!empty($tmp)) {
             $commands = array();
             foreach ($tmp as $c) {
                 $command = array();
                 $command[] = 'yiic';
                 $command[] = $c['controller'];
                 if (!empty($c['action'])) {
                     $command[] = $c['action'];
                 }
                 if (!empty($c['params'])) {
                     $command = array_merge($command, $c['params']);
                 }
                 if (!empty($c['params'])) {
                     foreach ($c['params'] as $k => $v) {
                         $command[] = '--' . $k . '=' . $v;
                     }
                 }
                 $commands[] = $command;
             }
         }
     }
     return $commands;
 }
开发者ID:mihaildev,项目名称:yiicomposer,代码行数:31,代码来源:Console.php

示例5: __construct

 public function __construct(PackageInterface $package = null, Composer $composer = null, IOInterface $io = null)
 {
     if (null === $package) {
         $package = $composer->getPackage();
     }
     $extraOxidRoot = $extraModuleVendor = false;
     if (null !== $package) {
         $extra = $package->getExtra();
         if (isset($extra['oxid-root'])) {
             foreach ($this->locations as $name => $location) {
                 $this->locations[$name] = "{$extra['oxid-root']}/{$location}";
             }
             $extraOxidRoot = true;
         }
         if (isset($extra['module-vendor'])) {
             $this->locations['module'] = str_replace('modules/', "modules/{$extra['module-vendor']}/", $this->locations['module']);
             $extraModuleVendor = true;
         }
     }
     $composerPackage = $composer->getPackage();
     if (null !== $composerPackage) {
         $extra = $composerPackage->getExtra();
         if (isset($extra['oxid-root']) && !$extraOxidRoot) {
             foreach ($this->locations as $name => $location) {
                 $this->locations[$name] = "{$extra['oxid-root']}/{$location}";
             }
         }
         if (isset($extra['module-vendor']) && !$extraModuleVendor) {
             $this->locations['module'] = str_replace('modules/', "modules/{$extra['module-vendor']}/", $this->locations['module']);
         }
     }
     parent::__construct($package, $composer, $io);
 }
开发者ID:kyoya-de,项目名称:installers,代码行数:33,代码来源:OxidInstaller.php

示例6: activate

 public function activate(Composer $composer, IOInterface $io)
 {
     $config = json_decode(file_get_contents(getcwd() . '/composer.json'), true);
     if (!in_array('--no-dev', $_SERVER['argv']) && isset($config['scripts-dev'])) {
         $scripts = array_merge_recursive($composer->getPackage()->getScripts(), $config['scripts-dev']);
         $composer->getPackage()->setScripts($scripts);
     }
 }
开发者ID:neronmoon,项目名称:scriptsdev,代码行数:8,代码来源:Plugin.php

示例7: dumpFiles

 public function dumpFiles()
 {
     $extraConfig = $this->composer->getPackage()->getExtra();
     if (!array_key_exists('include_files', $extraConfig) || !is_array($extraConfig['include_files'])) {
         return;
     }
     $this->generator->dumpFiles($this->composer, $extraConfig['include_files']);
 }
开发者ID:funkjedi,项目名称:composer-include-files,代码行数:8,代码来源:Plugin.php

示例8: activate

 public function activate(Composer $composer, IOInterface $io)
 {
     $this->composer = $composer;
     $this->io = $io;
     $extra = $this->composer->getPackage()->getExtra();
     if (isset($extra['composer-constant-prefix'])) {
         $this->constantPrefix = $extra['composer-constant-prefix'];
     }
 }
开发者ID:bangpound,项目名称:composer-constants,代码行数:9,代码来源:ConstantsPlugin.php

示例9: runWith

 protected function runWith($expected, $extra)
 {
     $mapSources = new \ReflectionMethod($this->installerStub, 'getSourcesSpec');
     $mapSources->setAccessible(true);
     /** @var RootPackage $package */
     $package = clone $this->composer->getPackage();
     $package->setExtra($extra);
     $this->assertEquals($expected, $mapSources->invokeArgs($this->installerStub, array($package)));
 }
开发者ID:Jobu,项目名称:core,代码行数:9,代码来源:GetSourcesSpecTest.php

示例10: registerLoader

 private function registerLoader()
 {
     $package = $this->composer->getPackage();
     $generator = $this->composer->getAutoloadGenerator();
     $packages = $this->composer->getRepositoryManager()->getLocalRepository()->getCanonicalPackages();
     $packageMap = $generator->buildPackageMap($this->composer->getInstallationManager(), $package, $packages);
     $map = $generator->parseAutoloads($packageMap, $package);
     $this->loader = $generator->createLoader($map);
     $this->loader->register();
 }
开发者ID:helhum,项目名称:typo3-console-plugin,代码行数:10,代码来源:ScriptDispatcher.php

示例11: runGruntTasks

 public function runGruntTasks(Composer $composer, $isDevMode = null)
 {
     $isDevMode = (bool) $isDevMode;
     $this->io()->write('<info>Running Grunt tasks for root project</info>');
     if ($this->isDependantPackage($composer->getPackage(), $isDevMode)) {
         $this->client()->runTask($this->getTask($composer->getPackage()));
     } else {
         $this->io()->write('Nothing to grunt');
     }
     $this->installForVendors($composer);
 }
开发者ID:johnpbloch,项目名称:composer-grunt-bridge,代码行数:11,代码来源:GruntBridge.php

示例12: getYiiPaths

 public static function getYiiPaths(Composer $composer)
 {
     $yiiPaths = array('module' => '{vendor}' . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . '{name}', 'extension' => '{vendor}' . DIRECTORY_SEPARATOR . 'extensions' . DIRECTORY_SEPARATOR . '{name}', 'framework' => '{vendor}' . DIRECTORY_SEPARATOR . 'framework', 'yiisoft/yii' => '$framework$');
     if ($composer->getPackage()) {
         $extra = $composer->getPackage()->getExtra();
         if (!empty($extra['yiicomposer-paths'])) {
             $yiiPaths = array_merge($yiiPaths, $extra['yiicomposer-paths']);
         }
     }
     return $yiiPaths;
 }
开发者ID:mihaildev,项目名称:yiicomposer,代码行数:11,代码来源:Installer.php

示例13: start

 public function start(Event $e)
 {
     $package = $this->composer->getPackage();
     $fetches = array_merge($this->getFetchesInExtra($package, self::EXTRA_KEY), $this->findFetchesInRequire($package));
     $this->baseDir = $this->determineBaseDir($fetches, self::DEFAULT_BASE_DIR);
     $this->targets = $this->processFetches($package, $fetches);
     if ($e->isDevMode()) {
         $devFetches = array_merge($this->getFetchesInExtra($package, self::EXTRA_KEY_DEV), $this->findFetchesInRequireDev($package));
         $this->baseDirDev = $this->determineBaseDir($devFetches, self::DEFAULT_BASE_DIR_DEV);
         $this->targetsDev = $this->processFetches($package, $devFetches);
     }
 }
开发者ID:rtens,项目名称:fido,代码行数:12,代码来源:FidoPlugin.php

示例14: activate

 /**
  * {@inheritdoc}
  *
  * @throws \InvalidArgumentException
  * @throws \RuntimeException
  */
 public function activate(Composer $composer, IOInterface $io)
 {
     $this->composer = $composer;
     $this->io = $io;
     $this->config = $config = new Config\PluginConfig((array) $composer->getConfig()->get(self::CONFIG_KEY));
     $this->cleaner = $config->isDebug() ? new FakeCleaner($io) : $config->getCleaner();
     $this->matcher = $config->getMatcher();
     $this->normalizer = $config->getNormalizer();
     if (($extra = $this->composer->getPackage()->getExtra()) && isset($extra[self::EXTRA_KEY])) {
         $this->devFiles = $this->normalizer->normalize((array) $extra[self::EXTRA_KEY]);
     }
 }
开发者ID:octolab,项目名称:cleaner,代码行数:18,代码来源:Plugin.php

示例15: onPostUpdate

 public function onPostUpdate(Event $event)
 {
     // Load global plugin configuration
     $globalCfg = $this->getGlobalConfig();
     if ($globalCfg) {
         $extra = self::get($globalCfg, 'extra', []);
         $myConfig = self::get($extra, self::EXTRA_KEY, []);
         if ($myConfig) {
             $this->info("Global configuration loaded");
         }
     } else {
         $myConfig = [];
     }
     // Merge project-specific configuration.
     // Ignore it if Composer is running in global mode.
     $package = $this->composer->getPackage();
     if ($package->getName() != '__root__') {
         $projCfg = self::get($package->getExtra(), self::EXTRA_KEY, []);
         $myConfig = array_merge_recursive($myConfig, $projCfg);
         $this->info("Project-specific configuration loaded");
     }
     // Setup
     $rules = array_unique(self::get($myConfig, self::RULES_KEY, []));
     $sharedDir = str_replace('~', getenv('HOME'), self::get($myConfig, self::SHARED_DIR_KEY, self::DEFAULT_SHARED_DIR));
     $packages = $this->composer->getRepositoryManager()->getLocalRepository()->getCanonicalPackages();
     $rulesInfo = implode(', ', $rules);
     $this->info("Shared directory: <info>{$sharedDir}</info>");
     $this->info("Match packages: <info>{$rulesInfo}</info>");
     $fsUtil = new FilesystemUtil();
     $fs = new Filesystem();
     // Do useful work
     $count = 0;
     foreach ($packages as $package) {
         $srcDir = $this->getInstallPath($package);
         $packageName = $package->getName();
         if (self::globMatchAny($rules, $packageName) && !$fsUtil->isSymlinkedDirectory($srcDir)) {
             $destPath = "{$sharedDir}/{$packageName}";
             if (!file_exists($destPath)) {
                 $fsUtil->copyThenRemove($srcDir, $destPath);
                 $this->info("Moved <info>{$packageName}</info> to shared directory and symlinked to it");
             } else {
                 $fs->remove($srcDir);
                 $this->info("Symlinked to existing <info>{$packageName}</info> on shared directory");
             }
             $fs->symlink($destPath, $srcDir);
             ++$count;
         }
     }
     if (!$count) {
         $this->info("No packages matched");
     }
 }
开发者ID:php-kit,项目名称:composer-shared-packages-plugin,代码行数:52,代码来源:Plugin.php


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