src/Controller/View/Magazine/ThemeController.php line 23

Open in your IDE?
  1. <?php
  2. namespace App\Controller\View\Magazine;
  3. use App\Entity\Magazine\Magazine;
  4. use Exception;
  5. use function PHPSTORM_META\type;
  6. use Symfony\Component\HttpFoundation\Request;
  7. use Symfony\Component\HttpFoundation\Response;
  8. use Symfony\Component\Routing\Annotation\Route;
  9. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  10. /**
  11.  * @Route("/view/theme")
  12.  */
  13. class ThemeController extends AbstractController
  14. {
  15.     /**
  16.      * @Route("/{slug}", methods={"GET"})
  17.      */
  18.     public function show(Request $request$slug)
  19.     {
  20.         $magazine $this->getDoctrine()->getRepository(Magazine::class)->findOneBy(['slug'=>$slug]);
  21.         if(!$magazine) {
  22.             return $this->json(['message' => 'magazine not found'], Response::HTTP_NOT_FOUND);
  23.         }
  24.         /*if($request->get('provider') != 'preprod' && $magazine->getPreprod() == true) {
  25.             return $this->json(['message' => 'Magazine not found'], Response::HTTP_NOT_FOUND);
  26.         }*/
  27.         $theme $magazine->getThemeBgColor();
  28.         $contrast $magazine->getContrastBgColor();
  29.         if (null === ($theme)) {
  30.             $theme "";
  31.         }
  32.         if (null === ($contrast)) {
  33.             $contrast "";
  34.         }        
  35.         return $this->json(['theme' => $theme'contrast' => $contrast]);
  36.     }
  37.     
  38. }