/** * @param ConsoleTerminateEvent $event */ public function onConsoleTerminate(ConsoleTerminateEvent $event) { if ($event->getCommand() instanceof UpdateSchemaDoctrineCommand) { $output = $event->getOutput(); $input = $event->getInput(); if ($input->getOption('force')) { $result = $this->fulltextIndexManager->createIndexes(); $output->writeln('Schema update and create index completed.'); if ($result) { $output->writeln('Indexes were created.'); } } } if ($event->getCommand() instanceof UpdateSchemaCommand) { $entities = $this->registry->getRepository('OroSearchBundle:UpdateEntity')->findAll(); if (count($entities)) { $em = $this->registry->getManager(); foreach ($entities as $entity) { $job = new Job(ReindexCommand::COMMAND_NAME, ['class' => $entity->getEntity()]); $em->persist($job); $em->remove($entity); } $em->flush($job); } } }
/** * Log Abnormal exists for AcmPhp commands. * * @param ConsoleTerminateEvent $event */ public function onConsoleTerminate(ConsoleTerminateEvent $event) { if (0 === ($exitCode = $event->getExitCode())) { return; } if (!$this->isAcmePhpCommand($event->getCommand())) { return; } $this->logger->error('Command "{command}" exited with code "{exitCode}".', ['command' => $event->getCommand()->getName(), 'exitCode' => $exitCode]); }
/** * @param ConsoleTerminateEvent $event */ public function callCommands(ConsoleTerminateEvent $event) { /** * @var \Drupal\Console\Command\Command $command */ $command = $event->getCommand(); $output = $event->getOutput(); if (!$command instanceof Command) { return; } $application = $command->getApplication(); $commands = $application->getChain()->getCommands(); if (!$commands) { return; } foreach ($commands as $chainedCommand) { if ($chainedCommand['name'] == 'module:install') { $messageHelper = $application->getMessageHelper(); $translatorHelper = $application->getTranslator(); $messageHelper->addErrorMessage($translatorHelper->trans('commands.chain.messages.module_install')); continue; } $callCommand = $application->find($chainedCommand['name']); $input = new ArrayInput($chainedCommand['inputs']); if (!is_null($chainedCommand['interactive'])) { $input->setInteractive($chainedCommand['interactive']); } $callCommand->run($input, $output); } }
/** * @param ConsoleTerminateEvent $event */ public function showCompletedMessage(ConsoleTerminateEvent $event) { /** * @var \Drupal\AppConsole\Command\Command $command */ $command = $event->getCommand(); $output = $event->getOutput(); $application = $command->getApplication(); $messageHelper = $application->getHelperSet()->get('message'); /* @var TranslatorHelper */ $translatorHelper = $application->getHelperSet()->get('translator'); $messageHelper->showMessages($output); if ($event->getExitCode() != 0) { return; } if (in_array($command->getName(), $this->skipCommands)) { return; } $completedMessageKey = 'application.console.messages.completed'; if ($command instanceof GeneratorCommand) { $completedMessageKey = 'application.console.messages.generated.completed'; } $completedMessage = $translatorHelper->trans($completedMessageKey); if ($completedMessage != $completedMessageKey) { $messageHelper->showMessage($output, $completedMessage); } }
public function onConsoleTerminate(ConsoleTerminateEvent $event) { $command = $event->getCommand(); $input = $event->getInput(); if ('rabbitmq:consumer' === $command->getName() && $this->consumerName === $input->getArgument('name')) { $this->om->flush(); } }
/** * @param ConsoleTerminateEvent $event */ public function onConsoleTerminate(ConsoleTerminateEvent $event) { if ('check' == $event->getCommand()->getName()) { $stopEvent = $this->stopwatch->stop('check_command'); $output = $event->getOutput(); $output->writeln(sprintf('Checked source files in %s seconds, %s MB memory used', $stopEvent->getDuration() / 1000, $stopEvent->getMemory() / 1024 / 1024)); } }
public function onCommandEnd(ConsoleTerminateEvent $event) { $command = $event->getCommand(); if (!in_array($command->getName(), $this->listenedCommands)) { return; } $commandSlug = preg_replace('/[^a-zA-Z0-9_.]/', '', $command->getName()); $this->watcher->end($commandSlug, $event->getOutput(), $event->getInput()->getArguments()); }
/** * @param ConsoleTerminateEvent $event */ public function onConsoleTerminate(ConsoleTerminateEvent $event) { $command = $event->getCommand(); $environment = $this->kernel->getEnvironment(); if ($environment == 'test' && $command instanceof LoadMigrationsCommand && $event->getInput()->getOption('force')) { $executor = new CommandExecutor($environment, $event->getOutput(), $command->getApplication()); $executor->runCommand('oro:test:schema:update', ['--process-isolation' => true]); } }
/** * @param ConsoleTerminateEvent $event */ public function showGenerateInline(ConsoleTerminateEvent $event) { /** * @var \Drupal\AppConsole\Command\Command $command */ $command = $event->getCommand(); $output = $event->getOutput(); $command_name = $command->getName(); $this->skipArguments[] = $command_name; $application = $command->getApplication(); $messageHelper = $application->getHelperSet()->get('message'); /** * @var TranslatorHelper */ $translatorHelper = $application->getHelperSet()->get('translator'); if ($event->getExitCode() != 0) { return; } if (in_array($command->getName(), $this->skipCommands)) { return; } // get the input instance $input = $event->getInput(); //Get options list $options = array_filter($input->getOptions()); if (isset($options['generate-inline']) && $options['generate-inline'] == 1) { // Remove unnecessary options foreach ($this->skipOptions as $remove_option) { unset($options[$remove_option]); } // Get argument list $arguments = array_filter($input->getArguments()); // Remove unnecessary arguments foreach ($this->skipArguments as $remove_argument) { unset($arguments[$remove_argument]); } $inline = ''; foreach ($arguments as $argument_id => $argument) { if (is_array($argument)) { $argument = implode(" ", $argument); } elseif (strstr($argument, ' ')) { $argument = '"' . $argument . '"'; } $inline .= " {$argument}"; } foreach ($options as $option_id => $option) { if (strstr($option, ' ')) { $option = '"' . $option . '"'; } $inline .= ' --' . $option_id . '=' . $option; } // Print yaml output and message $messageHelper->showMessage($output, $translatorHelper->trans('application.console.messages.inline.generated')); $output->writeln('$ drupal' . $inline); } }
public function handleTerminate(ConsoleTerminateEvent $event) { $command = $event->getCommand(); $output = $event->getOutput(); $session = $command->get('phpcr.session'); if ($session->hasPendingChanges()) { $output->writeln('<info>Auto-saving session</info>'); } $session->save(); }
public function applyCodingStyle(ConsoleTerminateEvent $event) { $command = $event->getCommand(); if (!$this->isAllowedCommand($command->getName())) { return; } $filename = $this->getCurrentMigrationFileName(); if (file_exists($filename)) { $this->codeStyle->applyForFile($filename); } }
/** * @param ConsoleTerminateEvent $event */ public function onConsoleTerminate(ConsoleTerminateEvent $event) { $command = $event->getCommand(); $application = $command->getApplication(); if ($this->registry->isChainCommand($command)) { $dependencies = $this->registry->getDependencies($command); foreach ($dependencies as $dep) { $application->find($dep)->run($event->getInput(), $event->getOutput()); } } }
/** * @param ConsoleTerminateEvent $event */ public function afterExecute(ConsoleTerminateEvent $event) { switch ($event->getCommand()->getName()) { case DriverLockCommandListener::LEXIK_MAINTENANCE_LOCK: $this->dispatcher->dispatch(Events::MAINTENANCE_ON); break; case DriverLockCommandListener::LEXIK_MAINTENANCE_UNLOCK: $this->dispatcher->dispatch(Events::MAINTENANCE_OFF); break; } }
/** * @param ConsoleTerminateEvent $event */ public function onConsoleTerminate(ConsoleTerminateEvent $event) { $statusCode = $event->getExitCode(); $command = $event->getCommand(); if ($statusCode === 0) { return; } if ($statusCode > 255) { $statusCode = 255; $event->setExitCode($statusCode); } $this->logger->warning(sprintf('Command `%s` exited with status code %d', $command->getName(), $statusCode)); }
/** * @param ConsoleTerminateEvent $event */ public function showTerminateMessages(ConsoleTerminateEvent $event) { /** * @var \Drupal\Console\Command\Command $command */ $command = $event->getCommand(); $output = $event->getOutput(); $application = $command->getApplication(); $messageHelper = $application->getMessageHelper(); $messageHelper->showMessages($output); if ($event->getExitCode() != 0) { return; } }
/** * @param ConsoleTerminateEvent $event */ public function showTerminateMessages(ConsoleTerminateEvent $event) { /* @var Command $command */ $command = $event->getCommand(); /* @var DrupalStyle $io */ $io = $event->getOutput(); $application = $command->getApplication(); if ($errorMessage = $application->getErrorMessage()) { $io->warning($errorMessage); } if ($event->getExitCode() != 0) { return; } }
/** * @param ConsoleTerminateEvent $event */ public function onConsoleTerminate(ConsoleTerminateEvent $event) { if ($event->getCommand() instanceof UpdateSchemaDoctrineCommand) { $output = $event->getOutput(); $input = $event->getInput(); if ($input->getOption('force')) { $result = $this->fulltextIndexManager->createIndexes(); $output->writeln('Schema update and create index completed.'); if ($result) { $output->writeln('Indexes were created.'); } } } }
/** * @param ConsoleTerminateEvent $event */ public function showGenerateChain(ConsoleTerminateEvent $event) { /** * @var \Drupal\Console\Command\Command $command */ $command = $event->getCommand(); $output = $event->getOutput(); $command_name = $command->getName(); $this->skipArguments[] = $command_name; $application = $command->getApplication(); $messageHelper = $application->getHelperSet()->get('message'); /* @var TranslatorHelper */ $translatorHelper = $application->getHelperSet()->get('translator'); if ($event->getExitCode() != 0) { return; } if (in_array($command->getName(), $this->skipCommands)) { return; } // get the input instance $input = $event->getInput(); //Get options list $options = array_filter($input->getOptions()); if (isset($options['generate-chain']) && $options['generate-chain'] == 1) { // Remove unnecessary options foreach ($this->skipOptions as $remove_option) { unset($options[$remove_option]); } // Get argument list $arguments = array_filter($input->getArguments()); // Remove unnecessary arguments foreach ($this->skipArguments as $remove_argument) { unset($arguments[$remove_argument]); } $yaml = array(); $yaml[$command_name]['options'] = $options; $yaml[$command_name]['arguments'] = $arguments; $dumper = new Dumper(); $yaml = $dumper->dump($yaml, 10); // Print yaml output and message $messageHelper->showMessage($output, $translatorHelper->trans('application.console.messages.chain.generated')); $output->writeln($yaml); } }
/** * @param ConsoleTerminateEvent $event */ public function onTerminate(ConsoleTerminateEvent $event) { if ($event->getCommand()->getName() == 'cache:clear') { $env = ltrim($event->getInput()->getOption('env'), '='); $cmd = 'animedb:update-titles -e=' . $env; $phpFinder = new PhpExecutableFinder(); if (!($phpPath = $phpFinder->find())) { throw new \RuntimeException('The php executable could not be found, add it to your PATH environment variable and try again'); } $php = escapeshellarg($phpPath); $process = new Process($php . ' app/console ' . $cmd, $this->root_dir . '/../', null, null, 1500); $process->run(function ($type, $buffer) { echo $buffer; }); if (!$process->isSuccessful()) { throw new \RuntimeException(sprintf('An error occurred when executing the "%s" command.', $cmd)); } } }
/** * @param ConsoleTerminateEvent $event */ public function showGeneratedFiles(ConsoleTerminateEvent $event) { /** @var \Drupal\AppConsole\Command\Command $command */ $command = $event->getCommand(); $output = $event->getOutput(); $application = $command->getApplication(); $messageHelper = $application->getHelperSet()->get('message'); if ($event->getExitCode() != 0) { return; } if ('self-update' == $command->getName()) { return; } if ($command instanceof GeneratorCommand) { $files = $command->getGenerator()->getFiles(); if ($files) { $messageHelper->showGeneratedFiles($output, $files); } } }
/** * @param ConsoleTerminateEvent $event */ public function showGenerateChain(ConsoleTerminateEvent $event) { if ($event->getExitCode() != 0) { return; } /* @var Command $command */ $command = $event->getCommand(); /* @var DrupalStyle $io */ $io = $event->getOutput(); $command_name = $command->getName(); $this->skipArguments[] = $command_name; $application = $command->getApplication(); $translatorHelper = $application->getTranslator(); if (in_array($command->getName(), $this->skipCommands)) { return; } $input = $event->getInput(); if ($input->getOption('generate-chain')) { $commands = []; $options = array_filter($input->getOptions()); foreach ($this->skipOptions as $remove_option) { unset($options[$remove_option]); } $arguments = array_filter($input->getArguments()); foreach ($this->skipArguments as $remove_argument) { unset($arguments[$remove_argument]); } $commands['commands'][0]['command'] = $command_name; if ($options) { $commands['commands'][0]['options'] = $options; } if ($arguments) { $commands['commands'][0]['arguments'] = $arguments; } $dumper = new Dumper(); $yml = $dumper->dump($commands, 10); $yml = str_replace(sprintf('\'%s\':', $command_name), sprintf(' - command: %s', $command_name), $yml); $io->commentBlock($translatorHelper->trans('application.messages.chain.generated')); $io->writeln($yml); } }
/** * @param ConsoleTerminateEvent $event */ public function callCommands(ConsoleTerminateEvent $event) { // /* @var Command $command */ $command = $event->getCommand(); /* @var DrupalStyle $io */ $io = $event->getOutput(); if (!$command instanceof Command && !$command instanceof BaseCommand) { return; } $application = $command->getApplication(); $commands = $application->getContainer()->get('chain')->getCommands(); if (!$commands) { return; } foreach ($commands as $chainedCommand) { $callCommand = $application->find($chainedCommand['name']); $input = new ArrayInput($chainedCommand['inputs']); if (!is_null($chainedCommand['interactive'])) { $input->setInteractive($chainedCommand['interactive']); } $io->text($chainedCommand['name']); $callCommand->run($input, $io); $drupal = $application->getContainer()->get('site'); if ($chainedCommand['name'] === 'site:new') { if ($chainedCommand['inputs']['directory']) { $siteRoot = sprintf('%s/%s', getcwd(), $chainedCommand['inputs']['directory']); chdir($siteRoot); } $drupal->isValidRoot(getcwd()); $drupal->getAutoLoadClass(); $application->prepare($drupal); } if ($chainedCommand['name'] === 'site:install') { $drupal->isValidRoot(getcwd()); $application->prepare($drupal); } if ($chainedCommand['name'] === 'settings:set') { $application->prepare($drupal); } } }
/** * @param ConsoleTerminateEvent $event */ public function showGeneratedFiles(ConsoleTerminateEvent $event) { /* @var Command $command */ $command = $event->getCommand(); /* @var DrupalStyle $io */ $io = $event->getOutput(); $application = $command->getApplication(); $showFileHelper = $application->getShowFileHelper(); if ($event->getExitCode() != 0) { return; } if ('self-update' == $command->getName()) { return; } if ($command instanceof GeneratorCommand) { $files = $command->getGenerator()->getFiles(); if ($files) { $showFileHelper->generatedFiles($io, $files); } } }
/** * @param ConsoleTerminateEvent $event */ public function callCommands(ConsoleTerminateEvent $event) { /** * @var \Drupal\Console\Command\Command $command */ $command = $event->getCommand(); $output = $event->getOutput(); if (!$command instanceof Command) { return; } $application = $command->getApplication(); $commands = $application->getChain()->getCommands(); if (!$commands) { return; } foreach ($commands as $chainedCommand) { $callCommand = $application->find($chainedCommand['name']); $input = new ArrayInput($chainedCommand['inputs']); if (!is_null($chainedCommand['interactive'])) { $input->setInteractive($chainedCommand['interactive']); } $callCommand->run($input, $output); $drupal = $application->getDrupalHelper(); if ($chainedCommand['name'] === 'site:new') { if ($chainedCommand['inputs']['site-name']) { $siteRoot = sprintf('%s/%s', getcwd(), $chainedCommand['inputs']['site-name']); chdir($siteRoot); } $drupal->isValidRoot(getcwd()); $drupal->getAutoLoadClass(); $application->prepare($drupal); } if ($chainedCommand['name'] === 'site:install') { $drupal->isValidRoot(getcwd()); $application->prepare($drupal); } } }
/** * @param ConsoleTerminateEvent $event */ public function callCommands(ConsoleTerminateEvent $event) { /** * @var \Drupal\Console\Command\Command $command */ $command = $event->getCommand(); $output = $event->getOutput(); if (!$command instanceof Command) { return; } $application = $command->getApplication(); $commands = $application->getChain()->getCommands(); if (!$commands) { return; } foreach ($commands as $chainedCommand) { $callCommand = $application->find($chainedCommand['name']); $input = new ArrayInput($chainedCommand['inputs']); if (!is_null($chainedCommand['interactive'])) { $input->setInteractive($chainedCommand['interactive']); } $callCommand->run($input, $output); } }
/** * @param ConsoleTerminateEvent $event */ public function onTerminate(ConsoleTerminateEvent $event) { if ($this->track_clear_cache && $event->getCommand()->getName() == 'cache:clear') { $this->keeper->set(Keeper::LAST_UPDATE_KEY, new \DateTime()); } }
/** * @param ConsoleTerminateEvent $event */ public function showGenerateInline(ConsoleTerminateEvent $event) { /* @var Command $command */ $command = $event->getCommand(); /* @var DrupalStyle $io */ $io = $event->getOutput(); $command_name = $command->getName(); $this->skipArguments[] = $command_name; $application = $command->getApplication(); $translatorHelper = $application->getTranslator(); if ($event->getExitCode() != 0) { return; } if (in_array($command->getName(), $this->skipCommands)) { return; } $input = $event->getInput(); if ($input->getOption('generate-inline')) { $options = array_filter($input->getOptions()); foreach ($this->skipOptions as $remove_option) { unset($options[$remove_option]); } $arguments = array_filter($input->getArguments()); foreach ($this->skipArguments as $remove_argument) { unset($arguments[$remove_argument]); } $inline = ''; foreach ($arguments as $argument_id => $argument) { if (is_array($argument)) { $argument = implode(" ", $argument); } elseif (strstr($argument, ' ')) { $argument = '"' . $argument . '"'; } $inline .= " {$argument}"; } // Refactor and remove nested levels. Then apply to arguments. foreach ($options as $optionName => $optionValue) { if (is_array($optionValue)) { foreach ($optionValue as $optionItem) { if (is_array($optionItem)) { $inlineValue = implode(' ', array_map(function ($v, $k) { return $k . ':' . $v; }, $optionItem, array_keys($optionItem))); } else { $inlineValue = $optionItem; } $inline .= ' --' . $optionName . '="' . $inlineValue . '"'; } } else { if (is_bool($optionValue)) { $inline .= ' --' . $optionName; } else { $inline .= ' --' . $optionName . '="' . $optionValue . '"'; } } } // Print yaml output and message $io->commentBlock($translatorHelper->trans('application.messages.inline.generated')); $io->writeln(sprintf('$ drupal %s %s', $command_name, $inline)); } }
/** * @param \Symfony\Component\Console\Event\ConsoleTerminateEvent $event * * @return void */ public function onConsoleTerminate(ConsoleTerminateEvent $event) { $this->getLogger()->info(sprintf('CLI command "%s" terminated', $event->getCommand()->getName())); }
/** * @param \Symfony\Component\Console\Event\ConsoleTerminateEvent $event * * @return string */ protected function getTransactionName(ConsoleTerminateEvent $event) { return static::TRANSACTION_NAME_PREFIX . $event->getCommand()->getName(); }
/** * Cleanup after run command * * @param ConsoleTerminateEvent $event */ public function onTerminate(ConsoleTerminateEvent $event) { if (!$this->isPIDRequired($event->getCommand())) { return; } $pidFile = $event->getInput()->getOption(static::PID_OPTION); if (null !== $pidFile) { unlink($pidFile); } }