|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @link https://github.com/old-town/workflow-zf2 |
|
4
|
|
|
* @author Malofeykin Andrey <[email protected]> |
|
5
|
|
|
*/ |
|
6
|
|
|
namespace OldTown\Workflow\ZF2\Options; |
|
7
|
|
|
|
|
8
|
|
|
use Zend\Stdlib\AbstractOptions; |
|
9
|
|
|
|
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* Class ManagerOptions |
|
13
|
|
|
* |
|
14
|
|
|
* @package OldTown\Workflow\ZF2\Options |
|
15
|
|
|
*/ |
|
16
|
|
|
class ConfigurationOptions extends AbstractOptions |
|
17
|
|
|
{ |
|
18
|
|
|
/** |
|
19
|
|
|
* Конфиг хранилища запущенного состояния workflow |
|
20
|
|
|
* |
|
21
|
|
|
* @var array |
|
22
|
|
|
*/ |
|
23
|
|
|
protected $persistence; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* Конфиг фабрики по созданию workflow |
|
27
|
|
|
* |
|
28
|
|
|
* @var array |
|
29
|
|
|
*/ |
|
30
|
|
|
protected $factory; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* Конфиг сервиса работы с переменными в workflow |
|
34
|
|
|
* |
|
35
|
|
|
* @var array |
|
36
|
|
|
*/ |
|
37
|
|
|
protected $resolver; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* Настройки хранилища запущенного состояния workflow |
|
41
|
|
|
* |
|
42
|
|
|
* @var ConfigurationServiceOptions |
|
43
|
|
|
*/ |
|
44
|
|
|
protected $persistenceOptions; |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Настройки фабрики по созданию workflow |
|
48
|
|
|
* |
|
49
|
|
|
* @var ConfigurationServiceOptions |
|
50
|
|
|
*/ |
|
51
|
|
|
protected $factoryOptions; |
|
52
|
|
|
|
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* @return array |
|
56
|
|
|
*/ |
|
57
|
|
|
public function getPersistence() |
|
58
|
|
|
{ |
|
59
|
|
|
return $this->persistence; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* @param array $persistence |
|
64
|
|
|
* |
|
65
|
|
|
* @return $this |
|
66
|
|
|
*/ |
|
67
|
|
|
public function setPersistence(array $persistence) |
|
68
|
|
|
{ |
|
69
|
|
|
$this->persistence = $persistence; |
|
70
|
|
|
$this->persistenceOptions = null; |
|
71
|
|
|
|
|
72
|
|
|
return $this; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* @return array |
|
77
|
|
|
*/ |
|
78
|
|
|
public function getFactory() |
|
79
|
|
|
{ |
|
80
|
|
|
return $this->factory; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* @param array $factory |
|
85
|
|
|
* |
|
86
|
|
|
* @return $this |
|
87
|
|
|
*/ |
|
88
|
|
|
public function setFactory(array $factory) |
|
89
|
|
|
{ |
|
90
|
|
|
$this->factory = $factory; |
|
91
|
|
|
$this->factoryOptions = null; |
|
92
|
|
|
|
|
93
|
|
|
return $this; |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
/** |
|
97
|
|
|
* @return array |
|
98
|
|
|
*/ |
|
99
|
|
|
public function getResolver() |
|
100
|
|
|
{ |
|
101
|
|
|
return $this->resolver; |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
/** |
|
105
|
|
|
* @param string $resolver |
|
106
|
|
|
* |
|
107
|
|
|
* @return $this |
|
108
|
|
|
*/ |
|
109
|
|
|
public function setResolver($resolver) |
|
110
|
|
|
{ |
|
111
|
|
|
$this->resolver = $resolver; |
|
|
|
|
|
|
112
|
|
|
|
|
113
|
|
|
return $this; |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
/** |
|
117
|
|
|
* @return ConfigurationServiceOptions |
|
118
|
|
|
* |
|
119
|
|
|
* @throws Exception\InvalidPersistenceConfigException |
|
120
|
|
|
*/ |
|
121
|
|
|
public function getPersistenceOptions() |
|
122
|
|
|
{ |
|
123
|
|
|
if ($this->persistenceOptions) { |
|
124
|
|
|
return $this->persistenceOptions; |
|
125
|
|
|
} |
|
126
|
|
|
if (!$this->hasPersistenceOptions()) { |
|
127
|
|
|
$errMsg = 'Persistence options not specified'; |
|
128
|
|
|
throw new Exception\InvalidPersistenceConfigException($errMsg); |
|
129
|
|
|
} |
|
130
|
|
|
$this->persistenceOptions = new ConfigurationServiceOptions($this->persistence); |
|
131
|
|
|
return $this->persistenceOptions; |
|
132
|
|
|
} |
|
133
|
|
|
|
|
134
|
|
|
/** |
|
135
|
|
|
* Определяет есть ли настройки для хранилища |
|
136
|
|
|
* |
|
137
|
|
|
* @return bool |
|
138
|
|
|
*/ |
|
139
|
|
|
public function hasPersistenceOptions() |
|
140
|
|
|
{ |
|
141
|
|
|
return is_array($this->persistence); |
|
142
|
|
|
} |
|
143
|
|
|
|
|
144
|
|
|
/** |
|
145
|
|
|
* @return ConfigurationServiceOptions |
|
146
|
|
|
* |
|
147
|
|
|
* @throws Exception\InvalidFactoryConfigException |
|
148
|
|
|
*/ |
|
149
|
|
|
public function getFactoryOptions() |
|
150
|
|
|
{ |
|
151
|
|
|
if ($this->factoryOptions) { |
|
152
|
|
|
return $this->factoryOptions; |
|
153
|
|
|
} |
|
154
|
|
|
if (!$this->hasFactoryOptions()) { |
|
155
|
|
|
$errMsg = 'Factory options not specified'; |
|
156
|
|
|
throw new Exception\InvalidFactoryConfigException($errMsg); |
|
157
|
|
|
} |
|
158
|
|
|
$this->factoryOptions = new ConfigurationServiceOptions($this->factory); |
|
159
|
|
|
return $this->factoryOptions; |
|
160
|
|
|
} |
|
161
|
|
|
|
|
162
|
|
|
/** |
|
163
|
|
|
* Определяет есть ли настройки для фабрики |
|
164
|
|
|
* |
|
165
|
|
|
* @return bool |
|
166
|
|
|
*/ |
|
167
|
|
|
public function hasFactoryOptions() |
|
168
|
|
|
{ |
|
169
|
|
|
return is_array($this->factory); |
|
170
|
|
|
} |
|
171
|
|
|
} |
|
172
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..