Lines 100.00% 8 / 8
Functions and Methods 100.00% 1 / 1
Classes and Traits 100.00% 1 / 1
Name Lines Functions and Methods CRAP Classes and Traits
Index 100.00% 8 / 8 100.00% 1 / 1 2 100.00% 1 / 1
 __invoke 100.00% 8 / 8 100.00% 1 / 1 2
1<?php
2
3declare(strict_types=1);
4
5namespace App\Controller\Banners;
6
7use App\ApiResource\Bannergress;
8use App\Bannergress\BannerMap;
9use App\Controller\BaseController;
10use App\Enum\UserRole;
11use App\Repository\DoneBannerRepository;
12use Symfony\Component\HttpFoundation\Response;
13use Symfony\Component\Routing\Attribute\Route;
14use Symfony\Component\Security\Http\Attribute\IsGranted;
15
16/**
17 * What the app synced from Bannergress for the user: the counts, the newest to-do banners and
18 * the done list, where the user sets the day each banner was done (DoneAt).
19 */
20#[Route('/banners', name: 'app_banners', methods: ['GET'])]
21#[IsGranted(UserRole::USER->value)]
22final class Index extends BaseController
23{
24    public function __invoke(DoneBannerRepository $doneBannerRepository, BannerMap $bannerMap): Response
25    {
26        $bannergress = Bannergress::fromStored($this->getUser()->getBannergress());
27        $doneBanners = $doneBannerRepository->findByOwner($this->getUser());
28
29        return $this->render('banners/index.html.twig', [
30            'bannergress' => $bannergress,
31            'doneBanners' => $doneBanners,
32            'mapPoints' => $bannergress instanceof Bannergress ? $bannerMap->points($bannergress, $doneBanners) : [],
33            'agent' => null,
34        ]);
35    }
36}