<?php
namespace DcSiteBundle\Controller\ToyotaBorispol;
use CoreBundle\Component\CoreFormFactory;
use CoreBundle\Component\FormManager;
use CoreBundle\Entity\ViDiDepartment;
use CoreBundle\Factory\Vehicle as VehicleFactory;
use CoreBundle\Model\Api\OnlineService\ApiServer1C;
use CoreBundle\Model\Post;
use CoreBundle\Model\Vehicles\Repository;
use CoreBundle\Model\ViDiWorkerModel;
use CoreBundle\Services\MediaExtensionVidi;
use DcSiteBundle\Entity\Vacancy;
use Doctrine\ORM\EntityManagerInterface;
use PortalBundle\Model\SeoMetaTag;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\Routing\RouterInterface;
use Twig\Environment;
class AboutController extends BaseController
{
public function __construct(CoreFormFactory $coreFormFactory, SeoMetaTag $seoMetaTag, RequestStack $requestStack, RouterInterface $router, FormManager $formManager, EntityManagerInterface $em, ApiServer1C $apiServer1C, SessionInterface $session, Filesystem $filesystem, MediaExtensionVidi $mediaExtensionVidi, Repository $vehicleRepository, VehicleFactory $vehicleFactory, Environment $twig)
{
parent::__construct($coreFormFactory, $seoMetaTag, $requestStack, $router, $formManager, $em, $apiServer1C, $session, $filesystem, $mediaExtensionVidi, $vehicleRepository, $vehicleFactory, $twig);
}
public function about(): ?Response
{
return $this->baseToyotaBorispol('@DcSite/Toyota_Borispol/About/about-us.html.twig', [
]);
}
public function contact(): ?Response
{
$departments = $this->em->getRepository(ViDiDepartment::class)->findBy(['dealer' => $this->getDealer()]);
return $this->baseToyotaBorispol('@DcSite/Toyota_Borispol/About/contact.html.twig', [
'departments' => $departments,
]);
}
public function qualityPolicy(): ?Response
{
return $this->baseToyotaBorispol('@DcSite/Toyota_Borispol/About/quality-policy.html.twig', [
]);
}
public function team(Request $request, ViDiWorkerModel $viDiWorkerModel): ?Response
{
$workers = $viDiWorkerModel->getAllByDealer($this->getDealer(), $request->getLocale());
return $this->baseToyotaBorispol('@DcSite/Toyota_Borispol/About/team.html.twig', [
'workers' => $workers,
'callbackForm' => $this->CoreFormFactory()->orderCallForm(null, $this->getDealer())->createView(),
]);
}
public function vacancy(): ?Response
{
$vacancies = $this->em->getRepository(Vacancy::class)->getByDealer($this->getDealer());
return $this->baseToyotaBorispol('@DcSite/Toyota_Borispol/About/vacancy.html.twig', [
'vacancies' => $vacancies,
]);
}
public function vacancySingle($id): ?Response
{
$vacancy = $this->em->getRepository(Vacancy::class)->getByID($id);
if (!$vacancy) {
throw new NotFoundHttpException();
}
return $this->baseToyotaBorispol('@DcSite/Toyota_Borispol/About/vacancy-single.html.twig', [
'vacancy' => $vacancy,
'vacancyForm' => $this->CoreFormFactory()->vacancyForm($this->getDealer(), $vacancy)->createView(),
]);
}
public function news(): ?Response
{
$posts = $this->em->getRepository(\CoreBundle\Entity\Post::class)->getNewsByDealer($this->getDealer());
return $this->baseToyotaBorispol('@DcSite/Toyota_Borispol/About/news.html.twig', [
'posts' => $posts
]);
}
public function newsSingle(Request $request, Post $postModel): ?Response
{
$post = $postModel->initByUrl($this->getDealer(), $request->get('url'), Post::POST_TYPE_NEWS);
if (!$post) {
throw $this->createNotFoundException();
}
return $this->baseToyotaBorispol('@DcSite/Toyota_Borispol/About/news-single.html.twig', [
'post' => $post,
]);
}
public function actions(): ?Response
{
$posts['cars'] = $this->em->getRepository(\CoreBundle\Entity\Post::class)->getActionsByDealer($this->getDealer(), Post::ACTION_TYPE_CAR);
$posts['service'] = $this->em->getRepository(\CoreBundle\Entity\Post::class)->getActionsByDealer($this->getDealer(), Post::ACTION_TYPE_SERVICE);
$posts['all'] = array_merge($posts['cars'], $posts['service']);
return $this->baseToyotaBorispol('@DcSite/Toyota_Borispol/About/actions.html.twig', ['posts' => $posts]);
}
public function actionsSingle(Request $request, Post $postModel): ?Response
{
$post = $postModel->initByUrl($this->getDealer(), $request->get('url'), Post::POST_TYPE_ACTIONS);
if (!$post) {
throw $this->createNotFoundException();
}
return $this->baseToyotaBorispol('@DcSite/Toyota_Borispol/About/actions-single.html.twig', [
'post' => $post,
]);
}
public function publicOffer(): ?Response
{
return $this->baseToyotaBorispol('@DcSite/Toyota_Borispol/About/public-offer.html.twig', ['dealer' => $this->getDealer()]);
}
public function returnRefundPolicies(): ?Response
{
return $this->baseToyotaBorispol('@DcSite/Toyota_Borispol/About/return-refund-policies.html.twig');
}
}