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); } }
/** * actually is triggered before anything got executed * * @param \Composer\Plugin\CommandEvent $event */ public function onCommandEvent(\Composer\Plugin\CommandEvent $event) { $command = $event->getCommandName(); }
/** * 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: } }