<?php
namespace App\Controller;
use App\Services\SearchRedirectorService;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class HomeController extends AbstractController
{
private $searchRedirectorService;
public function __construct(SearchRedirectorService $searchRedirectorService)
{
$this->searchRedirectorService = $searchRedirectorService;
}
#[Route('/', name: 'app_home')]
public function index(Request $request): Response
{
$search = $request->request->get('search', '');
if ($search) {
return $this->redirect($this->searchRedirectorService->redirectToSearch($search));
}
return $this->render('home/index.html.twig');
}
}