@@ 16-75 (lines=60) @@ | ||
13 | use Symfony\Component\HttpFoundation\Response; |
|
14 | use Symfony\Component\Validator\Validator\ValidatorInterface; |
|
15 | ||
16 | final class DropCartAction |
|
17 | { |
|
18 | /** |
|
19 | * @var ViewHandlerInterface |
|
20 | */ |
|
21 | private $viewHandler; |
|
22 | ||
23 | /** |
|
24 | * @var CommandBus |
|
25 | */ |
|
26 | private $bus; |
|
27 | ||
28 | /** |
|
29 | * @var ValidatorInterface |
|
30 | */ |
|
31 | private $validator; |
|
32 | ||
33 | /** |
|
34 | * @var ValidationErrorViewFactoryInterface |
|
35 | */ |
|
36 | private $validationErrorViewFactory; |
|
37 | ||
38 | /** |
|
39 | * @param ViewHandlerInterface $viewHandler |
|
40 | * @param CommandBus $bus |
|
41 | * @param ValidatorInterface $validator |
|
42 | * @param ValidationErrorViewFactoryInterface $validationErrorViewFactory |
|
43 | */ |
|
44 | public function __construct( |
|
45 | ViewHandlerInterface $viewHandler, |
|
46 | CommandBus $bus, |
|
47 | ValidatorInterface $validator, |
|
48 | ValidationErrorViewFactoryInterface $validationErrorViewFactory |
|
49 | ) { |
|
50 | $this->viewHandler = $viewHandler; |
|
51 | $this->bus = $bus; |
|
52 | $this->validator = $validator; |
|
53 | $this->validationErrorViewFactory = $validationErrorViewFactory; |
|
54 | } |
|
55 | ||
56 | /** |
|
57 | * @param Request $request |
|
58 | * |
|
59 | * @return Response |
|
60 | */ |
|
61 | public function __invoke(Request $request) |
|
62 | { |
|
63 | $pickupRequest = new DropCartRequest($request); |
|
64 | ||
65 | $validationResults = $this->validator->validate($pickupRequest); |
|
66 | ||
67 | if (0 === count($validationResults)) { |
|
68 | $this->bus->handle($pickupRequest->getCommand()); |
|
69 | ||
70 | return $this->viewHandler->handle(View::create(null, Response::HTTP_NO_CONTENT)); |
|
71 | } |
|
72 | ||
73 | return $this->viewHandler->handle(View::create($this->validationErrorViewFactory->create($validationResults), Response::HTTP_BAD_REQUEST)); |
|
74 | } |
|
75 | } |
|
76 |
@@ 16-64 (lines=49) @@ | ||
13 | use Symfony\Component\HttpFoundation\Response; |
|
14 | use Symfony\Component\Validator\Validator\ValidatorInterface; |
|
15 | ||
16 | final class RegisterCustomerAction |
|
17 | { |
|
18 | /** |
|
19 | * @var ViewHandlerInterface |
|
20 | */ |
|
21 | private $viewHandler; |
|
22 | ||
23 | /** |
|
24 | * @var CommandBus |
|
25 | */ |
|
26 | private $bus; |
|
27 | ||
28 | /** |
|
29 | * @var ValidatorInterface |
|
30 | */ |
|
31 | private $validator; |
|
32 | ||
33 | /** |
|
34 | * @var ValidationErrorViewFactoryInterface |
|
35 | */ |
|
36 | private $validationErrorViewFactory; |
|
37 | ||
38 | public function __construct( |
|
39 | ViewHandlerInterface $viewHandler, |
|
40 | CommandBus $bus, |
|
41 | ValidatorInterface $validator, |
|
42 | ValidationErrorViewFactoryInterface $validationErrorViewFactory |
|
43 | ) { |
|
44 | $this->viewHandler = $viewHandler; |
|
45 | $this->bus = $bus; |
|
46 | $this->validator = $validator; |
|
47 | $this->validationErrorViewFactory = $validationErrorViewFactory; |
|
48 | } |
|
49 | ||
50 | public function __invoke(Request $request): Response |
|
51 | { |
|
52 | $registerCustomerRequest = new RegisterCustomerRequest($request); |
|
53 | ||
54 | $validationResults = $this->validator->validate($registerCustomerRequest); |
|
55 | ||
56 | if (0 !== count($validationResults)) { |
|
57 | return $this->viewHandler->handle(View::create($this->validationErrorViewFactory->create($validationResults), Response::HTTP_BAD_REQUEST)); |
|
58 | } |
|
59 | ||
60 | $this->bus->handle($registerCustomerRequest->getCommand()); |
|
61 | ||
62 | return $this->viewHandler->handle(View::create(null, Response::HTTP_NO_CONTENT)); |
|
63 | } |
|
64 | } |
|
65 |
@@ 16-64 (lines=49) @@ | ||
13 | use Symfony\Component\HttpFoundation\Response; |
|
14 | use Symfony\Component\Validator\Validator\ValidatorInterface; |
|
15 | ||
16 | final class ResendVerificationTokenAction |
|
17 | { |
|
18 | /** |
|
19 | * @var ViewHandlerInterface |
|
20 | */ |
|
21 | private $viewHandler; |
|
22 | ||
23 | /** |
|
24 | * @var CommandBus |
|
25 | */ |
|
26 | private $bus; |
|
27 | ||
28 | /** |
|
29 | * @var ValidatorInterface |
|
30 | */ |
|
31 | private $validator; |
|
32 | ||
33 | /** |
|
34 | * @var ValidationErrorViewFactoryInterface |
|
35 | */ |
|
36 | private $validationErrorViewFactory; |
|
37 | ||
38 | public function __construct( |
|
39 | ViewHandlerInterface $viewHandler, |
|
40 | CommandBus $bus, |
|
41 | ValidatorInterface $validator, |
|
42 | ValidationErrorViewFactoryInterface $validationErrorViewFactory |
|
43 | ) { |
|
44 | $this->viewHandler = $viewHandler; |
|
45 | $this->bus = $bus; |
|
46 | $this->validator = $validator; |
|
47 | $this->validationErrorViewFactory = $validationErrorViewFactory; |
|
48 | } |
|
49 | ||
50 | public function __invoke(Request $request): Response |
|
51 | { |
|
52 | $resendVerificationTokenRequest = new ResendVerificationTokenRequest($request); |
|
53 | ||
54 | $validationResults = $this->validator->validate($resendVerificationTokenRequest); |
|
55 | ||
56 | if (0 !== count($validationResults)) { |
|
57 | return $this->viewHandler->handle(View::create($this->validationErrorViewFactory->create($validationResults), Response::HTTP_BAD_REQUEST)); |
|
58 | } |
|
59 | ||
60 | $this->bus->handle($resendVerificationTokenRequest->getCommand()); |
|
61 | ||
62 | return $this->viewHandler->handle(View::create(null, Response::HTTP_CREATED)); |
|
63 | } |
|
64 | } |
|
65 |
@@ 16-64 (lines=49) @@ | ||
13 | use Symfony\Component\HttpFoundation\Response; |
|
14 | use Symfony\Component\Validator\Validator\ValidatorInterface; |
|
15 | ||
16 | final class VerifyAccountAction |
|
17 | { |
|
18 | /** |
|
19 | * @var ViewHandlerInterface |
|
20 | */ |
|
21 | private $viewHandler; |
|
22 | ||
23 | /** |
|
24 | * @var CommandBus |
|
25 | */ |
|
26 | private $bus; |
|
27 | ||
28 | /** |
|
29 | * @var ValidatorInterface |
|
30 | */ |
|
31 | private $validator; |
|
32 | ||
33 | /** |
|
34 | * @var ValidationErrorViewFactoryInterface |
|
35 | */ |
|
36 | private $validationErrorViewFactory; |
|
37 | ||
38 | public function __construct( |
|
39 | ViewHandlerInterface $viewHandler, |
|
40 | CommandBus $bus, |
|
41 | ValidatorInterface $validator, |
|
42 | ValidationErrorViewFactoryInterface $validationErrorViewFactory |
|
43 | ) { |
|
44 | $this->viewHandler = $viewHandler; |
|
45 | $this->bus = $bus; |
|
46 | $this->validator = $validator; |
|
47 | $this->validationErrorViewFactory = $validationErrorViewFactory; |
|
48 | } |
|
49 | ||
50 | public function __invoke(Request $request): Response |
|
51 | { |
|
52 | $resendVerificationTokenRequest = new VerifyAccountRequest($request); |
|
53 | ||
54 | $validationResults = $this->validator->validate($resendVerificationTokenRequest); |
|
55 | ||
56 | if (0 !== count($validationResults)) { |
|
57 | return $this->viewHandler->handle(View::create($this->validationErrorViewFactory->create($validationResults), Response::HTTP_BAD_REQUEST)); |
|
58 | } |
|
59 | ||
60 | $this->bus->handle($resendVerificationTokenRequest->getCommand()); |
|
61 | ||
62 | return $this->viewHandler->handle(View::create(null, Response::HTTP_NO_CONTENT)); |
|
63 | } |
|
64 | } |
|
65 |
@@ 16-56 (lines=41) @@ | ||
13 | use Symfony\Component\HttpFoundation\Response; |
|
14 | use Symfony\Component\Validator\Validator\ValidatorInterface; |
|
15 | ||
16 | final class AddReviewByCodeAction |
|
17 | { |
|
18 | /** @var ViewHandlerInterface */ |
|
19 | private $viewHandler; |
|
20 | ||
21 | /** @var CommandBus */ |
|
22 | private $bus; |
|
23 | ||
24 | /** @var ValidatorInterface */ |
|
25 | private $validator; |
|
26 | ||
27 | /** @var ValidationErrorViewFactoryInterface */ |
|
28 | private $validationErrorViewFactory; |
|
29 | ||
30 | public function __construct( |
|
31 | ViewHandlerInterface $viewHandler, |
|
32 | CommandBus $bus, |
|
33 | ValidatorInterface $validator, |
|
34 | ValidationErrorViewFactoryInterface $validationErrorViewFactory |
|
35 | ) { |
|
36 | $this->viewHandler = $viewHandler; |
|
37 | $this->bus = $bus; |
|
38 | $this->validator = $validator; |
|
39 | $this->validationErrorViewFactory = $validationErrorViewFactory; |
|
40 | } |
|
41 | ||
42 | public function __invoke(Request $request): Response |
|
43 | { |
|
44 | $addReviewRequest = new AddProductReviewByCodeRequest($request); |
|
45 | ||
46 | $validationResults = $this->validator->validate($addReviewRequest); |
|
47 | ||
48 | if (0 !== count($validationResults)) { |
|
49 | return $this->viewHandler->handle(View::create($this->validationErrorViewFactory->create($validationResults), Response::HTTP_BAD_REQUEST)); |
|
50 | } |
|
51 | ||
52 | $this->bus->handle($addReviewRequest->getCommand()); |
|
53 | ||
54 | return $this->viewHandler->handle(View::create(null, Response::HTTP_CREATED)); |
|
55 | } |
|
56 | } |
|
57 |
@@ 16-56 (lines=41) @@ | ||
13 | use Symfony\Component\HttpFoundation\Response; |
|
14 | use Symfony\Component\Validator\Validator\ValidatorInterface; |
|
15 | ||
16 | final class AddReviewBySlugAction |
|
17 | { |
|
18 | /** @var ViewHandlerInterface */ |
|
19 | private $viewHandler; |
|
20 | ||
21 | /** @var CommandBus */ |
|
22 | private $bus; |
|
23 | ||
24 | /** @var ValidatorInterface */ |
|
25 | private $validator; |
|
26 | ||
27 | /** @var ValidationErrorViewFactoryInterface */ |
|
28 | private $validationErrorViewFactory; |
|
29 | ||
30 | public function __construct( |
|
31 | ViewHandlerInterface $viewHandler, |
|
32 | CommandBus $bus, |
|
33 | ValidatorInterface $validator, |
|
34 | ValidationErrorViewFactoryInterface $validationErrorViewFactory |
|
35 | ) { |
|
36 | $this->viewHandler = $viewHandler; |
|
37 | $this->bus = $bus; |
|
38 | $this->validator = $validator; |
|
39 | $this->validationErrorViewFactory = $validationErrorViewFactory; |
|
40 | } |
|
41 | ||
42 | public function __invoke(Request $request): Response |
|
43 | { |
|
44 | $addReviewRequest = new AddProductReviewBySlugRequest($request); |
|
45 | ||
46 | $validationResults = $this->validator->validate($addReviewRequest); |
|
47 | ||
48 | if (0 !== count($validationResults)) { |
|
49 | return $this->viewHandler->handle(View::create($this->validationErrorViewFactory->create($validationResults), Response::HTTP_BAD_REQUEST)); |
|
50 | } |
|
51 | ||
52 | $this->bus->handle($addReviewRequest->getCommand()); |
|
53 | ||
54 | return $this->viewHandler->handle(View::create(null, Response::HTTP_CREATED)); |
|
55 | } |
|
56 | } |
|
57 |