<?php
namespace Hello\World\Console\Command;
use Hello\World\Cron\Test;
use SymfonyComponentConsoleCommandCommand;
use SymfonyComponentConsoleInputInputInterface;
use SymfonyComponentConsoleInputInputOption;
use SymfonyComponentConsoleOutputOutputInterface;
/**
* Class SomeCommand
*/
class SomeCommand extends Command
{
/** @var string **/
const NAME = 'helloworld:testcronjob';
/** @var Test **/
protected $testCronJob;
public function __construct(Test $testCronJob)
{
$this->testCronJob = $testCronJob;
}
/**
* @inheritDoc
*/
protected function configure()
{
$options = [];
$this->setName(self::NAME)
->setDescription('Test cron job runner')
->setDefinition($options);
parent::configure();
}
/**
* Execute the command
*
* @param InputInterface $input
* @param OutputInterface $output
*
* @return null|int
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
try {
$this->testCronJob->execute();
} catch (Exception $e) {
$output->writeln(sprintf('<error>%s</error>', $e->getMessage()));
}
}
}