|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Jabe\Engine\Impl\Core\Model; |
|
4
|
|
|
|
|
5
|
|
|
use Jabe\Engine\Delegate\VariableScopeInterface; |
|
6
|
|
|
use Jabe\Engine\Impl\Core\Variable\Mapping\Value\ParameterValueProviderInterface; |
|
7
|
|
|
|
|
8
|
|
|
class BaseCallableElement |
|
9
|
|
|
{ |
|
10
|
|
|
protected $definitionKeyValueProvider; |
|
11
|
|
|
protected $binding; |
|
12
|
|
|
protected $versionValueProvider; |
|
13
|
|
|
protected $versionTagValueProvider; |
|
14
|
|
|
protected $tenantIdProvider; |
|
15
|
|
|
protected $deploymentId; |
|
16
|
|
|
|
|
17
|
|
|
public function getDefinitionKey(VariableScopeInterface $variableScope): string |
|
18
|
|
|
{ |
|
19
|
|
|
$result = $this->definitionKeyValueProvider->getValue($variableScope); |
|
20
|
|
|
|
|
21
|
|
|
if ($result !== null && !(is_string($result))) { |
|
22
|
|
|
throw new \Exception("Cannot cast '" . $result . "' to string"); |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
return $result; |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
public function getDefinitionKeyValueProvider(): ParameterValueProviderInterface |
|
29
|
|
|
{ |
|
30
|
|
|
return $this->definitionKeyValueProvider; |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
public function setDefinitionKeyValueProvider(ParameterValueProviderInterface $definitionKey): void |
|
34
|
|
|
{ |
|
35
|
|
|
$this->definitionKeyValueProvider = $definitionKey; |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
public function getBinding(): ?string |
|
39
|
|
|
{ |
|
40
|
|
|
return $this->binding; |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
public function setBinding(string $binding): void |
|
44
|
|
|
{ |
|
45
|
|
|
$this->binding = $binding; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
public function isLatestBinding(): bool |
|
49
|
|
|
{ |
|
50
|
|
|
return $this->binding === null || CallableElementBinding::LATEST == $this->binding; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
public function isDeploymentBinding(): bool |
|
54
|
|
|
{ |
|
55
|
|
|
return CallableElementBinding::DEPLOYMENT == $this->binding; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
public function isVersionBinding(): bool |
|
59
|
|
|
{ |
|
60
|
|
|
return CallableElementBinding::VERSION == $this->binding; |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
public function isVersionTagBinding(): bool |
|
64
|
|
|
{ |
|
65
|
|
|
return CallableElementBinding::VERSION_TAG == $this->binding; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
public function getVersion(VariableScopeInterface $variableScope): ?int |
|
69
|
|
|
{ |
|
70
|
|
|
$result = $this->versionValueProvider->getValue($variableScope); |
|
71
|
|
|
|
|
72
|
|
|
if ($result !== null) { |
|
73
|
|
|
return intval($result); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
return null; |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
public function getVersionValueProvider(): ParameterValueProviderInterface |
|
80
|
|
|
{ |
|
81
|
|
|
return $this->versionValueProvider; |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
public function setVersionValueProvider(ParameterValueProviderInterface $version): void |
|
85
|
|
|
{ |
|
86
|
|
|
$this->versionValueProvider = $version; |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
public function getVersionTag(VariableScopeInterface $variableScope): ?string |
|
90
|
|
|
{ |
|
91
|
|
|
$result = $this->versionTagValueProvider->getValue($variableScope); |
|
92
|
|
|
|
|
93
|
|
|
if ($result !== null) { |
|
94
|
|
|
return strval($result); |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
return null; |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
public function getVersionTagValueProvider(): ParameterValueProviderInterface |
|
101
|
|
|
{ |
|
102
|
|
|
return $this->versionTagValueProvider; |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
public function setVersionTagValueProvider(ParameterValueProviderInterface $version): void |
|
106
|
|
|
{ |
|
107
|
|
|
$this->versionTagValueProvider = $version; |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
public function setTenantIdProvider(ParameterValueProviderInterface $tenantIdProvider): void |
|
111
|
|
|
{ |
|
112
|
|
|
$this->tenantIdProvider = $tenantIdProvider; |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
public function getDeploymentId(): ?string |
|
116
|
|
|
{ |
|
117
|
|
|
return $this->deploymentId; |
|
118
|
|
|
} |
|
119
|
|
|
|
|
120
|
|
|
public function setDeploymentId(string $deploymentId): void |
|
121
|
|
|
{ |
|
122
|
|
|
$this->deploymentId = $deploymentId; |
|
123
|
|
|
} |
|
124
|
|
|
|
|
125
|
|
|
public function getDefinitionTenantId(VariableScopeInterface $variableScope, string $defaultTenantId = null): ?string |
|
126
|
|
|
{ |
|
127
|
|
|
if ($this->tenantIdProvider !== null) { |
|
128
|
|
|
return $this->tenantIdProvider->getValue($variableScope); |
|
129
|
|
|
} else { |
|
130
|
|
|
return $defaultTenantId; |
|
131
|
|
|
} |
|
132
|
|
|
} |
|
133
|
|
|
|
|
134
|
|
|
public function getTenantIdProvider(): ParameterValueProviderInterface |
|
135
|
|
|
{ |
|
136
|
|
|
return $this->tenantIdProvider; |
|
137
|
|
|
} |
|
138
|
|
|
|
|
139
|
|
|
/** |
|
140
|
|
|
* @return bool true if any of the references that specify the callable element are non-literal and need to be resolved with |
|
141
|
|
|
* potential side effects to determine the process or case definition that is to be called. |
|
142
|
|
|
*/ |
|
143
|
|
|
public function hasDynamicReferences(): bool |
|
144
|
|
|
{ |
|
145
|
|
|
return ($this->tenantIdProvider !== null && $this->tenantIdProvider->isDynamic()) |
|
146
|
|
|
|| $this->definitionKeyValueProvider->isDynamic() |
|
147
|
|
|
|| $this->versionValueProvider->isDynamic() |
|
148
|
|
|
|| $this->versionTagValueProvider->isDynamic(); |
|
149
|
|
|
} |
|
150
|
|
|
} |
|
151
|
|
|
|