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


PHP CommandEvent::getComposer方法代码示例

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


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

示例1: __construct

 protected function __construct(CommandEvent $event)
 {
     $this->composerEvent = $event;
     $this->io = $this->composerEvent->getIO();
     $this->extras = $this->composerEvent->getComposer()->getPackage()->getExtra();
     $this->fs = new Filesystem();
 }
开发者ID:opencontent,项目名称:opencontent-project-installer,代码行数:7,代码来源:ScriptHandler.php

示例2: getOptions

 protected static function getOptions(CommandEvent $event)
 {
     $options = array_merge(array('symfony-app-dir' => 'app', 'symfony-web-dir' => 'web', 'symfony-assets-install' => 'hard'), $event->getComposer()->getPackage()->getExtra());
     $options['symfony-assets-install'] = getenv('SYMFONY_ASSETS_INSTALL') ?: $options['symfony-assets-install'];
     $options['process-timeout'] = $event->getComposer()->getConfig()->get('process-timeout');
     return $options;
 }
开发者ID:jmsteinmetz,项目名称:Dime,代码行数:7,代码来源:ScriptHandler.php

示例3: copyBootstrapFiles

 /**
  * Checks for the twitter/bootstrap package and copys all necessary files into the specified directory.
  *
  * Where the files are copied into must be specified in the extra section in the project's `composer.json`.
  *
  * 		"extra": {
  * 			"bootstrap-public-dir": "src/Acme/MyBundle/Resources/public",
  * 			...
  * 		}
  *
  * @param CommandEvent $event
  */
 public static function copyBootstrapFiles(CommandEvent $event)
 {
     /** @var RootPackage $package */
     $package = $event->getComposer()->getPackage();
     /** @var Link[] $requires */
     $requires = $package->getRequires();
     // Show error if package was not found
     if (!in_array(self::$bootstrapPackageKey, array_keys($requires))) {
         echo PHP_EOL . "\tError: Could not find the Twitter Bootstrap package \"twitter/bootstrap\"." . PHP_EOL . PHP_EOL;
         return;
     }
     $fs = new Filesystem();
     // Check for package path
     $packagePath = static::_getPackagePath($event->getComposer());
     if (is_null($packagePath) or !$fs->exists($packagePath)) {
         echo PHP_EOL . "\tError: The twitter bootstrap package doesn't seem to be installed." . PHP_EOL . PHP_EOL;
         return;
     }
     $bootstrapPath = $packagePath . '/dist/';
     // Check the public path where it should be copied to
     $extra = $package->getExtra();
     if (!isset($extra['bootstrap-public-dir']) or !$fs->exists($extra['bootstrap-public-dir'])) {
         echo PHP_EOL . "\tError: Given bootstrap public directory doesn't exist: " . $extra['bootstrap-public-dir'] . PHP_EOL . PHP_EOL;
         return;
     }
     $bootstrapPublicPath = $extra['bootstrap-public-dir'];
     echo sprintf('Installing twitter bootstrap files into %s%s', $bootstrapPublicPath, PHP_EOL);
     $files = array('js/bootstrap.js', 'js/bootstrap.min.js', 'fonts/glyphicons-halflings-regular.eot', 'fonts/glyphicons-halflings-regular.svg', 'fonts/glyphicons-halflings-regular.ttf', 'fonts/glyphicons-halflings-regular.woff');
     foreach ($files as $file) {
         $fs->copy($bootstrapPath . $file, $bootstrapPublicPath . '/' . $file, true);
     }
 }
开发者ID:holloway87,项目名称:hw-basics-bundle,代码行数:44,代码来源:ScriptHandler.php

