<?php
namespace App\Controller\View\Magazine;
use App\Entity\Magazine\Magazine;
use Exception;
use function PHPSTORM_META\type;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
/**
* @Route("/view/theme")
*/
class ThemeController extends AbstractController
{
/**
* @Route("/{slug}", methods={"GET"})
*/
public function show(Request $request, $slug)
{
$magazine = $this->getDoctrine()->getRepository(Magazine::class)->findOneBy(['slug'=>$slug]);
if(!$magazine) {
return $this->json(['message' => 'magazine not found'], Response::HTTP_NOT_FOUND);
}
/*if($request->get('provider') != 'preprod' && $magazine->getPreprod() == true) {
return $this->json(['message' => 'Magazine not found'], Response::HTTP_NOT_FOUND);
}*/
$theme = $magazine->getThemeBgColor();
$contrast = $magazine->getContrastBgColor();
if (null === ($theme)) {
$theme = "";
}
if (null === ($contrast)) {
$contrast = "";
}
return $this->json(['theme' => $theme, 'contrast' => $contrast]);
}
}