<?php
namespace App\Controller;
use App\Entity\Information;
use App\Form\Admin\InformationType;
use App\Repository\InformationRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Routing\RequestContext;
#[Route('/information', name: 'hs_public_information_')]
class InformationController extends AbstractController
{
public function __construct(
private readonly InformationRepository $informationRepository,
){
}
public function widgetAction($widget)
{
switch ($widget) {
case 'rs_header':
case 'btn_whatsapp':
$info = $this->informationRepository->findBy(['category' => 'Réseaux sociaux', 'published' => true]);
break;
case 'coordonnees':
case 'coo_header':
$info = $this->informationRepository->findBy(['category' => 'Coordonnées', 'published' => true]);
break;
default:
$info =[];
}
$info_soc = [];
foreach ($info as $parm) {
$info_soc[$parm->getSlug()] = ["val" => $parm->getVal(), "icon" => $parm->getType(), 'name' => $parm->getName(), 'slug' => $parm->getSlug()];
}
return $this->render(
'widget/' . $widget . '.html.twig',
['params' => $info_soc]
);
}
}