- <?php
- 
- namespace AutomarketBundle\Controller;
- 
- use CoreBundle\Component\CoreFormFactory;
- use CoreBundle\Model\Post;
- use Doctrine\ORM\EntityManagerInterface;
- use PortalBundle\Model\SeoMetaTag;
- use Symfony\Component\HttpFoundation\Request;
- use Symfony\Component\HttpFoundation\RequestStack;
- use Symfony\Component\HttpFoundation\Response;
- use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
- 
- class PostController extends BaseController
- {
-     public function __construct(CoreFormFactory $coreFormFactory, RequestStack $requestStack, EntityManagerInterface $em, SeoMetaTag $seoMetaTag)
-     {
-         parent::__construct($coreFormFactory, $requestStack, $em, $seoMetaTag);
-     }
- 
-     public function news(): Response
-     {
-         $news = $this->em->getRepository(\CoreBundle\Entity\Post::class)->getNewsByDealer($this->getDealer());
-         return $this->baseAutomarketRender('@Automarket/Post/news.html.twig', ['news' => $news]);
-     }
- 
-     public function newsSingle(Request $request): Response
-     {
-         $url = $request->get('url');
-         $dealer = $this->getDealer();
-         $postRepo = $this->em->getRepository(\CoreBundle\Entity\Post::class);
-         $post = $postRepo->getPostByUrl($dealer, $url, Post::POST_TYPE_NEWS);
-         if (!$post) {
-             throw new NotFoundHttpException();
-         }
-         $interesting = $postRepo->getNewsByDealer($dealer, 2, $url);
- 
-         $pForm = $post->getId() != 944 ? null : $this->CoreFormFactory()->fbDefQuestionForm('Интересует партнерство по выкупу авто', null,null, $this->getDealer())->createView();
- 
-         return $this->baseAutomarketRender('@Automarket/Post/news-single.html.twig', [
-             'news' => $post,
-             'interesting' => $interesting,
-             'partnerFbForm' => $pForm,
-         ]);
-     }
- }
-