/** * @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); } } }
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) { $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]); } }
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 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); } }
/** * @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 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 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); } }
/** * 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); } }
/** * @param \Symfony\Component\Console\Event\ConsoleTerminateEvent $event * * @return array */ protected function addOptionsAsCustomParameter(ConsoleTerminateEvent $event) { $this->addCustomParameter($event->getInput()->getOptions()); }
/** * @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)); } }