1 | <?php |
||||
2 | |||||
3 | namespace Jabe\Impl\Batch; |
||||
4 | |||||
5 | use Jabe\BatchPermissions; |
||||
6 | use Jabe\Batch\BatchInterface; |
||||
7 | use Jabe\Impl\{ |
||||
8 | ProcessEngineLogger, |
||||
9 | RestartProcessInstanceBuilderImpl, |
||||
10 | RestartProcessInstancesBatchConfiguration |
||||
11 | }; |
||||
12 | use Jabe\Impl\Batch\Builder\{ |
||||
13 | BatchBuilder, |
||||
14 | OperationLogInstanceCountHandlerInterface |
||||
15 | }; |
||||
16 | use Jabe\Impl\Cmd\{ |
||||
17 | AbstractProcessInstanceModificationCommand, |
||||
18 | AbstractRestartProcessInstanceCmd, |
||||
19 | CommandLogger |
||||
20 | }; |
||||
21 | use Jabe\Impl\Interceptor\{ |
||||
22 | CommandContext, |
||||
23 | CommandExecutorInterface |
||||
24 | }; |
||||
25 | use Jabe\Impl\Persistence\Entity\ProcessDefinitionEntity; |
||||
26 | use Jabe\Impl\Util\EnsureUtil; |
||||
27 | |||||
28 | class RestartProcessInstancesBatchCmd extends AbstractRestartProcessInstanceCmd |
||||
29 | { |
||||
30 | //private final CommandLogger LOG = ProcessEngineLogger.CMD_LOGGER; |
||||
31 | |||||
32 | public function __construct(CommandExecutorInterface $commandExecutor, RestartProcessInstanceBuilderImpl $builder) |
||||
33 | { |
||||
34 | parent::__construct($commandExecutor, $builder); |
||||
35 | } |
||||
36 | |||||
37 | public function execute(CommandContext $commandContext) |
||||
38 | { |
||||
39 | $collectedInstanceIds = $this->collectProcessInstanceIds(); |
||||
40 | |||||
41 | $instructions = $this->builder->getInstructions(); |
||||
42 | EnsureUtil::ensureNotEmpty("Restart instructions cannot be empty", "instructions", $instructions); |
||||
43 | EnsureUtil::ensureNotEmpty("Process instance ids cannot be empty", "processInstanceIds", $collectedInstanceIds); |
||||
44 | EnsureUtil::ensureNotContainsNull("Process instance ids cannot be null", "processInstanceIds", $collectedInstanceIds); |
||||
45 | |||||
46 | $processDefinitionId = $this->builder->getProcessDefinitionId(); |
||||
47 | $processDefinition = $this->getProcessDefinition($commandContext, $processDefinitionId); |
||||
48 | |||||
49 | EnsureUtil::ensureNotNull("Process definition cannot be null", "processDefinition", $processDefinition); |
||||
50 | EnsureUtil::ensureTenantAuthorized($commandContext, $processDefinition); |
||||
0 ignored issues
–
show
|
|||||
51 | |||||
52 | $tenantId = $processDefinition->getTenantId(); |
||||
53 | |||||
54 | $scope = $this; |
||||
55 | return (new BatchBuilder($commandContext)) |
||||
56 | ->type(BatchInterface::TYPE_PROCESS_INSTANCE_RESTART) |
||||
57 | ->config(getConfiguration($collectedInstanceIds, $processDefinition->getDeploymentId())) |
||||
0 ignored issues
–
show
The function
getConfiguration was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
58 | ->permission(BatchPermissions::createBatchRestartProcessInstances()) |
||||
59 | ->tenantId($tenantId) |
||||
0 ignored issues
–
show
It seems like
$tenantId can also be of type null ; however, parameter $tenantId of Jabe\Impl\Batch\Builder\BatchBuilder::tenantId() does only seem to accept string , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
60 | ->operationLogHandler(new class ($scope, $processDefinition) implements OperationLogInstanceCountHandlerInterface { |
||||
61 | private $scope; |
||||
62 | private $processDefinition; |
||||
63 | |||||
64 | public function __construct($scope, $processDefinition) |
||||
65 | { |
||||
66 | $this->scope = $scope; |
||||
67 | $this->processDefinition = $processDefinition; |
||||
68 | } |
||||
69 | |||||
70 | public function write(CommandContext $commandContext, int $instanceCount): void |
||||
71 | { |
||||
72 | $op = $this->scope->writeUserOperationLog; |
||||
73 | $op($commandContext, $this->processDefinition, $instanceCount, true); |
||||
74 | } |
||||
75 | }) |
||||
76 | ->build(); |
||||
77 | } |
||||
78 | |||||
79 | protected function ensureTenantAuthorized(CommandContext $commandContext, ProcessDefinitionEntity $processDefinition): void |
||||
80 | { |
||||
81 | if (!$commandContext->getTenantManager()->isAuthenticatedTenant($processDefinition->getTenantId())) { |
||||
82 | //throw LOG.exceptionCommandWithUnauthorizedTenant("restart process instances of process definition '" + processDefinition.getId() + "'"); |
||||
83 | throw new \Exception("restart process instances of process definition '" . $processDefinition->getId() . "'"); |
||||
84 | } |
||||
85 | } |
||||
86 | |||||
87 | public function getConfiguration(array $instanceIds, string $deploymentId): BatchConfiguration |
||||
88 | { |
||||
89 | return new RestartProcessInstancesBatchConfiguration( |
||||
90 | $instanceIds, |
||||
91 | DeploymentMappings::of(new DeploymentMapping($deploymentId, count($instanceIds))), |
||||
92 | $this->builder->getInstructions(), |
||||
93 | $this->builder->getProcessDefinitionId(), |
||||
94 | $this->builder->isInitialVariables(), |
||||
95 | $this->builder->isSkipCustomListeners(), |
||||
96 | $this->builder->isSkipIoMappings(), |
||||
97 | $this->builder->isWithoutBusinessKey() |
||||
98 | ); |
||||
99 | } |
||||
100 | } |
||||
101 |
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.