| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace App\EventListener\Submission\Transfer; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use App\Entity\Submission; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use App\Entity\Scenario; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use App\Service\SubmissionService; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use Ds\Component\Api\Api\Api; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use Ds\Component\Camunda\Model\Variable; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | use Ds\Component\Camunda\Query\ProcessDefinitionParameters; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | use Ds\Component\Config\Service\ConfigService; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | use Symfony\Component\DependencyInjection\ContainerInterface; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  * Class BpmListener | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | final class BpmListener | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |      * @var \Symfony\Component\DependencyInjection\ContainerInterface | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |     private $container; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |      * @var \Ds\Component\Api\Api\Api | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |     private $api; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |      * @var \Ds\Component\Config\Service\ConfigService | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |     private $configService; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |      * @var \App\Service\SubmissionService | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |     private $submissionService; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |      * Constructor | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |      * @param \Symfony\Component\DependencyInjection\ContainerInterface $container | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |     public function __construct(ContainerInterface $container) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |         $this->container = $container; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |      * Forward the submission to the bpm service | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |      * @param \App\Entity\Submission $submission | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 53 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 54 |  |  |     public function postPersist(Submission $submission) | 
            
                                                                        
                            
            
                                    
            
            
                | 55 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 56 |  |  |         // Circular reference error workaround | 
            
                                                                        
                            
            
                                    
            
            
                | 57 |  |  |         // @todo Look into fixing this | 
            
                                                                        
                            
            
                                    
            
            
                | 58 |  |  |         $this->api = $this->container->get(Api::class); | 
            
                                                                        
                            
            
                                    
            
            
                | 59 |  |  |         $this->configService = $this->container->get(ConfigService::class); | 
            
                                                                        
                            
            
                                    
            
            
                | 60 |  |  |         $this->submissionService = $this->container->get(SubmissionService::class); | 
            
                                                                        
                            
            
                                    
            
            
                | 61 |  |  |         // | 
            
                                                                        
                            
            
                                    
            
            
                | 62 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 63 |  |  |         $scenario = $submission->getScenario(); | 
            
                                                                        
                            
            
                                    
            
            
                | 64 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 65 |  |  |         if (Scenario::TYPE_BPM !== $scenario->getType()) { | 
            
                                                                        
                            
            
                                    
            
            
                | 66 |  |  |             return; | 
            
                                                                        
                            
            
                                    
            
            
                | 67 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 68 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 69 |  |  | //        $parameters = new ProcessDefinitionParameters; | 
            
                                                                        
                            
            
                                    
            
            
                | 70 |  |  | //        $parameters->setKey($scenario->getConfig()['process_definition_key']); | 
            
                                                                        
                            
            
                                    
            
            
                | 71 |  |  | //        $xml = $this->api->camunda->processDefinition->getXml(null, $parameters); | 
            
                                                                        
                            
            
                                    
            
            
                | 72 |  |  |         $service = $scenario->getService(); | 
            
                                                                        
                            
            
                                    
            
            
                | 73 |  |  |         $parameters = new ProcessDefinitionParameters; | 
            
                                                                        
                            
            
                                    
            
            
                | 74 |  |  |         $variables = []; | 
            
                                                                        
                            
            
                                    
            
            
                | 75 |  |  |         $variables[] = new Variable($this->configService->get('app.bpm.variables.api_url'), ''); | 
            
                                                                        
                            
            
                                    
            
            
                | 76 |  |  |         $variables[] = new Variable($this->configService->get('app.bpm.variables.api_user'), ''); | 
            
                                                                        
                            
            
                                    
            
            
                | 77 |  |  |         $variables[] = new Variable($this->configService->get('app.bpm.variables.api_key'), ''); | 
            
                                                                        
                            
            
                                    
            
            
                | 78 |  |  |         $variables[] = new Variable($this->configService->get('app.bpm.variables.service_uuid'), $service->getUuid()); | 
            
                                                                        
                            
            
                                    
            
            
                | 79 |  |  |         $variables[] = new Variable($this->configService->get('app.bpm.variables.scenario_uuid'), $scenario->getUuid()); | 
            
                                                                        
                            
            
                                    
            
            
                | 80 |  |  |         $config = $scenario->getConfig(); | 
            
                                                                        
                            
            
                                    
            
            
                | 81 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 82 |  |  |         if (array_key_exists('process_custom_data', $config) | 
            
                                                                        
                            
            
                                    
            
            
                | 83 |  |  |             && array_key_exists('enabled', $config['process_custom_data']) | 
            
                                                                        
                            
            
                                    
            
            
                | 84 |  |  |             && $config['process_custom_data']['enabled'] | 
            
                                                                        
                            
            
                                    
            
            
                | 85 |  |  |             && array_key_exists('value', $config['process_custom_data']) | 
            
                                                                        
                            
            
                                    
            
            
                | 86 |  |  |         ) { | 
            
                                                                        
                            
            
                                    
            
            
                | 87 |  |  |             $variables[] = new Variable($this->configService->get('app.bpm.variables.scenario_custom_data'), $config['process_custom_data']['value'], Variable::TYPE_JSON); | 
            
                                                                        
                            
            
                                    
            
            
                | 88 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 89 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 90 |  |  |         $variables[] = new Variable($this->configService->get('app.bpm.variables.identity'), $submission->getIdentity()); | 
            
                                                                        
                            
            
                                    
            
            
                | 91 |  |  |         $variables[] = new Variable($this->configService->get('app.bpm.variables.identity_uuid'), $submission->getIdentityUuid()); | 
            
                                                                        
                            
            
                                    
            
            
                | 92 |  |  |         $variables[] = new Variable($this->configService->get('app.bpm.variables.submission_uuid'), $submission->getUuid()); | 
            
                                                                        
                            
            
                                    
            
            
                | 93 |  |  |         $variables[] = new Variable($this->configService->get('app.bpm.variables.start_data'), $submission->getData(), Variable::TYPE_JSON); | 
            
                                                                        
                            
            
                                    
            
            
                | 94 |  |  |         $parameters | 
            
                                                                        
                            
            
                                    
            
            
                | 95 |  |  |             ->setVariables($variables) | 
            
                                                                        
                            
            
                                    
            
            
                | 96 |  |  |             ->setKey($scenario->getConfig()['process_definition_key']) | 
            
                                                                        
                            
            
                                    
            
            
                | 97 |  |  |             ->setTenantId($scenario->getTenant()); | 
            
                                                                        
                            
            
                                    
            
            
                | 98 |  |  |         $this->api->get('workflow.process_definition')->start(null, $parameters); | 
            
                                                                        
                            
            
                                    
            
            
                | 99 |  |  |         $submission->setState(Submission::STATE_TRANSFERRED); | 
            
                                                                        
                            
            
                                    
            
            
                | 100 |  |  |         $manager = $this->submissionService->getManager(); | 
            
                                                                        
                            
            
                                    
            
            
                | 101 |  |  |         $manager->persist($submission); | 
            
                                                                        
                            
            
                                    
            
            
                | 102 |  |  |         $manager->flush(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 104 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 105 |  |  |  | 
            
                        
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