|
13 | 13 |
|
14 | 14 | namespace App\Controller; |
15 | 15 |
|
| 16 | +use App\DTO\AnalyticsFilters; |
| 17 | +use App\Form\Type\AnalyticsFiltersType; |
16 | 18 | use App\Highcharts\Chart\TagAmountChart; |
17 | 19 | use App\Highcharts\Chart\TagUsageChart; |
18 | 20 | use App\Repository\OperationRepository; |
19 | 21 | use App\Repository\TagRepository; |
| 22 | +use Symfony\Component\Form\FormFactoryInterface; |
| 23 | +use Symfony\Component\HttpFoundation\Request; |
20 | 24 | use Symfony\Component\HttpFoundation\Response; |
21 | 25 | use Symfony\Component\Routing\Annotation\Route; |
22 | 26 | use Twig\Environment; |
23 | 27 |
|
24 | 28 | class AnalyticsController |
25 | 29 | { |
26 | 30 | private Environment $twig; |
| 31 | + private FormFactoryInterface $formFactory; |
27 | 32 | private TagRepository $tagRepository; |
28 | 33 | private OperationRepository $operationRepository; |
29 | 34 |
|
30 | 35 | public function __construct( |
31 | 36 | Environment $twig, |
| 37 | + FormFactoryInterface $formFactory, |
32 | 38 | TagRepository $tagRepository, |
33 | 39 | OperationRepository $operationRepository |
34 | 40 | ) { |
35 | 41 | $this->twig = $twig; |
| 42 | + $this->formFactory = $formFactory; |
36 | 43 | $this->tagRepository = $tagRepository; |
37 | 44 | $this->operationRepository = $operationRepository; |
38 | 45 | } |
39 | 46 |
|
40 | 47 | /** |
41 | 48 | * @Route("/admin/analytics", name="analytics") |
42 | 49 | */ |
43 | | - public function analytics(): Response |
| 50 | + public function analytics(Request $request): Response |
44 | 51 | { |
45 | | - $operations = $this->operationRepository->findWithTags(); |
| 52 | + $filters = new AnalyticsFilters(); |
| 53 | + $form = $this->formFactory->createNamed('', AnalyticsFiltersType::class, $filters); |
| 54 | + $form->handleRequest($request); |
| 55 | + |
| 56 | + $operations = $this->operationRepository->findForAnalytics($filters); |
46 | 57 |
|
47 | 58 | return new Response($this->twig->render('analytics.html.twig', [ |
| 59 | + 'filters_form' => $form->createView(), |
48 | 60 | 'charts' => [ |
49 | 61 | new TagUsageChart($operations), |
50 | 62 | new TagAmountChart($operations), |
|
0 commit comments