run() public method

Runs the current application.
public run ( Symfony\Component\Console\Input\InputInterface $input = null, Symfony\Component\Console\Output\OutputInterface $output = null ) : integer
$input Symfony\Component\Console\Input\InputInterface An Input instance
$output Symfony\Component\Console\Output\OutputInterface An Output instance
return integer 0 if everything went fine, or an error code
Exemplo n.º 1
1
 /**
  * {@inheritdoc}
  */
 public function execute(ContainerInterface $app)
 {
     foreach ($this->commands as $command) {
         $this->console->add($app->create($command));
     }
     $this->console->run();
 }
Exemplo n.º 2
0
 /**
  * Handles any commandline request
  *
  * @param InputInterface $input
  * @return void
  */
 public function handleRequest(InputInterface $input)
 {
     $output = new ConsoleOutput();
     $this->bootstrap->loadExtensionTables();
     // Check if the command to run needs a backend user to be loaded
     $command = $this->getCommandToRun($input);
     foreach ($this->availableCommands as $data) {
         if ($data['command'] !== $command) {
             continue;
         }
         if (isset($data['user'])) {
             $this->initializeBackendUser($data['user']);
         }
     }
     // Make sure output is not buffered, so command-line output and interaction can take place
     $this->bootstrap->endOutputBufferingAndCleanPreviousOutput();
     if (!$command) {
         $cliKeys = array_keys($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['cliKeys']);
         $output->writeln('Old entrypoint keys available:');
         asort($cliKeys);
         foreach ($cliKeys as $key => $value) {
             $output->writeln('  ' . $value);
         }
         $output->writeln('');
         $output->writeln('TYPO3 Console Commands:');
     }
     $exitCode = $this->application->run($input, $output);
     exit($exitCode);
 }
Exemplo n.º 3
0
 protected function start()
 {
     $this->console = new SymfonyApplication(self::APP_NAME, self::VERSION);
     foreach ($this->commands as $command) {
         $this->console->add($command);
     }
     $this->console->run();
 }
Exemplo n.º 4
0
 /**
  * @throws \Exception
  */
 public function run()
 {
     $commands = $this->config('commands');
     foreach ($commands as $command) {
         $this->console->add($this->container->get($command));
     }
     $this->console->run();
 }
 /**
  * @param string $input
  *
  * @return integer
  */
 public function run($input)
 {
     $this->input = new StringInput($input);
     $this->output = new StreamOutput(fopen('php://memory', 'w', false));
     $inputStream = $this->getInputStream();
     rewind($inputStream);
     $this->application->getHelperSet()->get('dialog')->setInputStream($inputStream);
     $this->result = $this->application->run($this->input, $this->output);
 }
Exemplo n.º 6
0
 /**
  * Index action - runs the console application
  */
 public function cliAction()
 {
     $exitCode = $this->cliApplication->run(new RequestInput($this->getRequest()));
     if (is_numeric($exitCode)) {
         $model = class_exists(ViewModel::class) ? new ViewModel() : new V2ViewModel();
         $model->setErrorLevel($exitCode);
         return $model;
     }
 }
 /**
  * 
  * @return ConsoleModel
  */
 public function runAction()
 {
     $exitCode = $this->application->run(new RequestInput($this->getRequest()));
     if (is_numeric($exitCode)) {
         $model = new ConsoleModel();
         $model->setErrorLevel($exitCode);
         return $model;
     }
 }
Exemplo n.º 8
0
 public function run()
 {
     if ($this->container->getConfig()->get('app.debug')) {
         foreach ($this->app->all() as $commandKey => $command) {
             if (method_exists($command, 'isVagrant') && $command->isVagrant()) {
                 $this->toggleVagrantCommand($commandKey, $command);
             }
         }
     }
     $this->app->run();
 }
Exemplo n.º 9
0
 /**
  * Main function of Facilior
  * @return int
  */
 public function execute()
 {
     //Greetings
     $this->console->log('Logging started');
     $this->console->output('<fg=default;options=bold>Logging started:</> <fg=magenta>' . $this->console->getLogFile() . '</>', 0, 2);
     $fileService = new FileService();
     $fileService->init();
     //Run Command and check if there is a config error
     $exitCode = $this->application->run();
     $fileService->cleanup();
     return $exitCode;
 }
