1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Kaliop\eZWorkflowEngineBundle\Command; |
4
|
|
|
|
5
|
|
|
use Kaliop\eZMigrationBundle\API\Value\MigrationDefinition; |
6
|
|
|
use Symfony\Component\Console\Helper\Table; |
7
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
8
|
|
|
use Symfony\Component\Console\Input\InputOption; |
9
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
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
|
|
|
->addOption('show-path', null, InputOption::VALUE_NONE, "Print definition path instead of notes") |
22
|
|
|
; |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
public function execute(InputInterface $input, OutputInterface $output) |
26
|
|
|
{ |
27
|
|
|
$workflowService = $this->getWorkflowService(); |
28
|
|
|
|
29
|
|
|
$displayPath = $input->getOption('show-path'); |
30
|
|
|
|
31
|
|
|
$workflowDefinitions = $workflowService->getWorkflowsDefinitions($input->getOption('path')); |
|
|
|
|
32
|
|
|
|
33
|
|
|
if (!count($workflowDefinitions)) { |
34
|
|
|
$output->writeln('<info>No workflow definitions found</info>'); |
35
|
|
|
return 0; |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
$i = 1; |
39
|
|
|
foreach ($workflowDefinitions as $workflowDefinition) { |
40
|
|
|
switch ($workflowDefinition->status) { |
41
|
|
|
case MigrationDefinition::STATUS_INVALID: |
42
|
|
|
$name = '<error>' . $workflowDefinition->name . '</error>'; |
43
|
|
|
break; |
44
|
|
|
default: |
45
|
|
|
$name = $workflowDefinition->name; |
46
|
|
|
} |
47
|
|
|
$data[] = array( |
48
|
|
|
$i++, |
49
|
|
|
$name, |
50
|
|
|
$workflowDefinition->signalName, |
51
|
|
|
//$workflowDefinition->path, |
52
|
|
|
($workflowDefinition->runAs === false) ? '-' : $workflowDefinition->runAs, |
53
|
|
|
$workflowDefinition->useTransaction ? 'Y' : 'N', |
54
|
|
|
$displayPath ? $workflowDefinition->path : $workflowDefinition->parsingError |
55
|
|
|
); |
56
|
|
|
|
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
$table = new Table($output); |
60
|
|
|
$table |
61
|
|
|
->setHeaders(array('#', 'Workflow definition', 'Signal', 'Switch user', 'Use transaction', /*'Path',*/ 'Notes')) |
62
|
|
|
->setRows($data); |
|
|
|
|
63
|
|
|
$table->render(); |
64
|
|
|
|
65
|
|
|
return 0; |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
|