示例4: exec

 public static function exec(CommandEvent $event)
 {
     $composer = $event->getComposer();
     $installManager = $composer->getInstallationManager();
     $repoManager = $composer->getRepositoryManager();
     $packages = $repoManager->getLocalRepository()->getPackages();
     foreach ($packages as $package) {
         $path = $installManager->getInstallPath($package);
         $extra = $package->getExtra();
         if (array_key_exists('clean', $extra)) {
             // we have things to remove, try to take them out
             foreach ($extra['clean'] as $remove) {
                 $resolvePath = realpath($path . '/' . $remove);
                 if ($resolvePath !== false) {
                     if (is_dir($resolvePath)) {
                         self::unlinkDirectory($resolvePath);
                         // rmdir($resolvePath);
                     } elseif (is_file($resolvePath)) {
                         // unlink($resolvePath);
                         self::unlinkFile($resolvePath);
                     }
                 }
             }
         }
     }
 }
开发者ID:enygma,项目名称:composerclean,代码行数:26,代码来源:Clean.php

示例5: onPostInstallCMD

 /**
  * Listener to the POST_INSTALL_CMD, POST_UPDATE_CMD and POST_CREATE_PROJECT_CMD events
  * It contains the code that launch the execution of the finalize precedures
  *
  * @param  \Composer\Script\CommandEvent $event Event to handle
  *
  */
 public function onPostInstallCMD(CommandEvent $event)
 {
     $packages = $event->getComposer()->getRepositoryManager()->getLocalRepository()->getPackages();
     foreach ($packages as $package) {
         $this->onEventHandler($package, "finalize");
     }
     $this->doRetry();
 }
开发者ID:comodojo,项目名称:composer-events-handler,代码行数:15,代码来源:EventsListener.php

示例6: getConfigs

 protected static function getConfigs(CommandEvent $event)
 {
     $extras = array_merge(array('app-version-key' => 'version_number'), $event->getComposer()->getPackage()->getExtra());
     if (!isset($extras['incenteev-parameters'])) {
         throw new \InvalidArgumentException('The parameter handler needs to be configured through the extra.incenteev-parameters setting.');
     }
     $configs = $extras['incenteev-parameters'];
     return $configs;
 }
开发者ID:hkmshb,项目名称:OpitHrm,代码行数:9,代码来源:ScriptHandler.php

示例7: buildPathFromBase

 /**
  * Build a directory path starting on the project base
  *
  * @param CommandEvent $event
  * @param string       $directory
  */
 private static function buildPathFromBase(CommandEvent $event, $directory)
 {
     /** @var Package $package */
     $package = $event->getComposer()->getPackage();
     $extra = $package->getExtra();
     // Generate the complete path.
     $basePath = getcwd();
     $path = array_key_exists($directory, $extra) ? $extra[$directory] : self::$options[$directory];
     $completePath = sprintf('%s/%s', $basePath, $path);
     // Set values.
     self::$options[self::CONSOLE_APPLICATION_BASE_DIR] = $basePath;
     self::$options[$directory] = $completePath;
 }
开发者ID:ebidtech,项目名称:console-application,代码行数:19,代码来源:ScriptHandler.php

示例8: executeCommand

 protected static function executeCommand(CommandEvent $event, $cmd, $timeout = 300)
 {
     $extra = $event->getComposer()->getPackage()->getExtra();
     $binDir = $extra['sb-bin-dir'];
     if (!is_dir($binDir)) {
         echo 'The sb-bin-dir (' . $binDir . ') specified in composer.json was not found in ' . getcwd() . ', can not clear the cache.' . PHP_EOL;
         return;
     }
     $php = escapeshellarg(self::getPhp());
     $console = escapeshellarg($binDir . '/sb');
     if ($event->getIO()->isDecorated()) {
         $console .= ' --ansi';
     }
     $process = new Process($php . ' ' . $console . ' ' . $cmd, null, null, null, $timeout);
     $process->run(function ($type, $buffer) {
         echo $buffer;
     });
     if (!$process->isSuccessful()) {
         throw new \RuntimeException(sprintf('An error occurred when executing the "%s" command.', escapeshellarg($cmd)));
     }
 }
开发者ID:dongww,项目名称:silex-base,代码行数:21,代码来源:ScriptHandler.php

