src/Controller/InformationController.php line 26

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\Information;
  4. use App\Form\Admin\InformationType;
  5. use App\Repository\InformationRepository;
  6. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  7. use Symfony\Component\HttpFoundation\JsonResponse;
  8. use Symfony\Component\HttpFoundation\RedirectResponse;
  9. use Symfony\Component\HttpFoundation\Request;
  10. use Symfony\Component\HttpFoundation\RequestStack;
  11. use Symfony\Component\HttpFoundation\Response;
  12. use Symfony\Component\Routing\Annotation\Route;
  13. use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
  14. use Symfony\Component\Routing\RequestContext;
  15. #[Route('/information'name'hs_public_information_')]
  16. class InformationController extends AbstractController
  17. {
  18.     public function __construct(
  19.         private readonly InformationRepository $informationRepository,
  20.     ){
  21.     }
  22.     public function widgetAction($widget)
  23.     {
  24.         switch ($widget) {
  25.             case 'rs_header':
  26.             case 'btn_whatsapp':
  27.                 $info $this->informationRepository->findBy(['category' => 'Réseaux sociaux''published' => true]);
  28.                 break;
  29.             case 'coordonnees':
  30.             case 'coo_header':
  31.                 $info $this->informationRepository->findBy(['category' => 'Coordonnées''published' => true]);
  32.                 break;
  33.             default:
  34.                 $info =[];
  35.         }
  36.         $info_soc = [];
  37.         foreach ($info as $parm) {
  38.             $info_soc[$parm->getSlug()] = ["val" => $parm->getVal(), "icon" => $parm->getType(), 'name' => $parm->getName(), 'slug' => $parm->getSlug()];
  39.         }
  40.         return $this->render(
  41.             'widget/' $widget '.html.twig',
  42.             ['params' => $info_soc]
  43.         );
  44.     }
  45. }