1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Service; |
4
|
|
|
|
5
|
|
|
use App\Entity\Scenario; |
6
|
|
|
use Doctrine\ORM\EntityManagerInterface; |
|
|
|
|
7
|
|
|
use DomainException; |
8
|
|
|
use Ds\Component\Api\Api\Api; |
|
|
|
|
9
|
|
|
use Ds\Component\Camunda\Query\ProcessDefinitionParameters; |
|
|
|
|
10
|
|
|
use Ds\Component\Entity\Service\EntityService; |
|
|
|
|
11
|
|
|
use Ds\Component\Form\Service\FormService; |
|
|
|
|
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Class ScenarioService |
15
|
|
|
*/ |
16
|
|
|
final class ScenarioService extends EntityService |
17
|
|
|
{ |
18
|
|
|
/** |
19
|
|
|
* @var \Ds\Component\Api\Api\Api |
20
|
|
|
*/ |
21
|
|
|
private $api; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @var \Ds\Component\Form\Service\FormService |
25
|
|
|
*/ |
26
|
|
|
private $formService; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Constructor |
30
|
|
|
* |
31
|
|
|
* @param \Doctrine\ORM\EntityManagerInterface $manager |
32
|
|
|
* @param \Ds\Component\Api\Api\Api $api |
33
|
|
|
* @param \Ds\Component\Form\Service\FormService $formService |
34
|
|
|
* @param string $entity |
35
|
|
|
*/ |
36
|
|
|
public function __construct(EntityManagerInterface $manager, Api $api, FormService $formService, string $entity = Scenario::class) |
37
|
|
|
{ |
38
|
|
|
parent::__construct($manager, $entity); |
39
|
|
|
$this->api = $api; |
40
|
|
|
$this->formService = $formService; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Get form |
45
|
|
|
* |
46
|
|
|
* @param \App\Entity\Scenario $scenario |
47
|
|
|
* @return \Ds\Component\Form\Model\Form |
|
|
|
|
48
|
|
|
* @throws \DomainException |
49
|
|
|
*/ |
50
|
|
|
public function getForm(Scenario $scenario) |
51
|
|
|
{ |
52
|
|
|
$forms = $this->getForms($scenario); |
53
|
|
|
|
54
|
|
|
foreach ($forms as $form) { |
55
|
|
|
if ($form->getPrimary()) { |
56
|
|
|
return $form; |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Get forms |
63
|
|
|
* |
64
|
|
|
* @param \App\Entity\Scenario $scenario |
65
|
|
|
* @return array |
66
|
|
|
* @throws \DomainException |
67
|
|
|
*/ |
68
|
|
|
public function getForms(Scenario $scenario) |
69
|
|
|
{ |
70
|
|
|
switch ($scenario->getType()) { |
71
|
|
|
case Scenario::TYPE_BPM: |
72
|
|
|
$config = $scenario->getConfig(); |
73
|
|
|
|
74
|
|
|
if (array_key_exists('form_key', $config)) { |
75
|
|
|
$id = $config['form_key']; |
76
|
|
|
} else { |
77
|
|
|
$parameters = new ProcessDefinitionParameters; |
78
|
|
|
$parameters |
79
|
|
|
->setKey($scenario->getConfig()['process_definition_key']) |
80
|
|
|
->setTenantId($scenario->getTenant()); |
81
|
|
|
$id = $this->api->get('workflow.process_definition')->getStartForm(null, $parameters); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
if (null === $id) { |
85
|
|
|
return []; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
break; |
89
|
|
|
|
90
|
|
|
default: |
91
|
|
|
throw new DomainException('Scenario type does not exist.'); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
$forms = $this->formService->getForms($id); |
95
|
|
|
|
96
|
|
|
foreach ($forms as $key => $form) { |
97
|
|
|
$form = $this->formService->resolve($form); |
98
|
|
|
|
99
|
|
|
if ($form->getPrimary()) { |
100
|
|
|
// @todo Perhaps use the route generator. |
101
|
|
|
$form->setAction('/scenarios/'.$scenario->getUuid().'/submissions'); |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
$forms[$key] = $form; |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
return $forms; |
108
|
|
|
} |
109
|
|
|
} |
110
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths