src/Controller/Customer/StaticPagesController.php line 65

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Customer;
  3. use App\Entity\CarrierPricePostman;
  4. use App\Entity\Configuration;
  5. use Doctrine\ORM\EntityManagerInterface;
  6. use Exception;
  7. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  8. use Symfony\Component\HttpFoundation\Response;
  9. use Symfony\Contracts\Translation\TranslatorInterface;
  10. class StaticPagesController extends AbstractController
  11. {
  12.     /**
  13.      * Zobrazí robots.txt nad customer částí
  14.      * Na customer můžeme povolit robotům přístup ke všemu vyjma trackingu.
  15.      * @return Response
  16.      */
  17.     public function robotsTxtFile(): Response
  18.     {
  19.         $response = new Response(
  20.             implode("\n", [
  21.                 'User-agent: *',
  22.                 'Disallow: /track-and-trace/',
  23.             ]),
  24.             200
  25.         );
  26.         $response->headers->set('Content-Type''text/plain; charset=utf-8');
  27.         return $response;
  28.     }
  29.     /**
  30.      * Stranka O nas
  31.      * @return Response
  32.      */
  33.     public function aboutUs(): Response
  34.     {
  35.         return $this->render('Customer/Postman/about_us.html.twig', []);
  36.     }
  37.     /**
  38.      * Stranka Intro
  39.      * @param TranslatorInterface $translator
  40.      * @param EntityManagerInterface $em
  41.      * @return Response
  42.      */
  43.     public function index(TranslatorInterface $translatorEntityManagerInterface $em): Response
  44.     {
  45.         $carrierPricePostmanRepo $em->getRepository(CarrierPricePostman::class);
  46.         $countries $carrierPricePostmanRepo->getLowestNeighbourPrices($translator);
  47.         return $this->render('Customer/Postman/index.html.twig', ['countries' => $countries]);
  48.     }
  49.     /**
  50.      * Stranka s Kontaktnimi informacemi
  51.      * @param EntityManagerInterface $em
  52.      * @return Response
  53.      * @throws Exception
  54.      */
  55.     public function contact(EntityManagerInterface $em): Response
  56.     {
  57.         $config $em->getRepository(Configuration::class);
  58.         return $this->render('Customer/Postman/contact.html.twig', [
  59.             'support_postman_email' => $config->get('support_postman_email'),
  60.             'support_postman_phone' => $config->get('support_postman_phone'),
  61.             'depo_address_street' => $config->get('depo_address_street'),
  62.             'depo_address_city' => $config->get('depo_address_city'),
  63.             'depo_address_zipcode' => $config->get('depo_address_zipcode'),
  64.         ]);
  65.     }
  66.     /**
  67.      * Stranka Pro firmy
  68.      * @param EntityManagerInterface $em
  69.      * @return Response
  70.      * @throws Exception
  71.      */
  72.     public function b2b(EntityManagerInterface $em): Response
  73.     {
  74.         $config $em->getRepository(Configuration::class);
  75.         return $this->render('Customer/Postman/b2b.html.twig', [
  76.             'support_postman_email' => $config->get('support_postman_email'),
  77.             'support_postman_phone' => $config->get('support_postman_phone'),
  78.         ]);
  79.     }
  80.     /**
  81.      * Stranka s obchodnimi podminkami
  82.      *
  83.      * @return Response
  84.      */
  85.     public function termsAndConditions(): Response
  86.     {
  87.         return $this->render('Customer/Postman/terms_and_conditions.html.twig', []);
  88.     }
  89.     /**
  90.      * Vraci kontaktni informace do paticky
  91.      * @param TranslatorInterface $translator
  92.      * @param EntityManagerInterface $em
  93.      * @return Response
  94.      */
  95.     public function getContactInfo(TranslatorInterface $translatorEntityManagerInterface $em): Response
  96.     {
  97.         $configRepo $em->getRepository(Configuration::class);
  98.         try {
  99.             $email $configRepo->get('support_postman_email');
  100. //            $phone = $configRepo->get('support_delivery_phone');
  101.         } catch (Exception $ex) {
  102.             $email '';
  103. //            $phone = '';
  104.         }
  105.         return new Response(
  106.             $translator->trans(
  107.                 'Kontaktujte nás na adrese: %email% nebo na telefonním čísle: %phone%.',
  108.                 [
  109.                     '%email%' => $email,
  110. //                    '%phone%' => $phone
  111.                 ],
  112.                 'customer'
  113.             )
  114.         );
  115.     }
  116.     /**
  117.      * Nacita stranku ceniku - tabulek s cenou pro kazdou zemi
  118.      * @param EntityManagerInterface $em
  119.      * @return Response
  120.      * @throws Exception
  121.      */
  122.     public function priceList(EntityManagerInterface $em): Response
  123.     {
  124.         $config $em->getRepository(Configuration::class);
  125.         $carrierPricePostmanRepo $em->getRepository(CarrierPricePostman::class);
  126.         $countries $carrierPricePostmanRepo->getCarrierPrices();
  127.         $output = [];
  128.         foreach ($countries as $country) {
  129.             $output[$country->getCountry()->getName()][$country->getCountry()->getIso()][$country->getWeight(
  130.             )] = $country->getPriceSell();
  131.         }
  132.         return $this->render(
  133.             'Customer/Postman/price_list.html.twig',
  134.             [
  135.                 'support_postman_email' => $config->get('support_postman_email'),
  136.                 'support_postman_phone' => $config->get('support_postman_phone'),
  137.                 'countries' => $output
  138.             ]
  139.         );
  140.     }
  141. }