Issues (2551)

...teProcessInstanceSuspensionStateBuilderImpl.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace Jabe\Impl\Runtime;
4
5
use Jabe\History\HistoricProcessInstanceQueryInterface;
6
use Jabe\Impl\{
7
    ProcessEngineLogger,
8
    UpdateProcessInstancesSuspensionStateBuilderImpl
9
};
10
use Jabe\Impl\Cmd\{
11
    ActivateProcessInstanceCmd,
12
    CommandLogger,
13
    SuspendProcessInstanceCmd
14
};
15
use Jabe\Impl\Interceptor\CommandExecutorInterface;
16
use Jabe\Runtime\{
17
    ProcessInstanceQueryInterface,
18
    UpdateProcessInstanceSuspensionStateBuilderInterface,
19
    UpdateProcessInstanceSuspensionStateSelectBuilderInterface,
20
    UpdateProcessInstanceSuspensionStateTenantBuilderInterface,
21
    UpdateProcessInstancesSuspensionStateBuilderInterface
22
};
23
24
class UpdateProcessInstanceSuspensionStateBuilderImpl implements UpdateProcessInstanceSuspensionStateBuilderInterface, UpdateProcessInstanceSuspensionStateSelectBuilderInterface, UpdateProcessInstanceSuspensionStateTenantBuilderInterface
25
{
26
    //private final static CommandLogger LOG = ProcessEngineLogger.CMD_LOGGER;
27
28
    protected $commandExecutor;
29
30
    protected $processInstanceId;
31
32
    protected $processDefinitionKey;
33
    protected $processDefinitionId;
34
35
    protected $processDefinitionTenantId;
36
    protected $isProcessDefinitionTenantIdSet = false;
37
38
    public function __construct(?CommandExecutorInterface $commandExecutor)
39
    {
40
        $this->commandExecutor = $commandExecutor;
41
    }
42
43
    public function byProcessInstanceIds(array $processInstanceIds): UpdateProcessInstancesSuspensionStateBuilderInterface
44
    {
45
        return (new UpdateProcessInstancesSuspensionStateBuilderImpl($this->commandExecutor))->byProcessInstanceIds($processInstanceIds);
46
    }
47
48
    public function byHistoricProcessInstanceQuery(HistoricProcessInstanceQueryInterface $historicProcessInstanceQuery): UpdateProcessInstancesSuspensionStateBuilderInterface
49
    {
50
        return (new UpdateProcessInstancesSuspensionStateBuilderImpl($this->commandExecutor))->byHistoricProcessInstanceQuery($historicProcessInstanceQuery);
51
    }
52
53
    public function byProcessInstanceId(string $processInstanceId): UpdateProcessInstanceSuspensionStateBuilderImpl
54
    {
55
        $this->processInstanceId = $processInstanceId;
56
        return $this;
57
    }
58
59
    public function byProcessDefinitionId(string $processDefinitionId): UpdateProcessInstanceSuspensionStateBuilderImpl
60
    {
61
        $this->processDefinitionId = $processDefinitionId;
62
        return $this;
63
    }
64
65
    public function byProcessDefinitionKey(string $processDefinitionKey): UpdateProcessInstanceSuspensionStateBuilderImpl
66
    {
67
        $this->processDefinitionKey = $processDefinitionKey;
68
        return $this;
69
    }
70
71
    public function processDefinitionWithoutTenantId(): UpdateProcessInstanceSuspensionStateBuilderImpl
72
    {
73
        $this->processDefinitionTenantId = null;
74
        $this->isProcessDefinitionTenantIdSet = true;
75
        return $this;
76
    }
77
78
    public function processDefinitionTenantId(string $tenantId): UpdateProcessInstanceSuspensionStateBuilderImpl
79
    {
80
        $this->processDefinitionTenantId = $tenantId;
81
        $this->isProcessDefinitionTenantIdSet = true;
82
        return $this;
83
    }
84
85
    public function activate(): void
86
    {
87
        $this->validateParameters();
88
89
        $command = new ActivateProcessInstanceCmd($this);
90
        $this->commandExecutor->execute($command);
0 ignored issues
show
The method execute() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

90
        $this->commandExecutor->/** @scrutinizer ignore-call */ 
91
                                execute($command);

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.

Loading history...
91
    }
92
93
    public function suspend(): void
94
    {
95
        $this->validateParameters();
96
97
        $command = new SuspendProcessInstanceCmd($this);
98
        $this->commandExecutor->execute($command);
99
    }
100
101
    protected function validateParameters(): void
102
    {
103
        if ($this->processInstanceId === null && $this->processDefinitionId === null && $this->processDefinitionKey === null) {
104
            throw new \Exception("Need to specify either a process instance id, a process definition id or a process definition key.");
105
        }
106
        if ($this->isProcessDefinitionTenantIdSet && ($this->processInstanceId !== null || $this->processDefinitionId !== null)) {
107
            //throw LOG.exceptionUpdateSuspensionStateForTenantOnlyByProcessDefinitionKey();
108
        }
109
        if ($this->commandExecutor === null) {
110
            throw new \Exception("Command executor is undefined!");
111
        }
112
    }
113
114
    public function getProcessDefinitionKey(): ?string
115
    {
116
        return $this->processDefinitionKey;
117
    }
118
119
    public function getProcessDefinitionId(): ?string
120
    {
121
        return $this->processDefinitionId;
122
    }
123
124
    public function getProcessDefinitionTenantId(): ?string
125
    {
126
        return $this->processDefinitionTenantId;
127
    }
128
129
    public function isProcessDefinitionTenantIdSet(): bool
130
    {
131
        return $this->isProcessDefinitionTenantIdSet;
132
    }
133
134
    public function getProcessInstanceId(): ?string
135
    {
136
        return $this->processInstanceId;
137
    }
138
}
139