1 | <?php |
||
72 | class CircleService { |
||
73 | |||
74 | |||
75 | use TArrayTools; |
||
76 | use TStringTools; |
||
77 | |||
78 | |||
79 | /** @var CircleRequest */ |
||
80 | private $circleRequest; |
||
81 | |||
82 | /** @var MemberRequest */ |
||
83 | private $memberRequest; |
||
84 | |||
85 | /** @var RemoteStreamService */ |
||
86 | private $remoteStreamService; |
||
87 | |||
88 | /** @var FederatedUserService */ |
||
89 | private $federatedUserService; |
||
90 | |||
91 | /** @var FederatedEventService */ |
||
92 | private $federatedEventService; |
||
93 | |||
94 | /** @var MemberService */ |
||
95 | private $memberService; |
||
96 | |||
97 | /** @var ConfigService */ |
||
98 | private $configService; |
||
99 | |||
100 | |||
101 | /** |
||
102 | * CircleService constructor. |
||
103 | * |
||
104 | * @param CircleRequest $circleRequest |
||
105 | * @param MemberRequest $memberRequest |
||
106 | * @param RemoteStreamService $remoteStreamService |
||
107 | * @param FederatedUserService $federatedUserService |
||
108 | * @param FederatedEventService $federatedEventService |
||
109 | * @param MemberService $memberService |
||
110 | * @param ConfigService $configService |
||
111 | */ |
||
112 | public function __construct( |
||
125 | |||
126 | |||
127 | /** |
||
128 | * @param string $name |
||
129 | * @param FederatedUser|null $owner |
||
130 | * @param bool $personal |
||
131 | * @param bool $local |
||
132 | * |
||
133 | * @return array |
||
134 | * @throws FederatedEventException |
||
135 | * @throws FederatedItemException |
||
136 | * @throws InitiatorNotConfirmedException |
||
137 | * @throws InitiatorNotFoundException |
||
138 | * @throws OwnerNotFoundException |
||
139 | * @throws RemoteInstanceException |
||
140 | * @throws RemoteNotFoundException |
||
141 | * @throws RemoteResourceNotFoundException |
||
142 | * @throws UnknownRemoteException |
||
143 | * @throws RequestBuilderException |
||
144 | */ |
||
145 | public function create( |
||
194 | |||
195 | |||
196 | /** |
||
197 | * @param string $circleId |
||
198 | * |
||
199 | * @return array |
||
200 | * @throws CircleNotFoundException |
||
201 | * @throws FederatedEventException |
||
202 | * @throws FederatedItemException |
||
203 | * @throws InitiatorNotConfirmedException |
||
204 | * @throws InitiatorNotFoundException |
||
205 | * @throws OwnerNotFoundException |
||
206 | * @throws RemoteInstanceException |
||
207 | * @throws RemoteNotFoundException |
||
208 | * @throws RemoteResourceNotFoundException |
||
209 | * @throws RequestBuilderException |
||
210 | * @throws UnknownRemoteException |
||
211 | */ |
||
212 | public function destroy(string $circleId): array { |
||
223 | |||
224 | |||
225 | /** |
||
226 | * @param string $circleId |
||
227 | * @param int $config |
||
228 | * |
||
229 | * @return array |
||
230 | * @throws CircleNotFoundException |
||
231 | * @throws FederatedEventException |
||
232 | * @throws FederatedItemException |
||
233 | * @throws InitiatorNotConfirmedException |
||
234 | * @throws InitiatorNotFoundException |
||
235 | * @throws OwnerNotFoundException |
||
236 | * @throws RemoteInstanceException |
||
237 | * @throws RemoteNotFoundException |
||
238 | * @throws RemoteResourceNotFoundException |
||
239 | * @throws UnknownRemoteException |
||
240 | * @throws RequestBuilderException |
||
241 | */ |
||
242 | public function updateConfig(string $circleId, int $config): array { |
||
253 | |||
254 | |||
255 | /** |
||
256 | * @param string $circleId |
||
257 | * @param string $name |
||
258 | * |
||
259 | * @return array |
||
260 | * @throws CircleNotFoundException |
||
261 | * @throws FederatedEventException |
||
262 | * @throws FederatedItemException |
||
263 | * @throws InitiatorNotConfirmedException |
||
264 | * @throws InitiatorNotFoundException |
||
265 | * @throws OwnerNotFoundException |
||
266 | * @throws RemoteInstanceException |
||
267 | * @throws RemoteNotFoundException |
||
268 | * @throws RemoteResourceNotFoundException |
||
269 | * @throws RequestBuilderException |
||
270 | * @throws UnknownRemoteException |
||
271 | */ |
||
272 | public function updateName(string $circleId, string $name): array { |
||
273 | $circle = $this->getCircle($circleId); |
||
274 | |||
275 | $event = new FederatedEvent(CircleEdit::class); |
||
276 | $event->setCircle($circle); |
||
277 | $event->setParams(new SimpleDataStore(['name' => $name])); |
||
278 | |||
279 | $this->federatedEventService->newEvent($event); |
||
280 | |||
281 | return $event->getOutcome(); |
||
282 | } |
||
283 | |||
284 | /** |
||
285 | * @param string $circleId |
||
286 | * @param string $description |
||
287 | * |
||
288 | * @return array |
||
289 | * @throws CircleNotFoundException |
||
290 | * @throws FederatedEventException |
||
291 | * @throws FederatedItemException |
||
292 | * @throws InitiatorNotConfirmedException |
||
293 | * @throws InitiatorNotFoundException |
||
294 | * @throws OwnerNotFoundException |
||
295 | * @throws RemoteInstanceException |
||
296 | * @throws RemoteNotFoundException |
||
297 | * @throws RemoteResourceNotFoundException |
||
298 | * @throws RequestBuilderException |
||
299 | * @throws UnknownRemoteException |
||
300 | */ |
||
301 | public function updateDescription(string $circleId, string $description): array { |
||
312 | |||
313 | /** |
||
314 | * @param string $circleId |
||
315 | * @param array $settings |
||
316 | * |
||
317 | * @return array |
||
318 | * @throws CircleNotFoundException |
||
319 | * @throws FederatedEventException |
||
320 | * @throws FederatedItemException |
||
321 | * @throws InitiatorNotConfirmedException |
||
322 | * @throws InitiatorNotFoundException |
||
323 | * @throws OwnerNotFoundException |
||
324 | * @throws RemoteInstanceException |
||
325 | * @throws RemoteNotFoundException |
||
326 | * @throws RemoteResourceNotFoundException |
||
327 | * @throws RequestBuilderException |
||
328 | * @throws UnknownRemoteException |
||
329 | */ |
||
330 | public function updateSettings(string $circleId, array $settings): array { |
||
341 | |||
342 | |||
343 | /** |
||
344 | * @param string $circleId |
||
345 | * |
||
346 | * @return array |
||
347 | * @throws CircleNotFoundException |
||
348 | * @throws FederatedEventException |
||
349 | * @throws FederatedItemException |
||
350 | * @throws InitiatorNotConfirmedException |
||
351 | * @throws InitiatorNotFoundException |
||
352 | * @throws OwnerNotFoundException |
||
353 | * @throws RemoteInstanceException |
||
354 | * @throws RemoteNotFoundException |
||
355 | * @throws RemoteResourceNotFoundException |
||
356 | * @throws UnknownRemoteException |
||
357 | * @throws RequestBuilderException |
||
358 | */ |
||
359 | public function circleJoin(string $circleId): array { |
||
375 | |||
376 | |||
377 | /** |
||
378 | * @param string $circleId |
||
379 | * @param bool $force |
||
380 | * |
||
381 | * @return array |
||
382 | * @throws CircleNotFoundException |
||
383 | * @throws FederatedEventException |
||
384 | * @throws FederatedItemException |
||
385 | * @throws InitiatorNotConfirmedException |
||
386 | * @throws InitiatorNotFoundException |
||
387 | * @throws OwnerNotFoundException |
||
388 | * @throws RemoteInstanceException |
||
389 | * @throws RemoteNotFoundException |
||
390 | * @throws RemoteResourceNotFoundException |
||
391 | * @throws RequestBuilderException |
||
392 | * @throws UnknownRemoteException |
||
393 | */ |
||
394 | public function circleLeave(string $circleId, bool $force = false): array { |
||
407 | |||
408 | |||
409 | /** |
||
410 | * @param string $circleId |
||
411 | * @param int $filter |
||
412 | * |
||
413 | * @return Circle |
||
414 | * @throws CircleNotFoundException |
||
415 | * @throws InitiatorNotFoundException |
||
416 | * @throws RequestBuilderException |
||
417 | */ |
||
418 | public function getCircle( |
||
431 | |||
432 | |||
433 | /** |
||
434 | * @param Circle|null $circleFilter |
||
435 | * @param Member|null $memberFilter |
||
436 | * @param SimpleDataStore|null $params |
||
437 | * |
||
438 | * @return Circle[] |
||
439 | * @throws InitiatorNotFoundException |
||
440 | * @throws RequestBuilderException |
||
441 | */ |
||
442 | public function getCircles( |
||
472 | |||
473 | |||
474 | /** |
||
475 | * @param Circle $circle |
||
476 | * |
||
477 | * @throws RequestBuilderException |
||
478 | */ |
||
479 | public function confirmName(Circle $circle): void { |
||
488 | |||
489 | /** |
||
490 | * @param Circle $circle |
||
491 | * |
||
492 | * @throws RequestBuilderException |
||
493 | */ |
||
494 | private function confirmDisplayName(Circle $circle) { |
||
517 | |||
518 | |||
519 | /** |
||
520 | * @param Circle $circle |
||
521 | * |
||
522 | * @throws RequestBuilderException |
||
523 | */ |
||
524 | private function confirmSanitizedName(Circle $circle) { |
||
551 | |||
552 | /** |
||
553 | * @param string $name |
||
554 | * |
||
555 | * @return string |
||
556 | */ |
||
557 | public function sanitizeName(string $name): string { |
||
568 | |||
569 | |||
570 | /** |
||
571 | * @param Circle $circle |
||
572 | * |
||
573 | * @throws MembersLimitException |
||
574 | */ |
||
575 | public function confirmCircleNotFull(Circle $circle): void { |
||
580 | |||
581 | |||
582 | /** |
||
583 | * @param Circle $circle |
||
584 | * |
||
585 | * @return bool |
||
586 | * @throws RequestBuilderException |
||
587 | */ |
||
588 | public function isCircleFull(Circle $circle): bool { |
||
603 | |||
604 | } |
||
605 | |||
606 |
This check looks for access to properties that are not accessible from the current context.
If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.