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 Ramsey\Uuid\Uuid; |
||
| 10 | |||
| 11 | class Item extends AbstractController |
||
| 12 | { |
||
| 13 | /** |
||
| 14 | * @var ItemRepository |
||
| 15 | */ |
||
| 16 | private $repository; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * @param ItemRepository $repository |
||
| 20 | */ |
||
| 21 | public function __construct( |
||
| 22 | ItemRepository $repository |
||
| 23 | ) |
||
| 24 | { |
||
| 25 | $this->repository = $repository; |
||
| 26 | } |
||
| 27 | |||
| 28 | /** |
||
| 29 | * @Route("/item/{id}/{slug}", name="item", methods={"GET"}) |
||
| 30 | * @param string $id |
||
| 31 | * @param string $slug |
||
| 32 | * @return Response |
||
| 33 | */ |
||
| 34 | public function item(string $id, string $slug): Response |
||
|
0 ignored issues
–
show
|
|||
| 35 | { |
||
| 36 | try { |
||
| 37 | $uuid = Uuid::fromString($id); |
||
| 38 | $item = $this->repository->getItem($uuid); |
||
| 39 | } catch (\Exception $e) { |
||
| 40 | $error = $e->getMessage(); |
||
| 41 | } |
||
| 42 | |||
| 43 | return $this->render('frontend/item.html.twig', [ |
||
| 44 | 'item' => $item ?? null, |
||
| 45 | 'error' => $error ?? null |
||
| 46 | ]); |
||
| 47 | } |
||
| 48 | } |
||
| 49 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.