/** * 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)); }
/** * 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)); }
/** * @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); } }
/** * @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; }