| @@ 17-48 (lines=32) @@ | ||
| 14 | * |
|
| 15 | * @author @wachterjohannes <[email protected]> |
|
| 16 | */ |
|
| 17 | class RunHandlerCommand extends Command |
|
| 18 | { |
|
| 19 | /** |
|
| 20 | * @var RegistryInterface |
|
| 21 | */ |
|
| 22 | private $registry; |
|
| 23 | ||
| 24 | public function __construct(RegistryInterface $registry) |
|
| 25 | { |
|
| 26 | parent::__construct('task:run:handler'); |
|
| 27 | ||
| 28 | $this->registry = $registry; |
|
| 29 | } |
|
| 30 | ||
| 31 | /** |
|
| 32 | * {@inheritdoc} |
|
| 33 | */ |
|
| 34 | protected function configure() |
|
| 35 | { |
|
| 36 | $this->setDescription('Run pending tasks') |
|
| 37 | ->addArgument('handler', InputArgument::REQUIRED) |
|
| 38 | ->addArgument('workload', InputArgument::OPTIONAL); |
|
| 39 | } |
|
| 40 | ||
| 41 | /** |
|
| 42 | * {@inheritdoc} |
|
| 43 | */ |
|
| 44 | protected function execute(InputInterface $input, OutputInterface $output) |
|
| 45 | { |
|
| 46 | $this->registry->run($input->getArgument('handler'), $input->getArgument('workload')); |
|
| 47 | } |
|
| 48 | } |
|
| 49 | ||
| @@ 16-50 (lines=35) @@ | ||
| 13 | * |
|
| 14 | * @author @wachterjohannes <[email protected]> |
|
| 15 | */ |
|
| 16 | class ScheduleTaskCommand extends Command |
|
| 17 | { |
|
| 18 | /** |
|
| 19 | * @var SchedulerInterface |
|
| 20 | */ |
|
| 21 | private $scheduler; |
|
| 22 | ||
| 23 | public function __construct(SchedulerInterface $scheduler) |
|
| 24 | { |
|
| 25 | parent::__construct('task:schedule:task'); |
|
| 26 | ||
| 27 | $this->scheduler = $scheduler; |
|
| 28 | } |
|
| 29 | ||
| 30 | /** |
|
| 31 | * {@inheritdoc} |
|
| 32 | */ |
|
| 33 | protected function configure() |
|
| 34 | { |
|
| 35 | $this |
|
| 36 | ->setDescription('Run pending tasks') |
|
| 37 | ->addArgument('handler', InputArgument::REQUIRED) |
|
| 38 | ->addArgument('workload', InputArgument::OPTIONAL); |
|
| 39 | } |
|
| 40 | ||
| 41 | /** |
|
| 42 | * {@inheritdoc} |
|
| 43 | */ |
|
| 44 | protected function execute(InputInterface $input, OutputInterface $output) |
|
| 45 | { |
|
| 46 | $this->scheduler |
|
| 47 | ->createTask($input->getArgument('handler'), $input->getArgument('workload')) |
|
| 48 | ->schedule(); |
|
| 49 | } |
|
| 50 | } |
|
| 51 | ||