示例9: initTestsSkeleton

 /**
  * Sets the correct skeleton for the unit tests.
  * @param CommandEvent $event
  */
 public static function initTestsSkeleton($event)
 {
     $options = $event->getComposer()->getPackage()->getExtra();
     if (!isset($options[self::EXTRA_SKELETON], $options[self::EXTRA_SKELETON]['path'])) {
         $path = 'tests/js';
     } else {
         $path = $options[self::EXTRA_SKELETON]['path'];
     }
     $path = getcwd() . DIRECTORY_SEPARATOR . $path;
     echo "Setting init tests skeleton: {$path} ...\n";
     if (!file_exists($path)) {
         if (FileHelper::createDirectory($path)) {
             FileHelper::copyDirectory(self::getSourceSkeletonPath(), $path);
             echo "done\n";
         } else {
             echo "The directory was not found: " . $path . "\n";
         }
     } else {
         echo "{$path} directory is exists\n";
         return;
     }
 }
开发者ID:dizews,项目名称:yii2-qunit,代码行数:26,代码来源:Installer.php

示例10: siteIniUpdate

 /**
  * Deploy a proper settings/override/site.ini using settings/override/site.ini.dist as a template
  * Only main DB parameters (Host,Port,User,Password,Database) are replaced using the Symfony parameters
  *
  * @param $event CommandEvent A instance
  */
 public static function siteIniUpdate(CommandEvent $event)
 {
     $extras = $event->getComposer()->getPackage()->getExtra();
     if (!isset($extras['ezpublish-legacy-utility'])) {
         throw new \InvalidArgumentException('The eZ Publish Utility handler needs to be configured through the extra.ezpublish-legacy-utility setting.');
     }
     $configs = $extras['ezpublish-legacy-utility'];
     $yamlParser = new Parser();
     $parameters = $yamlParser->parse(file_get_contents($configs['parameters-file']));
     file_put_contents($configs['legacy-site_ini'], file_get_contents($configs['legacy-site_ini-dist']));
     $siteIniArray = file($configs['legacy-site_ini']);
     $dbSection = false;
     $siteIniUpdated = array();
     foreach ($siteIniArray as $siteIniRow) {
         $siteIniRow = trim($siteIniRow);
         if (substr($siteIniRow, 0, 1) === '[') {
             if ($siteIniRow === "[DatabaseSettings]") {
                 $dbSection = true;
             } else {
                 $dbSection = false;
             }
         }
         if ($dbSection) {
             if (strstr($siteIniRow, '=', true) != false) {
                 $key = strstr($siteIniRow, '=', true);
                 if (array_key_exists($key, $configs['parameters-map'])) {
                     $siteIniRow = $key . "=" . $parameters['parameters'][$configs['parameters-map'][$key]];
                 }
             }
         }
         $siteIniUpdated[] = $siteIniRow;
     }
     file_put_contents($configs['legacy-site_ini'], "");
     foreach ($siteIniUpdated as $siteIniUpdatedRow) {
         file_put_contents($configs['legacy-site_ini'], $siteIniUpdatedRow . "\n", FILE_APPEND);
     }
 }
开发者ID:guglielmobossi,项目名称:EzPublishLegacyUtilityBundle,代码行数:43,代码来源:ScriptHandler.php

示例11: setPermission

 /**
  * Sets the correct permission for the files and directories listed in the extra section.
  * @param CommandEvent $event
  */
 public static function setPermission($event)
 {
     $options = array_merge([self::EXTRA_WRITABLE => [], self::EXTRA_EXECUTABLE => []], $event->getComposer()->getPackage()->getExtra());
     foreach ((array) $options[self::EXTRA_WRITABLE] as $path) {
         echo "Setting writable: {$path} ...";
         if (is_dir($path)) {
             chmod($path, 0777);
             echo "done\n";
         } else {
             echo "The directory was not found: " . getcwd() . DIRECTORY_SEPARATOR . $path;
             return;
         }
     }
     foreach ((array) $options[self::EXTRA_EXECUTABLE] as $path) {
         echo "Setting executable: {$path} ...";
         if (is_file($path)) {
             chmod($path, 0755);
             echo "done\n";
         } else {
             echo "\n\tThe file was not found: " . getcwd() . DIRECTORY_SEPARATOR . $path . "\n";
             return;
         }
     }
 }
