Skip to content

Commit 1fbb7ec

Browse files
alexander-schranzwachterjohannes
authored andcommitted
add runhandler
1 parent 7c9ec72 commit 1fbb7ec

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

src/Command/RunHandlerCommand.php

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
3+
namespace Task\TaskBundle\Command;
4+
5+
use Symfony\Component\Console\Command\Command;
6+
use Symfony\Component\Console\Input\InputArgument;
7+
use Symfony\Component\Console\Input\InputInterface;
8+
use Symfony\Component\Console\Output\OutputInterface;
9+
use Task\Handler\RegistryInterface;
10+
use Task\SchedulerInterface;
11+
12+
/**
13+
* Run pending tasks.
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+
}

src/Resources/config/command.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99
<tag name="console.command"/>
1010
</service>
1111

12+
<service id="task.command.run.handler" class="Task\TaskBundle\Command\RunHandlerCommand">
13+
<argument type="service" id="task.handler_registry"/>
14+
15+
<tag name="console.command"/>
16+
</service>
17+
1218
<service id="task.command.schedule_task" class="Task\TaskBundle\Command\ScheduleTaskCommand">
1319
<argument type="service" id="task.scheduler"/>
1420

0 commit comments

Comments
 (0)