```
✨ feat(ReserverController): Ajoute des routes pour connexion, création de compte et recherche.
Crée les routes pour la connexion (`/reservation/connexion`), la création de compte
(`/reservation/creation-compte`), la gestion du mot de passe
(`/reservation/creation-compte`), et la recherche de produits
(`/reservation/recherche`). Intègre UploaderHelper et Client pour la recherche.
```
This commit is contained in:
@@ -12,6 +12,7 @@ use App\Repository\ProductRepository;
|
||||
use App\Service\Mailer\Mailer;
|
||||
use App\Service\ResetPassword\Event\ResetPasswordConfirmEvent;
|
||||
use App\Service\ResetPassword\Event\ResetPasswordEvent;
|
||||
use App\Service\Search\Client;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Fkrzski\RobotsTxt\RobotsTxt;
|
||||
use KnpU\OAuth2ClientBundle\Client\ClientRegistry;
|
||||
@@ -28,6 +29,8 @@ use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
|
||||
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||
use Vich\UploaderBundle\Templating\Helper\UploaderHelper;
|
||||
use Vich\UploaderBundle\Templating\Helper\UploaderHelperInterface;
|
||||
|
||||
|
||||
class ReserverController extends AbstractController
|
||||
@@ -105,9 +108,25 @@ class ReserverController extends AbstractController
|
||||
]);
|
||||
}
|
||||
#[Route('/reservation/connexion', name: 'reservation_login')]
|
||||
public function revervationLogin(): Response
|
||||
public function revervationLogin(AuthenticationUtils $authenticationUtils): Response
|
||||
{
|
||||
return $this->render('revervation/login.twig',[
|
||||
'last_username' => $authenticationUtils->getLastUsername(),
|
||||
'error' => $authenticationUtils->getLastAuthenticationError()
|
||||
|
||||
]);
|
||||
}
|
||||
#[Route('/reservation/creation-compte', name: 'reservation_register')]
|
||||
public function revervationRegister(): Response
|
||||
{
|
||||
return $this->render('revervation/register.twig',[
|
||||
|
||||
]);
|
||||
}
|
||||
#[Route('/reservation/creation-compte', name: 'reservation_password')]
|
||||
public function revervationForgot(): Response
|
||||
{
|
||||
return $this->render('revervation/password.twig',[
|
||||
|
||||
]);
|
||||
}
|
||||
@@ -161,9 +180,27 @@ class ReserverController extends AbstractController
|
||||
]);
|
||||
}
|
||||
#[Route('/reservation/recherche', name: 'reservation_search')]
|
||||
public function recherche()
|
||||
public function recherche(UploaderHelper $uploaderHelper,Client $client,Request $request,ProductRepository $productRepository): Response
|
||||
{
|
||||
return $this->render('revervation/search.twig');
|
||||
$results = $client->search('product',$request->query->get('q',''));
|
||||
$items = [];
|
||||
foreach ($results['hits'] as $result) {
|
||||
$p = $productRepository->find($result['id']);
|
||||
if($p instanceof Product) {
|
||||
$items[] = [
|
||||
'image' => $uploaderHelper->asset($p, 'imageFile') ?: "/provider/images/favicon.png",
|
||||
"name" => $p->getName(),
|
||||
"price" => $p->getPriceDay(),
|
||||
"price1day" => $p->getPriceDay(),
|
||||
"caution" => $p->getCaution(),
|
||||
"priceSup" => $p->getPriceSup(),
|
||||
'link' => $this->generateUrl('reservation_product_show',['id'=>$p->slug()]),
|
||||
];
|
||||
}
|
||||
}
|
||||
return $this->render('revervation/search.twig',[
|
||||
'products' => $items
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/reservation/mentions-legales', name: 'reservation_mentions-legal')]
|
||||
|
||||
Reference in New Issue
Block a user