<?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
#[Route('/', name: "app-")]
class HelloController extends AbstractController
{
protected $wurst = [
['message' => 'Hello', 'created' => '2022-12-01'],
['message' => 'Hi', 'created' => '2022-10-15'],
['message' => 'Bye!', 'created' => '2021-05-12']
];
#[Route('/{limit<\d+>?3}', name: "home")]
public function index(int $limit)
{
return $this->render('hello/index.html.twig',
[
'messages' => $this->wurst,
'limit'=>$limit
]);
// return new Response(
// implode(",",
// array_slice($this->wurst,0,$limit)
// ));
}
#[Route('/show/{id<\d+>}', name: "show")]
public function showOne(int $id)
{
return $this->render('hello/show_one.html.twig',[
'message'=>$this->wurst[$id]
]);
//return new Response($this->wurst[$id]);
}
}