Exemplo n.º 10
0
 /**
  * {@inheritdoc}
  */
 public function runCommand($command, $params = [])
 {
     $params = array_merge(['command' => $command], $params, $this->getDefaultParams());
     $this->application->setAutoExit(false);
     $exitCode = $this->application->run(new ArrayInput($params), $this->output);
     if (0 !== $exitCode) {
         $this->application->setAutoExit(true);
         $errorMessage = sprintf('The command terminated with an error code: %u.', $exitCode);
         $this->output->writeln("<error>{$errorMessage}</error>");
         $e = new \Exception($errorMessage, $exitCode);
         throw $e;
     }
     return $this;
 }
Exemplo n.º 11
0
 /**
  * @param $command
  * @param array $parameters
  * @param OutputInterface $output
  *
  * @return $this
  *
  * @throws \Exception
  */
 public function runCommand($command, $parameters = array(), OutputInterface $output = null)
 {
     $parameters = array_merge(array('command' => $command), $this->getDefaultParameters(), $parameters);
     $this->application->setAutoExit(false);
     $exitCode = $this->application->run(new ArrayInput($parameters), $output ?: new NullOutput());
     if (0 !== $exitCode) {
         $this->application->setAutoExit(true);
         $errorMessage = sprintf('The command terminated with an error code: %u.', $exitCode);
         $this->output->writeln("<error>{$errorMessage}</error>");
         $exception = new \Exception($errorMessage, $exitCode);
         throw $exception;
     }
     return $this;
 }
 public function testCommand()
 {
     $app = new Application('Propel', Propel::VERSION);
     $command = new DatabaseReverseCommand();
     $app->add($command);
     $currentDir = getcwd();
     $outputDir = __DIR__ . '/../../../../reversecommand';
     chdir(__DIR__ . '/../../../../Fixtures/bookstore');
     $input = new \Symfony\Component\Console\Input\ArrayInput(array('command' => 'database:reverse', '--database-name' => 'reverse-test', '--output-dir' => $outputDir, '--verbose' => true, '--platform' => ucfirst($this->getDriver()) . 'Platform', 'connection' => $this->getConnectionDsn('bookstore-schemas', true)));
     $output = new \Symfony\Component\Console\Output\StreamOutput(fopen("php://temp", 'r+'));
     $app->setAutoExit(false);
     $result = $app->run($input, $output);
     chdir($currentDir);
     if (0 !== $result) {
         rewind($output->getStream());
         echo stream_get_contents($output->getStream());
     }
     $this->assertEquals(0, $result, 'database:reverse tests exited successfully');
     $databaseXml = simplexml_load_file($outputDir . '/schema.xml');
     $this->assertEquals('reverse-test', $databaseXml['name']);
     $this->assertGreaterThan(20, $databaseXml->xpath("table"));
     $table = $databaseXml->xpath("table[@name='acct_access_role']");
     $this->assertCount(1, $table);
     $table = $table[0];
     $this->assertEquals('acct_access_role', $table['name']);
     $this->assertEquals('AcctAccessRole', $table['phpName']);
     $this->assertCount(2, $table->xpath('column'));
 }
Exemplo n.º 13
0
 /**
  * {@inheritDoc}
  */
 public function run(InputInterface $input = null, OutputInterface $output = null)
 {
     if (null === $output) {
         $output = Factory::createOutput();
     }
     return parent::run($input, $output);
 }
Exemplo n.º 14
0
 public function run(InputInterface $input = null, OutputInterface $output = null)
 {
     $fp = fopen($this->config['lockfile'], "w");
     // if you run this script as root - change user/group
     if (file_exists($this->config['lockfile'])) {
         chown($this->config['lockfile'], $this->config['file-user']);
         chgrp($this->config['lockfile'], $this->config['file-group']);
     }
     $exitCode = 0;
     if (flock($fp, LOCK_EX | LOCK_NB)) {
         // acquire an exclusive lock
         ftruncate($fp, 0);
         $exitCode = parent::run($input, $output);
         fflush($fp);
         // flush output before releasing the lock
         flock($fp, LOCK_UN);
         // release the lock
     } else {
         //throw new DNSSyncException("Running multiple instances is not allowed."); - nezachytí applikace error
         //$output->writeln() - null v této chvíli
         $message = "Running multiple instances is not allowed.";
         echo $message . PHP_EOL;
         mail($this->config['admin-email'], $message, $message);
         $exitCode = 500;
     }
     fclose($fp);
     return $exitCode;
 }
