|
4 | 4 |
|
5 | 5 | namespace CodelyTv\Shared\Infrastructure\Symfony; |
6 | 6 |
|
7 | | -use CodelyTv\Shared\Domain\Bus\Command\Command; |
8 | 7 | use CodelyTv\Shared\Domain\Bus\Command\CommandBus; |
9 | | -use CodelyTv\Shared\Domain\Bus\Query\Query; |
10 | 8 | use CodelyTv\Shared\Domain\Bus\Query\QueryBus; |
11 | | -use CodelyTv\Shared\Domain\Bus\Query\Response; |
12 | 9 | use Symfony\Component\HttpFoundation\RedirectResponse; |
13 | 10 | use Symfony\Component\HttpFoundation\Request; |
14 | 11 | use Symfony\Component\HttpFoundation\Response as SymfonyResponse; |
|
17 | 14 | use Symfony\Component\Validator\ConstraintViolationListInterface; |
18 | 15 | use Twig\Environment; |
19 | 16 |
|
20 | | -abstract class WebController |
| 17 | +abstract class WebController extends ApiController |
21 | 18 | { |
22 | 19 | private $twig; |
23 | 20 | private $router; |
24 | 21 | private $session; |
25 | | - private $queryBus; |
26 | | - private $commandBus; |
27 | 22 |
|
28 | 23 | public function __construct( |
29 | 24 | Environment $twig, |
30 | 25 | RouterInterface $router, |
31 | 26 | SessionInterface $session, |
32 | 27 | QueryBus $queryBus, |
33 | | - CommandBus $commandBus |
| 28 | + CommandBus $commandBus, |
| 29 | + ApiExceptionsHttpStatusCodeMapping $exceptionHandler |
34 | 30 | ) { |
35 | | - $this->twig = $twig; |
36 | | - $this->router = $router; |
37 | | - $this->session = $session; |
38 | | - $this->queryBus = $queryBus; |
39 | | - $this->commandBus = $commandBus; |
| 31 | + parent::__construct($queryBus, $commandBus, $exceptionHandler); |
| 32 | + |
| 33 | + $this->twig = $twig; |
| 34 | + $this->router = $router; |
| 35 | + $this->session = $session; |
40 | 36 | } |
41 | 37 |
|
42 | 38 | public function render(string $templatePath, array $arguments = []): SymfonyResponse |
@@ -67,16 +63,6 @@ public function redirectWithErrors( |
67 | 63 | return new RedirectResponse($this->router->generate($routeName), 302); |
68 | 64 | } |
69 | 65 |
|
70 | | - public function ask(Query $query): ?Response |
71 | | - { |
72 | | - return $this->queryBus->ask($query); |
73 | | - } |
74 | | - |
75 | | - public function dispatch(Command $command): void |
76 | | - { |
77 | | - $this->commandBus->dispatch($command); |
78 | | - } |
79 | | - |
80 | 66 | private function formatFlashErrors(ConstraintViolationListInterface $violations): array |
81 | 67 | { |
82 | 68 | $errors = []; |
|
0 commit comments