| @@ 23-45 (lines=23) @@ | ||
| 20 | use Symfony\Component\HttpFoundation\Request; |
|
| 21 | use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; |
|
| 22 | ||
| 23 | class AddMemberToOrganization |
|
| 24 | { |
|
| 25 | private $commandBus; |
|
| 26 | ||
| 27 | private $currentUser; |
|
| 28 | ||
| 29 | public function __construct(CommandBus $commandBus, TokenStorageInterface $tokenStorage) |
|
| 30 | { |
|
| 31 | $this->commandBus = $commandBus; |
|
| 32 | $this->currentUser = $tokenStorage->getToken()->getUser(); |
|
| 33 | } |
|
| 34 | ||
| 35 | public function __invoke(Request $request) : JsonResponse |
|
| 36 | { |
|
| 37 | $userId = $request->get('userId'); |
|
| 38 | $organizationId = $request->get('organizationId'); |
|
| 39 | $this->commandBus->handle( |
|
| 40 | new AddOrganizationMemberToOrganizationCommand($userId, $organizationId, $this->currentUser->getUserName()) |
|
| 41 | ); |
|
| 42 | ||
| 43 | return new JsonResponse(); |
|
| 44 | } |
|
| 45 | } |
|
| 46 | ||
| @@ 23-46 (lines=24) @@ | ||
| 20 | use Symfony\Component\HttpFoundation\Request; |
|
| 21 | use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; |
|
| 22 | ||
| 23 | class RemoveMemberFromOrganization |
|
| 24 | { |
|
| 25 | private $commandBus; |
|
| 26 | ||
| 27 | private $currentUser; |
|
| 28 | ||
| 29 | public function __construct(CommandBus $commandBus, TokenStorageInterface $tokenStorage) |
|
| 30 | { |
|
| 31 | $this->commandBus = $commandBus; |
|
| 32 | $this->currentUser = $tokenStorage->getToken()->getUser(); |
|
| 33 | } |
|
| 34 | ||
| 35 | public function __invoke(Request $request) : JsonResponse |
|
| 36 | { |
|
| 37 | $userId = $request->get('userId'); |
|
| 38 | $organizationId = $request->get('organizationId'); |
|
| 39 | ||
| 40 | $this->commandBus->handle( |
|
| 41 | new RemoveOrganizationMemberToOrganizationCommand($userId, $organizationId, $this->currentUser->getUserName()) |
|
| 42 | ); |
|
| 43 | ||
| 44 | return new JsonResponse(); |
|
| 45 | } |
|
| 46 | } |
|
| 47 | ||