/** * Use this for detecting the org and repo. * * Add the options to decorateDefinition. * * @param ConsoleEvent $event */ public function initialize(ConsoleEvent $event) { $command = $event->getCommand(); if (!$command instanceof InitCommand) { return; } if (!$this->gitHelper->isGitDir()) { throw new UserException(sprintf('You can only run the "%s" command when you are in a Git directory.', $command->getName())); } $input = $event->getInput(); $input->setOption('repo-adapter', GitHelper::undefinedToDefault($input->getOption('repo-adapter'), $this->detectAdapterName())); $input->setOption('issue-adapter', GitHelper::undefinedToDefault($input->getOption('issue-adapter'), $input->getOption('repo-adapter'))); if (!$this->application->getAdapterFactory()->supports($input->getOption('repo-adapter'), AdapterFactory::SUPPORT_REPOSITORY_MANAGER)) { return; } $org = GitHelper::undefinedToDefault($input->getOption('org')); $repo = GitHelper::undefinedToDefault($input->getOption('repo')); if (null === $org || null === $repo) { list($org, $repo) = $this->getRepositoryReference($this->getAdapter($input->getOption('repo-adapter')), $org, $repo); if (!$input->isInteractive()) { $this->styleHelper->note(['You did not provide an organization and/or repository name.', 'Gush automatically detected the missing information.', sprintf('Org: "%s" / repo: "%s"', $org, $repo)]); } $input->setOption('org', $org); $input->setOption('repo', $repo); } $input->setOption('issue-org', GitHelper::undefinedToDefault($input->getOption('issue-org'), $org)); $input->setOption('issue-project', GitHelper::undefinedToDefault($input->getOption('issue-project'), $repo)); }
/** * Fire event * * @return void */ public function __invoke(ConsoleEvent $event) { $output = $event->getOutput(); $output->writeln(''); $output->writeln("Time: " . round(microtime(true) - $this->startTime, 6) . " seg"); $output->writeln(''); }
/** * Fires when user send info to log * * @param ConsoleEvent $event ConsoleEvent instance * * @return void */ public function onConsoleCommandUserInfo(ConsoleEvent $event) { $input = $event->getInput(); $user_info = $input->getParameterOption("user_info"); $command = $event->getCommand(); $container = $command->getApplication()->getContainer(); $container['monolog']->addInfo(sprintf('Command \'%s\' UserInfo: \'%s\'', $command->getName(), $user_info)); }
public function onCommand(ConsoleEvent $event) { $command = $event->getCommand(); if (!$command instanceof ConsumeCommand) { return; } /* @var \Doctrine\DBAL\Connection $db */ $db = $this->container->get('doctrine.dbal.default_connection'); $db->getConfiguration()->setSQLLogger(null); }
/** * Display a warning if a running n98-magerun as root user * * @param ConsoleEvent $event * @return void */ public function checkRunningAsRootUser(ConsoleEvent $event) { $output = $event->getOutput(); if ($output instanceof ConsoleOutput) { $errorOutput = $output->getErrorOutput(); if (OperatingSystem::isLinux() || OperatingSystem::isMacOs()) { if (function_exists('posix_getuid')) { if (posix_getuid() === 0) { $errorOutput->writeln(''); $errorOutput->writeln(self::WARNING_ROOT_USER); $errorOutput->writeln(''); } } } } }
/** * @param ConsoleEvent $event */ public function registerComposer(ConsoleEvent $event) { /* * Inject composer object in composer commands */ $command = $event->getCommand(); if (strstr(get_class($command), 'Composer\\Command\\')) { $io = new ConsoleIO($event->getInput(), $event->getOutput(), $command->getHelperSet()); $contaoRootFolder = $command->getApplication()->getContaoRootFolder(); $configFile = $contaoRootFolder . '/composer.json'; $composer = Factory::create($io, $configFile); \chdir($contaoRootFolder); $command->setComposer($composer); $command->setIO($io); } }
/** * Fire event * * @return void */ public function __invoke(ConsoleEvent $event) { $header = <<<TEXT ____ __ /\\ _`\\ /\\ \\ \\ \\ \\L\\ \\ \\ \\___ ___ __ _ \\ \\ ,__/\\ \\ _ `\\ / __`\\/\\ \\/'\\ \\ \\ \\/ \\ \\ \\ \\ \\/\\ \\L\\ \\/> </ \\ \\_\\ \\ \\_\\ \\_\\ \\____//\\_/\\_\\ \\/_/ \\/_/\\/_/\\/___/ \\//\\/_/ TEXT; $output = $event->getOutput(); $output->writeln($header); }
public function report(ConsoleEvent $event, $eventName, EventDispatcherInterface $dispatcher) { $output = $event->getOutput(); if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) { $stat = ServiceCallsStatistics::getCalls(); $tableFormatter = new Table($output); $tableFormatter->setHeaders(['Class Name', 'Api Path', 'Parameters']); foreach ($stat as $row) { $tableFormatter->addRow([$row[0], $row[0]::API_METHOD, json_encode($row[1])]); } $tableFormatter->render(); if ($dispatcher instanceof TraceableEventDispatcher) { print_r($dispatcher->getCalledListeners()); } } $event->stopPropagation(); }
/** * Fire event * * @return void */ public function __invoke(ConsoleEvent $event) { $output = $event->getOutput(); $output->writeln("<comment>Dependencies validation:</comment>"); $output->write(str_pad("Phar extension is loaded?", 30, '.')); $error = false; if (!extension_loaded('phar')) { $output->writeln('<error>NOK</error>'); $error = true; } else { $output->writeln('<info>OK</info>'); } $output->write(str_pad("phar.readonly is On?", 30, '.')); if (!\Phar::canWrite()) { $output->writeln('<error>NOK</error>'); $error = true; } else { $output->writeln('<info>OK</info>'); } if ($error) { exit(1); } }
public function __construct(Command $command, InputInterface $input, OutputInterface $output, \Exception $exception, $exitCode) { parent::__construct($command, $input, $output); $this->setException($exception); $this->exitCode = (int) $exitCode; }
public function __construct(Command $command, InputInterface $input, OutputInterface $output, $exitCode) { parent::__construct($command, $input, $output); $this->setExitCode($exitCode); }
/** * Flush cache manager when console terminates or errors * * @throws ExceptionCollection If an exception occurs during flush. */ public function onConsoleTerminate(ConsoleEvent $event) { $num = $this->cacheManager->flush(); if ($num > 0 && OutputInterface::VERBOSITY_VERBOSE <= $event->getOutput()->getVerbosity()) { $event->getOutput()->writeln(sprintf('Sent %d invalidation request(s)', $num)); } }
/** * @param ConsoleEvent $event * @return bool */ protected function isProcessingRequired(ConsoleEvent $event) { return $event->getCommand() instanceof LoadDataFixturesCommand && $event->getInput()->hasOption('fixtures-type') && $event->getInput()->getOption('fixtures-type') == LoadDataFixturesCommand::DEMO_FIXTURES_TYPE; }
/** * Constructor. * * @param Command $command * @param InputInterface $input * @param OutputInterface $output * @param array $chain All members of this chain. */ public function __construct(Command $command, InputInterface $input, OutputInterface $output, array $chain) { parent::__construct($command, $input, $output); $this->chain = $chain; }