public function parsePluginArguments(CommandEvent $event) { $name = $event->getCommandName(); switch ($name) { case 'update': case 'install': $myPrefix = $this->args_getPrefix(); $args = $event->getInput()->getArgument('packages'); $newArgs = []; foreach ($args as $arg) { if (preg_match('/@([\\w\\-]+):([\\w\\-]+)(?:=(\\S+))?/', $arg, $m)) { $m[] = true; list($all, $prefix, $name, $value) = $m; if ($prefix == $myPrefix) { if ($this->args_set($name, $value)) { $this->info($this->args_getFriendlyName($name) . ($value === true ? ": <info>enabled</info>" : ": <info>{$value}</info>")); } else { throw new \RuntimeException("Invalid argument <fg=cyan;bg=red>{$name}</> for plugin <fg=cyan;bg=red>{$prefix}</>"); } } } else { $newArgs[] = $arg; } } if ($newArgs != $args) { $event->getInput()->setArgument('packages', $newArgs); } break; } }
public function onCommand(CommandEvent $event) { $command = $event->getCommandName(); $input = $event->getInput(); $output = $event->getOutput(); if ($command == 'status') { $repos = array(); foreach ($this->composer->getConfig()->getRepositories() as $key => $repository) { if ($repository['type'] == 'vcs') { $protocol = parse_url($repository['url'], PHP_URL_SCHEME); if ($protocol == 'file') { $repos[] = $repository['url']; } } } if (!empty($repos)) { $this->io->write('[composer-plugin-vcschecker: Begin]'); $this->io->write('<error>The following file protocol URLs were detected in the composer.json repositories section:</error>'); $indentedRepos = implode("\n", array_map(function ($line) { return ' ' . ltrim($line); }, $repos)); $this->io->write($indentedRepos); $this->io->write('<error>Please correct the URLs to point to their correct remote location.</error>'); $this->io->write('[composer-plugin-vcschecker: End]'); $this->io->writeError(''); } } }
/** * Command event dispatcher * * @param \Composer\Plugin\CommandEvent $event */ public function onCommand(CommandEvent $event) { switch ($event->getCommandName()) { case 'dump-autoload': $_this = new DumpAutoloadEventHandler($this->__installer->getComposer()->getPackage(), $this->__installer->getComposer()); break; default: break; } }
/** * Disable the package filter for all command, but for install and update command. * * @param CommandEvent $event */ public function onPluginCommand(CommandEvent $event) { if (!in_array($event->getCommandName(), array('install', 'update'))) { $this->packageFilter->setEnabled(false); } }
/** * 플러그인 커맨드를 통해 composer가 실행된 상태인지 조사한다. * * @param CommandEvent $event composer가 제공하는 event * * @return bool */ private static function isUpdateMode(CommandEvent $event) { if ($event->getInput()->hasArgument('packages')) { $packages = $event->getInput()->getArgument('packages'); $packages = array_shift($packages); if ($packages && strpos($packages, 'xpressengine-plugin') === 0) { if (!defined('__XE_PLUGIN_MODE__')) { define('__XE_PLUGIN_MODE__', true); } return true; } } return false; }
/** * actually is triggered before anything got executed * * @param \Composer\Plugin\CommandEvent $event */ public function onCommandEvent(\Composer\Plugin\CommandEvent $event) { $command = $event->getCommandName(); }
/** * Tell everyone we're here. * * @param CommandEvent $e * The event object. */ public function onCommand(CommandEvent $e) { $output = $e->getOutput(); $output->writeln('<info>Using ' . self::PACKAGE_NAME . '</info>'); }
/** * Handle command events. * * @param CommandEvent $event The event being raised. * * @return void * * @throws \RuntimeException When the artifact directory could not be created. */ public function handleCommand(CommandEvent $event) { switch ($event->getCommandName()) { case 'update': ConfigManipulator::run(); break; default: } }
/** * @param CommandEvent $commandEvent * * @throws ComposerNoUpdaterException */ public function checkUpdateCommand(CommandEvent $commandEvent) { $this->commandChecker->setInput($commandEvent->getInput())->validate(); }
/** * 플러그인 커맨드를 통해 composer가 실행된 상태인지 조사한다. * * @param CommandEvent $event composer가 제공하는 event * * @return bool */ private static function isUpdateMode(CommandEvent $event) { if ($event->getInput()->hasArgument('packages')) { $packages = $event->getInput()->getArgument('packages'); $packages = array_shift($packages); return $packages && strpos($packages, 'xpressengine-plugin') === 0; } else { return false; } }