1 | <?php |
||
22 | abstract class AbstractUpdateRequest extends AbstractApiRequest |
||
23 | { |
||
24 | use ExpandTrait; |
||
25 | |||
26 | const ACTION = 'action'; |
||
27 | const ACTIONS = 'actions'; |
||
28 | const VERSION = 'version'; |
||
29 | const ACTION_MAX_LIMIT = 500; |
||
30 | const ACTION_WARNING_TRESHOLD = 400; |
||
31 | |||
32 | /** |
||
33 | * @var string |
||
34 | */ |
||
35 | protected $id; |
||
36 | |||
37 | /** |
||
38 | * @var int |
||
39 | */ |
||
40 | protected $version; |
||
41 | |||
42 | /** |
||
43 | * @var AbstractAction[] |
||
44 | */ |
||
45 | protected $actions = []; |
||
46 | |||
47 | protected $overLimit = false; |
||
48 | |||
49 | /** |
||
50 | * @param JsonEndpoint $endpoint |
||
51 | * @param string $id |
||
52 | * @param int $version |
||
53 | * @param array $actions |
||
54 | * @param Context $context |
||
55 | */ |
||
56 | 427 | public function __construct($endpoint, $id, $version, array $actions = [], Context $context = null) |
|
61 | |||
62 | /** |
||
63 | * @return AbstractAction[] |
||
64 | */ |
||
65 | 367 | public function getActions() |
|
69 | |||
70 | /** |
||
71 | * @return bool |
||
72 | */ |
||
73 | 1 | public function hasActions() |
|
74 | { |
||
75 | 1 | return (0 !== count($this->actions)); |
|
76 | } |
||
77 | |||
78 | /** |
||
79 | * @param AbstractAction[] $actions |
||
80 | * @return $this |
||
81 | */ |
||
82 | 427 | public function setActions(array $actions) |
|
95 | |||
96 | /** |
||
97 | * @param AbstractAction $action |
||
98 | * @return $this |
||
99 | */ |
||
100 | 353 | public function addAction(AbstractAction $action) |
|
110 | |||
111 | /** |
||
112 | * @param array $action |
||
113 | * @return $this |
||
114 | */ |
||
115 | 8 | public function addActionAsArray(array $action) |
|
122 | |||
123 | 361 | protected function checkActionLimit() |
|
146 | |||
147 | /** |
||
148 | * @return string |
||
149 | */ |
||
150 | 371 | public function getId() |
|
154 | |||
155 | /** |
||
156 | * @param string $id |
||
157 | * @return $this |
||
158 | */ |
||
159 | 427 | public function setId($id) |
|
165 | |||
166 | /** |
||
167 | * @return int |
||
168 | */ |
||
169 | 372 | public function getVersion() |
|
173 | |||
174 | /** |
||
175 | * @param int $version |
||
176 | * @return $this |
||
177 | */ |
||
178 | 427 | public function setVersion($version) |
|
184 | |||
185 | /** |
||
186 | * @return string |
||
187 | * @internal |
||
188 | */ |
||
189 | 348 | protected function getPath() |
|
193 | |||
194 | /** |
||
195 | * @return JsonRequest |
||
196 | * @internal |
||
197 | */ |
||
198 | 365 | public function httpRequest() |
|
203 | |||
204 | /** |
||
205 | * @param ResponseInterface $response |
||
206 | * @return ResourceResponse |
||
207 | * @internal |
||
208 | */ |
||
209 | 345 | public function buildResponse(ResponseInterface $response) |
|
213 | } |
||
214 |