function ConsoleExampleCommand::execute

Same name and namespace in other branches
  1. 11.x core/modules/system/tests/modules/console_test/src/Command/ConsoleExampleCommand.php \Drupal\console_test\Command\ConsoleExampleCommand::execute()

File

core/modules/system/tests/modules/console_test/src/Command/ConsoleExampleCommand.php, line 52

Class

ConsoleExampleCommand
An example command.

Namespace

Drupal\console_test\Command

Code

protected function execute(InputInterface $input, OutputInterface $output) : int {
  $io = new SymfonyStyle($input, $output);
  $this->logger
    ->notice('Option test: ' . ($input->getOption('option-test') ? 'Yes' : 'No'));
  $this->logger
    ->notice('Argument test: ' . ($input->getArgument('argument-test') ? 'Yes' : 'No'));
  $this->logger
    ->notice('Dependency injection test: ' . $this->testService
    ->getTestInjection()::class);
  $io->success('Done.');
  return Command::SUCCESS;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.