src/AutomarketBundle/Controller/PostController.php line 43

Open in your IDE?
  1. <?php
  2. namespace AutomarketBundle\Controller;
  3. use CoreBundle\Component\CoreFormFactory;
  4. use CoreBundle\Model\Post;
  5. use Doctrine\ORM\EntityManagerInterface;
  6. use PortalBundle\Model\SeoMetaTag;
  7. use Symfony\Component\HttpFoundation\Request;
  8. use Symfony\Component\HttpFoundation\RequestStack;
  9. use Symfony\Component\HttpFoundation\Response;
  10. use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
  11. class PostController extends BaseController
  12. {
  13.     public function __construct(CoreFormFactory $coreFormFactoryRequestStack $requestStackEntityManagerInterface $emSeoMetaTag $seoMetaTag)
  14.     {
  15.         parent::__construct($coreFormFactory$requestStack$em$seoMetaTag);
  16.     }
  17.     public function news(): Response
  18.     {
  19.         $news $this->em->getRepository(\CoreBundle\Entity\Post::class)->getNewsByDealer($this->getDealer());
  20.         return $this->baseAutomarketRender('@Automarket/Post/news.html.twig', ['news' => $news]);
  21.     }
  22.     public function newsSingle(Request $request): Response
  23.     {
  24.         $url $request->get('url');
  25.         $dealer $this->getDealer();
  26.         $postRepo $this->em->getRepository(\CoreBundle\Entity\Post::class);
  27.         $post $postRepo->getPostByUrl($dealer$urlPost::POST_TYPE_NEWS);
  28.         if (!$post) {
  29.             throw new NotFoundHttpException();
  30.         }
  31.         $interesting $postRepo->getNewsByDealer($dealer2$url);
  32.         $pForm $post->getId() != 944 null $this->CoreFormFactory()->fbDefQuestionForm('Интересует партнерство по выкупу авто'null,null$this->getDealer())->createView();
  33.         return $this->baseAutomarketRender('@Automarket/Post/news-single.html.twig', [
  34.             'news' => $post,
  35.             'interesting' => $interesting,
  36.             'partnerFbForm' => $pForm,
  37.         ]);
  38.     }
  39. }