开发者ID:getherbie,项目名称:composer,代码行数:28,代码来源:Installer.php

示例12: postInstall

 /**
  * Updates the Puli repository after Composer installations/updates.
  *
  * @param CommandEvent $event The Composer event.
  */
 public function postInstall(CommandEvent $event)
 {
     // Plugin has been uninstalled
     if (!file_exists(__FILE__)) {
         return;
     }
     if (!$this->initialized) {
         $this->initialize($event->getComposer(), $event->getIO());
     }
     // This method is called twice. Run it only once.
     if (!$this->runPostInstall) {
         return;
     }
     $this->runPostInstall = false;
     $io = $event->getIO();
     $io->write('<info>Looking for updated Puli packages</info>');
     $rootPackage = $event->getComposer()->getPackage();
     $composerPackages = $this->loadComposerPackages($event->getComposer());
     $prodPackageNames = $this->filterProdPackageNames($composerPackages, $rootPackage);
     $env = $event->isDevMode() ? PuliPackage::ENV_DEV : PuliPackage::ENV_PROD;
     try {
         $puliPackages = $this->loadPuliPackages();
     } catch (PuliRunnerException $e) {
         $this->printWarning($io, 'Could not load Puli packages', $e);
         return;
     }
     // Don't remove non-existing packages in production environment
     // Removed packages could be dev dependencies (i.e. "require-dev"
     // of the root package or "require" of another dev dependency), and
     // we can't find out whether they are since Composer doesn't load them
     if (PuliPackage::ENV_PROD !== $env) {
         $this->removeRemovedPackages($composerPackages, $puliPackages, $io);
     }
     $this->installNewPackages($composerPackages, $prodPackageNames, $puliPackages, $io, $event->getComposer());
     // Don't print warnings for non-existing packages in production
     if (PuliPackage::ENV_PROD !== $env) {
         $this->checkForNotFoundErrors($puliPackages, $io);
     }
     $this->checkForNotLoadableErrors($puliPackages, $io);
     $this->adoptComposerName($puliPackages, $io, $event->getComposer());
     $this->buildPuli($io);
 }
开发者ID:issei-m,项目名称:composer-plugin,代码行数:47,代码来源:PuliPlugin.php

示例13: hookRootPackageInstall

 public static function hookRootPackageInstall(CommandEvent $event)
 {
     $event->getComposer()->getEventDispatcher()->addSubscriber(new InstallationHelper());
 }
开发者ID:d4rk4ng3l,项目名称:aom,代码行数:4,代码来源:Composer.php

示例14: loadConfiguration

 protected static function loadConfiguration(CommandEvent $event)
 {
     $composerConfiguration = $event->getComposer()->getPackage()->getExtra();
     return static::getOptions(isset($composerConfiguration['cqt-parameters']) ? $composerConfiguration['cqt-parameters'] : []);
 }
开发者ID:EHLOVader,项目名称:CodeQualityThreshold,代码行数:5,代码来源:ScriptHandler.php

示例15: getOptions

 /**
  * Get a default set of options.
  *
  * @param CommandEvent $event
  *
  * @return array
  */
 protected static function getOptions(CommandEvent $event)
 {
     $options = array_merge(array('bolt-separate-web-dir' => true, 'bolt-web-dir' => 'public', 'bolt-app-dir' => 'app', 'bolt-dir-mode' => 0777), $event->getComposer()->getPackage()->getExtra());
     return $options;
 }
开发者ID:OPARQUE,项目名称:Congresso-Anpcont,代码行数:12,代码来源:ScriptHandler.php


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