Exemplo n.º 15
0
 /**
  * Inicializa a aplicação.
  *
  * @throws \Exception
  */
 public function run()
 {
     //apenas para inicializar
     Config::getInstance();
     $application = new Application();
     $commands = [];
     /* Carregando os comandos internos */
     $anna_commands = __DIR__ . DS . 'Commands' . DS;
     $anna_commands = $this->loadAppCommands($anna_commands);
     /* Carregandos os comandos criados pelos desenvolvedores */
     $app_commands = SYS_ROOT . 'App' . DS . 'Console' . DS;
     $app_commands = $this->loadAppCommands($app_commands);
     /* Registra todos os comandos encontrados */
     foreach ($app_commands as $cmd) {
         $commands[] = new $cmd();
     }
     foreach ($anna_commands as $cmd) {
         $class = new \ReflectionClass($cmd);
         if (!$class->isAbstract()) {
             $commands[] = new $cmd();
         }
     }
     $application->addCommands($commands);
     $application->run();
 }
Exemplo n.º 16
0
 /**
  * @param InputInterface|null $input
  * @param OutputInterface|null $output
  * @return int
  * @throws \Exception
  */
 public function run(InputInterface $input = null, OutputInterface $output = null)
 {
     foreach ($this->factory->createCommands() as $command) {
         $this->add($command);
     }
     return parent::run($input, $this->factory->createOutput());
 }
Exemplo n.º 17
0
 /**
  * command应用主入口
  * @throws \Exception
  */
 static function main()
 {
     $application = new Application();
     $application->addCommands(self::createCommands());
     $application->setDefaultCommand(ThumbnailCommand::COMMAND_NAME);
     $application->run();
 }
Exemplo n.º 18
0
Arquivo: Tg.php Projeto: twhiston/tg
 /**
  * @param null $input Input
  * @return int|void
  * @throws \Exception
  *
  * Run tg and return an error code
  */
 public function run($input = null)
 {
     register_shutdown_function([$this, 'shutdown']);
     set_error_handler([$this, 'handleError']);
     if ($this->classCache->getCachePath() === null) {
         $this->classCache->setCachePath(__DIR__ . "/../.tg/");
     }
     $hasCommandFile = $this->autoloadCommandFile();
     $this->setupDevModes();
     $this->input = $this->prepareInput($input ? $input : $_SERVER['argv']);
     //Load all our commands
     $commandLoader = new CommandLoader();
     $this->loadLocalFile($commandLoader, $hasCommandFile);
     //Cwd project specific
     $this->loadCoreCommands($commandLoader);
     //Tg vendor and core
     if (!$this->coreDevMode) {
         //If we are developing in the core we dont want to load cwd vendors folder at all
         $this->loadLocalVendors($commandLoader);
         //Cwd vendor
     }
     if ($this->libDevMode) {
         //If we are developing a library we want to load the cwd source folder
         $this->loadLocalSrc($commandLoader);
     }
     //Set up the robo static config class :(
     Config::setInput($this->input);
     Config::setOutput($this->output);
     $this->app->setAutoExit(false);
     return $this->app->run($this->input, $this->output);
 }
Exemplo n.º 19
0
 /**
  * Run the Dumpling command line application.
  *
  * @param InputInterface|null  $input  The input interface to use.
  * @param OutputInterface|null $output The output interface to use.
  *
  * @return integer The process exit code.
  */
 public function run(InputInterface $input = null, OutputInterface $output = null)
 {
     if (null === $input) {
         $input = new Input\BoundArgvInput(array('dumpling'));
     }
     parent::run($input, $output);
 }
