bingo-soft /
jabe
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Jabe\Impl\Cmd; |
||
| 4 | |||
| 5 | use Jabe\AuthorizationException; |
||
| 6 | use Jabe\Impl\Bpmn\Behavior\CallActivityBehavior; |
||
| 7 | use Jabe\Impl\Interceptor\{ |
||
| 8 | CommandInterface, |
||
| 9 | CommandContext |
||
| 10 | }; |
||
| 11 | use Jabe\Impl\Persistence\Entity\ProcessDefinitionEntity; |
||
| 12 | use Jabe\Impl\Repository\CalledProcessDefinitionImpl; |
||
| 13 | use Jabe\Impl\Util\CallableElementUtil; |
||
| 14 | |||
| 15 | class GetStaticCalledProcessDefinitionCmd implements CommandInterface |
||
| 16 | { |
||
| 17 | protected $processDefinitionId; |
||
| 18 | |||
| 19 | public function __construct(string $processDefinitionId) |
||
| 20 | { |
||
| 21 | $this->processDefinitionId = $processDefinitionId; |
||
| 22 | } |
||
| 23 | |||
| 24 | protected function findCallActivitiesInProcess(ProcessDefinitionEntity $processDefinition): array |
||
| 25 | { |
||
| 26 | $callActivities = []; |
||
| 27 | |||
| 28 | $toCheck = $processDefinition->getActivities(); |
||
| 29 | while (!empty($toCheck)) { |
||
| 30 | $candidate = array_shift($toCheck); |
||
| 31 | |||
| 32 | if (!empty($candidate->getActivities())) { |
||
| 33 | $toCheck = array_merge($toCheck, $candidate->getActivities()); |
||
| 34 | } |
||
| 35 | if ($candidate->getActivityBehavior() instanceof CallActivityBehavior) { |
||
| 36 | $callActivities[] = $candidate; |
||
| 37 | } |
||
| 38 | } |
||
| 39 | return $callActivities; |
||
| 40 | } |
||
| 41 | |||
| 42 | public function execute(CommandContext $commandContext) |
||
| 43 | { |
||
| 44 | $processDefinition = (new GetDeployedProcessDefinitionCmd($this->processDefinitionId, true))->execute($commandContext); |
||
| 45 | |||
| 46 | $callActivities = $this->findCallActivitiesInProcess($processDefinition); |
||
| 47 | |||
| 48 | $calledProcessDefinitionsById = []; |
||
| 49 | |||
| 50 | foreach ($callActivities as $activity) { |
||
| 51 | $behavior = $activity->getActivityBehavior(); |
||
| 52 | $callableElement = $behavior->getCallableElement(); |
||
| 53 | $activityId = $activity->getActivityId(); |
||
| 54 | |||
| 55 | $tenantId = $processDefinition->getTenantId(); |
||
| 56 | $calledProcess = CallableElementUtil::getStaticallyBoundProcessDefinition( |
||
| 57 | $this->processDefinitionId, |
||
| 58 | $activityId, |
||
| 59 | $callableElement, |
||
| 60 | $tenantId |
||
| 61 | ); |
||
| 62 | |||
| 63 | if ($calledProcess !== null) { |
||
| 64 | if (!array_key_exists($calledProcess->getId(), $calledProcessDefinitionsById)) { |
||
| 65 | try { |
||
| 66 | foreach ($commandContext->getProcessEngineConfiguration()->getCommandCheckers() as $checker) { |
||
|
0 ignored issues
–
show
|
|||
| 67 | $checker->checkReadProcessDefinition($calledProcess); |
||
| 68 | } |
||
| 69 | $result = new CalledProcessDefinitionImpl($calledProcess, $this->processDefinitionId); |
||
| 70 | $result->addCallingCallActivity($activityId); |
||
| 71 | $calledProcessDefinitionsById[$calledProcess->getId()] = $result; |
||
| 72 | } catch (AuthorizationException $e) { |
||
| 73 | // unauthorized Process definitions will not be added. |
||
| 74 | //CMD_LOGGER.debugNotAllowedToResolveCalledProcess(calledProcess.getId(), processDefinitionId, activityId, e); |
||
| 75 | } |
||
| 76 | } else { |
||
| 77 | $calledProcessDefinitionsById[$calledProcess->getId()]->addCallingCallActivity($activityId); |
||
| 78 | } |
||
| 79 | } |
||
| 80 | } |
||
| 81 | return array_values($calledProcessDefinitionsById); |
||
| 82 | } |
||
| 83 | } |
||
| 84 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.