1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of tenside/core-bundle. |
5
|
|
|
* |
6
|
|
|
* (c) Christian Schiffler <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
* |
11
|
|
|
* This project is provided in good faith and hope to be usable by anyone. |
12
|
|
|
* |
13
|
|
|
* @package tenside/core-bundle |
14
|
|
|
* @author Christian Schiffler <[email protected]> |
15
|
|
|
* @copyright 2015 Christian Schiffler <[email protected]> |
16
|
|
|
* @license https://github.com/tenside/core-bundle/blob/master/LICENSE MIT |
17
|
|
|
* @link https://github.com/tenside/core-bundle |
18
|
|
|
* @filesource |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
namespace Tenside\CoreBundle\Command; |
22
|
|
|
|
23
|
|
|
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; |
24
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
25
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* This class executes a queued task in detached mode. |
29
|
|
|
*/ |
30
|
|
|
class ListTasksCommand extends ContainerAwareCommand |
31
|
|
|
{ |
32
|
|
|
/** |
33
|
|
|
* {@inheritdoc} |
34
|
|
|
*/ |
35
|
|
|
protected function configure() |
36
|
|
|
{ |
37
|
|
|
$this |
38
|
|
|
->setName('tenside:listtasks') |
39
|
|
|
->setDescription('List the queued tasks') |
40
|
|
|
->setHelp('You most likely do not want to use this from CLI - use the web UI'); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* {@inheritdoc} |
45
|
|
|
* |
46
|
|
|
* @throws \InvalidArgumentException When an invalid task id has been passed. |
47
|
|
|
*/ |
48
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
49
|
|
|
{ |
50
|
|
|
$container = $this->getContainer(); |
51
|
|
|
$taskList = $container->get('tenside.tasks'); |
52
|
|
|
|
53
|
|
|
foreach ($taskList->getIds() as $taskId) { |
54
|
|
|
$task = $taskList->getTask($taskId); |
55
|
|
|
$output->writeln(sprintf('<info>%s</info> %s (state: %s)', $taskId, $task->getType(), $task->getStatus())); |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
|