| @@ 338-358 (lines=21) @@ | ||
| 335 | * @return null|Member |
|
| 336 | * @throws \Exception |
|
| 337 | */ |
|
| 338 | public function joinCircle($circleUniqueId) { |
|
| 339 | ||
| 340 | try { |
|
| 341 | $circle = $this->circlesRequest->getCircle($circleUniqueId, $this->userId); |
|
| 342 | ||
| 343 | $member = $this->membersRequest->getFreshNewMember( |
|
| 344 | $circleUniqueId, $this->userId, Member::TYPE_USER |
|
| 345 | ); |
|
| 346 | $member->hasToBeAbleToJoinTheCircle(); |
|
| 347 | $this->checkThatCircleIsNotFull($circle); |
|
| 348 | ||
| 349 | $member->joinCircle($circle->getType()); |
|
| 350 | $this->membersRequest->updateMember($member); |
|
| 351 | ||
| 352 | $this->eventsService->onMemberNew($circle, $member); |
|
| 353 | } catch (\Exception $e) { |
|
| 354 | throw $e; |
|
| 355 | } |
|
| 356 | ||
| 357 | return $member; |
|
| 358 | } |
|
| 359 | ||
| 360 | ||
| 361 | /** |
|
| @@ 103-122 (lines=20) @@ | ||
| 100 | * @return array |
|
| 101 | * @throws \Exception |
|
| 102 | */ |
|
| 103 | public function linkGroup($circleUniqueId, $groupId) { |
|
| 104 | ||
| 105 | try { |
|
| 106 | $circle = $this->circlesRequest->getCircle($circleUniqueId, $this->userId); |
|
| 107 | $this->circlesService->hasToBeAdmin($circle->getHigherViewer()); |
|
| 108 | ||
| 109 | $group = $this->getFreshNewMember($circleUniqueId, $groupId); |
|
| 110 | } catch (\Exception $e) { |
|
| 111 | throw $e; |
|
| 112 | } |
|
| 113 | ||
| 114 | $group->setLevel(Member::LEVEL_MEMBER); |
|
| 115 | $this->membersRequest->updateGroup($group); |
|
| 116 | ||
| 117 | $this->eventsService->onGroupLink($circle, $group); |
|
| 118 | ||
| 119 | return $this->membersRequest->getGroupsFromCircle( |
|
| 120 | $circleUniqueId, $circle->getHigherViewer() |
|
| 121 | ); |
|
| 122 | } |
|
| 123 | ||
| 124 | ||
| 125 | /** |
|