Exemplo n.º 20
0
 /**
  * @override
  */
 public function run(InputInterface $input = null, OutputInterface $output = null)
 {
     $output = $output ?: new ConsoleOutput();
     $output->getFormatter()->setStyle('error', new OutputFormatterStyle('red'));
     $output->getFormatter()->setStyle('question', new OutputFormatterStyle('cyan'));
     return parent::run($input, $output);
 }
Exemplo n.º 21
0
 /**
  * command应用主入口
  * @throws \Exception
  */
 static function main()
 {
     $application = new Application();
     $application->addCommands(self::createCommands());
     $application->setDefaultCommand(self::DEFAULT_COMMAND_NAME);
     $application->run();
 }
 protected function executeCommand($command)
 {
     // Cache can not be warmed up as classes can not be redefined during one request
     if (preg_match('/^cache:clear/', $command)) {
         $command .= ' --no-warmup';
     }
     $input = new StringInput($command);
     $input->setInteractive(false);
     $output = new StringOutput();
     $formatter = $output->getFormatter();
     $formatter->setDecorated(true);
     $output->setFormatter(new HtmlOutputFormatterDecorator($formatter));
     # MVC object store
     MVCStore::store('mvc', $this->mvc);
     // Some commands (i.e. doctrine:query:dql) dump things out instead of returning a value
     ob_start();
     $this->application->setAutoExit(false);
     $errorCode = $this->application->run($input, $output);
     // So, if the returned output is empty
     if (!($result = $output->getBuffer())) {
         $result = ob_get_contents();
         // We replace it by the catched output
     }
     ob_end_clean();
     return array('command' => $command, 'output' => $result, 'errorCode' => $errorCode);
 }
Exemplo n.º 23
0
 /**
  * command应用主入口
  * @throws \Exception
  */
 static function main()
 {
     $application = new Application();
     $application->setAutoExit(true);
     $application->addCommands(self::createCommands());
     $application->run();
 }
Exemplo n.º 24
0
 public function run(InputInterface $input = null, OutputInterface $output = null)
 {
     if (null === $input) {
         $input = new Input\ArgvInput();
     }
     return parent::run($input, $output);
 }
Exemplo n.º 25
0
 /**
  * Starts the application, boilerplate code.
  * @param InputInterface|null $input
  * @param OutputInterface|null $output
  * @return int
  */
 public function run(InputInterface $input = null, OutputInterface $output = null)
 {
     if (null === $output) {
         $output = new ConsoleOutput(ConsoleOutput::VERBOSITY_NORMAL, null, new OutputFormatter(false, ['highlight' => new OutputFormatterStyle('red'), 'warning' => new OutputFormatterStyle('black', 'yellow')]));
     }
     return parent::run($input, $output);
 }
Exemplo n.º 26
0
 /**
  * {@inheritdoc}
  */
 public function run(InputInterface $input = null, OutputInterface $output = null)
 {
     $silexApp = $this->getSilexApplication();
     $silexApp->boot();
     $silexApp->flush();
     return parent::run($input, $output);
 }
Exemplo n.º 27
0
 /**
  * Method overridden to add output customizations and use the output object
  * for application logging.
  */
 public function run(InputInterface $input = null, OutputInterface $output = null)
 {
     if (null === $output) {
         $output = new ConsoleOutput();
         $output->setFormatter(new OutputFormatter($output->isDecorated()));
     }
     return parent::run($input, $output);
 }
Exemplo n.º 28
0
 /**
  * {@inheritDoc}
  */
 public function run(InputInterface $input = null, OutputInterface $output = null)
 {
     if (null === $output) {
         $formatter = new OutputFormatter(true, []);
         $output = new ConsoleOutput(ConsoleOutput::VERBOSITY_NORMAL, null, $formatter);
     }
     return parent::run($input, $output);
 }
Exemplo n.º 29
0
 public static function debug()
 {
     set_time_limit(0);
     $application = new Application();
     $application->add(new InstallRun());
     $application->add(new DatabaseDump());
     $application->run();
 }
Exemplo n.º 30
0
 public function run(InputInterface $input = null, OutputInterface $output = null)
 {
     $input = null !== $input ? $input : new ArgvInput();
     $output = null !== $output ? $output : new ConsoleOutput();
     $this->add(new RunCommand());
     $this->configureIO($input, $output);
     parent::run($input, $output);
 }