src/Controller/DefaultController.php line 62

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\HttpFoundation\RedirectResponse;
  5. use Symfony\Component\HttpFoundation\Request;
  6. use Symfony\Component\HttpFoundation\Response;
  7. class DefaultController extends AbstractController
  8. {
  9.     private static ?string $version null;
  10.     private array $topMenu = [
  11.         [
  12.             'link' => '/',
  13.             'nameEN' => 'Home',
  14.             'nameLV' => 'sākums',
  15.         ],
  16.         [
  17.             'link' => 'about-us',
  18.             'nameEN' => 'About us',
  19.             'nameLV' => 'par mums',
  20.         ],
  21.         [
  22.             'link' => 'seed-potatoes-declaration',
  23.             'nameEN' => 'Seed potatoes decleration',
  24.             'nameLV' => 'Sēklas kartupeļu deklarēšana',
  25.         ],
  26.         [
  27.             'link' => 'contacts',
  28.             'nameEN' => 'Contacts',
  29.             'nameLV' => 'kontakti',
  30.         ],
  31.     ];
  32.     public function getLocale(Request $request): Response
  33.     {
  34.         return new RedirectResponse(
  35.             sprintf(
  36.                 '/%s/',
  37.                 $request->getLocale()
  38.             )
  39.         );
  40.     }
  41.     public function index(): Response
  42.     {
  43.         return new Response(
  44.             $this->renderView(
  45.                 'home.html.twig',
  46.                 [
  47.                     'title' => 'AmeLat Group SIA &copy; 2007 - '.date('Y'),
  48.                     'year' => date('Y'),
  49.                     'topMenu' => $this->topMenu,
  50.                     'version' => $this->getVersion()
  51.                 ]
  52.             )
  53.         );
  54.     }
  55.     public function aboutUs(): Response
  56.     {
  57.         return new Response(
  58.             $this->renderView(
  59.                 'aboutUs.html.twig',
  60.                 [
  61.                     'title' => 'About Us | AmeLat Group SIA &copy; 2007 - '.date('Y'),
  62.                     'year' => date('Y'),
  63.                     'topMenu' => $this->topMenu,
  64.                     'version' => $this->getVersion()
  65.                 ]
  66.             )
  67.         );
  68.     }
  69.     public function contacts(): Response
  70.     {
  71.         return new Response(
  72.             $this->renderView(
  73.                 'contacts.html.twig',
  74.                 [
  75.                     'title' => 'Contacts | AmeLat Group SIA &copy; 2007 - '.date('Y'),
  76.                     'year' => date('Y'),
  77.                     'topMenu' => $this->topMenu,
  78.                     'version' => $this->getVersion()
  79.                 ]
  80.             )
  81.         );
  82.     }
  83.     public function seedPotatoesDeclaration(): RedirectResponse
  84.     {
  85.         return $this->redirect('https://lsa.onlinetrader.lv/client_form/');
  86.     }
  87.     private function getVersion(): string
  88.     {
  89.         if (null !== self::$version) {
  90.             return self::$version;
  91.         }
  92.         $versionFromFile file_exists('../CURRENT_PRODUCTION_TAG') ? file_get_contents('../CURRENT_PRODUCTION_TAG') : '1.0.0b';
  93.         self::$version $versionFromFile;
  94.         return self::$version;
  95.     }
  96. }