src/Controller/HelloController.php line 32

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\HttpFoundation\Response;
  5. use Symfony\Component\Routing\Annotation\Route;
  6. #[Route('/'name"app-")]
  7. class HelloController extends AbstractController
  8. {
  9.     protected $wurst = [
  10.         ['message' => 'Hello''created' => '2022-12-01'],
  11.         ['message' => 'Hi''created' => '2022-10-15'],
  12.         ['message' => 'Bye!''created' => '2021-05-12']
  13.     ];
  14.      #[Route('/{limit<\d+>?3}'name"home")]
  15.      public function index(int $limit)
  16.      {
  17.          return $this->render('hello/index.html.twig',
  18.          [
  19.              'messages' => $this->wurst,
  20.              'limit'=>$limit
  21.          ]);
  22. //         return new Response(
  23. //             implode(",",
  24. //             array_slice($this->wurst,0,$limit)
  25. //         ));
  26.      }
  27.     #[Route('/show/{id<\d+>}'name"show")]
  28.      public function showOne(int $id)
  29.      {
  30.         return $this->render('hello/show_one.html.twig',[
  31.             'message'=>$this->wurst[$id]
  32.         ]);
  33.          //return new Response($this->wurst[$id]);
  34.      }
  35. }