circleRequest = $circleRequest; $this->memberRequest = $memberRequest; $this->circleService = $circleService; $this->membershipService = $membershipService; $this->eventService = $eventService; } /** * @param FederatedEvent $event */ public function verify(FederatedEvent $event): void { $circle = $event->getCircle(); $event->setOutcome($this->serialize($circle)); } /** * @param FederatedEvent $event * * @throws FederatedEventDSyncException * @throws InvalidIdException * @throws RequestBuilderException */ public function manage(FederatedEvent $event): void { $circle = $event->getCircle(); $owner = $circle->getOwner(); try { $this->circleRequest->getCircle($circle->getSingleId()); throw new FederatedEventDSyncException('Circle already exist'); } catch (CircleNotFoundException $e) { } $this->circleService->confirmName($circle); try { $this->memberRequest->getMemberById($owner->getId()); throw new FederatedEventDSyncException('Owner already exist'); } catch (MemberNotFoundException $e) { } if ($owner->hasInvitedBy()) { $owner->setNoteObj('invitedBy', $owner->getInvitedBy()); } $this->circleRequest->save($circle); $this->memberRequest->save($owner); $this->membershipService->onUpdate($owner->getSingleId()); $this->membershipService->updatePopulation($circle); $this->eventService->circleCreating($event); } /** * @param FederatedEvent $event * @param array $results */ public function result(FederatedEvent $event, array $results): void { $this->eventService->circleCreated($event, $results); } }