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 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace App\Controller\Banners; | |
| 6 | ||
| 7 | use App\ApiResource\Bannergress; | |
| 8 | use App\Bannergress\BannerMap; | |
| 9 | use App\Controller\BaseController; | |
| 10 | use App\Enum\UserRole; | |
| 11 | use App\Repository\DoneBannerRepository; | |
| 12 | use Symfony\Component\HttpFoundation\Response; | |
| 13 | use Symfony\Component\Routing\Attribute\Route; | |
| 14 | use 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)] | |
| 22 | final 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 | } |