johnykvsky /
spisywarka
| 1 | <?php |
||
| 2 | |||
| 3 | namespace App\Controller\Frontend; |
||
| 4 | |||
| 5 | use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; |
||
| 6 | use Symfony\Component\HttpFoundation\Response; |
||
| 7 | use Symfony\Component\Routing\Annotation\Route; |
||
| 8 | use App\Repository\ItemRepository; |
||
| 9 | use App\Repository\CollectionRepository; |
||
| 10 | use Ramsey\Uuid\Uuid; |
||
| 11 | |||
| 12 | class Collection extends AbstractController |
||
| 13 | { |
||
| 14 | /** |
||
| 15 | * @var ItemRepository |
||
| 16 | */ |
||
| 17 | private $repository; |
||
| 18 | /** |
||
| 19 | * @var CollectionRepository |
||
| 20 | */ |
||
| 21 | private $collectionRepository; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * @param ItemRepository $repository |
||
| 25 | * @param CollectionRepository $collectionRepository |
||
| 26 | */ |
||
| 27 | public function __construct( |
||
| 28 | ItemRepository $repository, |
||
| 29 | CollectionRepository $collectionRepository |
||
| 30 | ) |
||
| 31 | { |
||
| 32 | $this->repository = $repository; |
||
| 33 | $this->collectionRepository = $collectionRepository; |
||
| 34 | } |
||
| 35 | |||
| 36 | /** |
||
| 37 | * @Route("/collection/{id}/{slug}", name="collection", methods={"GET"}) |
||
| 38 | * @param string $id |
||
| 39 | * @param string $slug |
||
| 40 | * @return Response |
||
| 41 | */ |
||
| 42 | public function collection(string $id, string $slug): Response |
||
|
0 ignored issues
–
show
|
|||
| 43 | { |
||
| 44 | try { |
||
| 45 | $uuid = Uuid::fromString($id); |
||
| 46 | $collection = $this->collectionRepository->getCollection($uuid); |
||
| 47 | $items = $this->repository->getItemsInCollection($uuid); |
||
| 48 | } catch (\Exception $e) { |
||
| 49 | $error = $e->getMessage(); |
||
| 50 | } |
||
| 51 | |||
| 52 | return $this->render('frontend/collection.html.twig', [ |
||
| 53 | 'items' => $items ?? null, |
||
| 54 | 'collection' => $collection ?? null, |
||
| 55 | 'error' => $error ?? null |
||
| 56 | ]); |
||
| 57 | } |
||
| 58 | } |
||
| 59 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.