<?php
namespace App\Controller\View\PublisherStore;
use App\Entity\Project\Publisher;
use App\Entity\Project\PublisherStore;
use App\Repository\PublisherRepository;
use App\Service\AdminEngineService;
use FOS\RestBundle\View\View;
use FOS\RestBundle\Controller\Annotations;
use FOS\RestBundle\Controller\FOSRestController;
use FOS\RestBundle\Routing\ClassResourceInterface;
use FOS\RestBundle\Controller\Annotations\RouteResource;
use FOS\UserBundle\Event\FilterUserResponseEvent;
use FOS\UserBundle\Event\GetResponseUserEvent;
use FOS\UserBundle\FOSUserEvents;
use FOS\UserBundle\Event\FormEvent;
use FOS\UserBundle\Model\UserInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Form\FormTypeInterface;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use App\Application\Sonata\MediaBundle\Entity\Media;
use App\Entity\Account\Subscription;
use App\Entity\Magazine\Magazine;
use App\Entity\Magazine\MagazinePage;
use App\Entity\Magazine\TOC;
use App\Service\SerializePageService;
use Symfony\Component\Serializer\Encoder\JsonEncoder;
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
use Symfony\Component\Serializer\Serializer;
use Symfony\Component\Serializer\NameConverter\MetadataAwareNameConverter;
use Doctrine\Common\Annotations\AnnotationReader;
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory;
use Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use FOS\RestBundle\Controller\AbstractFOSRestController;
use Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer;
use App\Application\Sonata\UserBundle\Entity\User;
/**
* @Route("/view/store")
*/
class PublisherStoreController extends AbstractFOSRestController
{
private $adminEngine;
public function __construct(AdminEngineService $adminEngine)
{
$this->adminEngine = $adminEngine;
}
/**
* @Route("/{slug}", methods={"GET"})
*/
public function show($slug)
{
$publisherStore = $this->getDoctrine()->getRepository(PublisherStore::class)->findActiveMagInStore($slug);
if(!$publisherStore) {
return $this->json(['message' => 'Publisher store cant find'], Response::HTTP_NOT_FOUND);
}
$store = $this->adminEngine->getRelatedMagazines($publisherStore);
return $this->json( $store, Response::HTTP_OK );
}
}