1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Kaliop\eZWorkflowEngineBundle\Command; |
4
|
|
|
|
5
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
6
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
7
|
|
|
use Symfony\Component\Console\Input\InputOption; |
8
|
|
|
use Symfony\Component\Console\Helper\Table; |
9
|
|
|
use Kaliop\eZMigrationBundle\API\Value\MigrationDefinition; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Command to display the defined workflow definitions. |
13
|
|
|
*/ |
14
|
|
|
class DebugCommand extends AbstractCommand |
15
|
|
|
{ |
16
|
|
|
protected function configure() |
17
|
|
|
{ |
18
|
|
|
$this->setName('kaliop:workflows:debug') |
19
|
|
|
->setDescription('List the configured workflow definitions') |
20
|
|
|
->addOption('path', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, "The directory or file to load the workflow definitions from" |
21
|
|
|
) |
22
|
|
|
; |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
public function execute(InputInterface $input, OutputInterface $output) |
26
|
|
|
{ |
27
|
|
|
$workflowService = $this->getWorkflowService(); |
28
|
|
|
|
29
|
|
|
$workflowDefinitions = $workflowService->getWorkflowsDefinitions($input->getOption('path')); |
30
|
|
|
|
31
|
|
|
if (!count($workflowDefinitions)) { |
32
|
|
|
$output->writeln('<info>No workflow definitions found</info>'); |
33
|
|
|
return; |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
$i = 1; |
37
|
|
|
foreach ($workflowDefinitions as $workflowDefinition) { |
38
|
|
|
switch ($workflowDefinition->status) { |
39
|
|
|
case MigrationDefinition::STATUS_INVALID: |
40
|
|
|
$name = '<error>' . $workflowDefinition->name . '</error>'; |
41
|
|
|
break; |
42
|
|
|
default: |
43
|
|
|
$name = $workflowDefinition->name; |
44
|
|
|
} |
45
|
|
|
$data[] = array( |
46
|
|
|
$i++, |
47
|
|
|
$name, |
48
|
|
|
$workflowDefinition->signalName, |
49
|
|
|
//$workflowDefinition->path, |
50
|
|
|
($workflowDefinition->runAs === false) ? '-' : $workflowDefinition->runAs, |
51
|
|
|
$workflowDefinition->useTransaction ? 'Y' : 'N', |
52
|
|
|
$workflowDefinition->parsingError |
53
|
|
|
); |
54
|
|
|
|
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
$table = new Table($output); |
58
|
|
|
$table |
59
|
|
|
->setHeaders(array('#', 'Workflow definition', 'Signal', 'Switch user', 'Use transaction', /*'Path',*/ 'Notes')) |
60
|
|
|
->setRows($data); |
|
|
|
|
61
|
|
|
$table->render(); |
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
|