src/Controller/LogoController.php line 22

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\Mailling;
  4. use App\Service\Utilitaire\AnomalieGestion;
  5. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  6. use Symfony\Component\HttpFoundation\Request;
  7. use Symfony\Component\HttpFoundation\Response;
  8. use Symfony\Component\HttpFoundation\ResponseHeaderBag;
  9. use Symfony\Component\HttpKernel\KernelInterface;
  10. use Symfony\Component\Routing\Annotation\Route;
  11. class LogoController extends AbstractController
  12. {
  13.     /**
  14.      * @Route("/logo/clients/{nom}",methods={"GET"},name="get.logo.client")
  15.      */
  16.     public function getLogoClientAction($nomRequest $requestKernelInterface $kernelAnomalieGestion  $anomalieGestion)
  17.     {
  18.         $file $kernel->getRootDir() . '/../public/logoClients/resized/'.$nom;
  19.         if(file_exists($file)) {
  20.             $response = new Response();
  21.             $disposition $response->headers->makeDisposition(ResponseHeaderBag::DISPOSITION_INLINE$nom);
  22.             $response->headers->set('Content-Disposition'$disposition);
  23.             $response->headers->set('Content-Type''image/jpeg');
  24.             $response->setContent(file_get_contents($file));
  25.             return $response;
  26.         } else {
  27.             $anomalieGestion->addAnomalieDemandeDeLogoInexistant($nom);
  28.         }
  29.     }
  30.     /**
  31.      * @Route("/logo/pieceJointe/{id}/{nom}",methods={"GET"},name="get.piece.jointe")
  32.      */
  33.     public function getPieceJointeAction($id$nomRequest $requestKernelInterface $kernelAnomalieGestion $anomalieGestion)
  34.     {
  35.         /** @var Mailling $mailling */
  36.         $mailling $this->getDoctrine()->getManager()
  37.             ->getRepository('App\Entity\Mailling')
  38.             ->find($id);
  39.         $file =$kernel->getRootDir() . '/../public/maillings/'$mailling->getAncienId() . '/' $nom;
  40.         if(file_exists($file)) {
  41.             $response = new Response();
  42.             $disposition $response->headers->makeDisposition(ResponseHeaderBag::DISPOSITION_INLINE$nom);
  43.             $response->headers->set('Content-Disposition'$disposition);
  44.             $response->headers->set('Content-Type''pdf');
  45.             $response->setContent(file_get_contents($file));
  46.             return $response;
  47.         } else {
  48.             $anomalieGestion->addAnomalieDemandeDePiecJointeInexistant($nom);
  49.         }
  50.     }
  51.     /**
  52.      * @Route("/logo/coupurepieceJointe/{nom}",methods={"GET"},name="get.piece.jointe")
  53.      */
  54.     public function getCoupurePieceJointeAction($nomRequest $requestKernelInterface $kernelAnomalieGestion $anomalieGestion)
  55.     {
  56.         /** @var Mailling $mailling */
  57.         $file =$kernel->getRootDir() . '/../public/coupures/'$nom;
  58.         if(file_exists($file)) {
  59.             $response = new Response();
  60.             $disposition $response->headers->makeDisposition(ResponseHeaderBag::DISPOSITION_INLINE$nom);
  61.             $response->headers->set('Content-Disposition'$disposition);
  62.             $response->headers->set('Content-Type''pdf');
  63.             $response->setContent(file_get_contents($file));
  64.             return $response;
  65.         } else {
  66.             $anomalieGestion->addAnomalieDemandeDePiecJointeInexistant($nom);
  67.         }
  68.     }
  69. }