<?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
class DefaultController extends AbstractController
{
private static ?string $version = null;
private array $topMenu = [
[
'link' => '/',
'nameEN' => 'Home',
'nameLV' => 'sākums',
],
[
'link' => 'about-us',
'nameEN' => 'About us',
'nameLV' => 'par mums',
],
[
'link' => 'seed-potatoes-declaration',
'nameEN' => 'Seed potatoes decleration',
'nameLV' => 'Sēklas kartupeļu deklarēšana',
],
[
'link' => 'contacts',
'nameEN' => 'Contacts',
'nameLV' => 'kontakti',
],
];
public function getLocale(Request $request): Response
{
return new RedirectResponse(
sprintf(
'/%s/',
$request->getLocale()
)
);
}
public function index(): Response
{
return new Response(
$this->renderView(
'home.html.twig',
[
'title' => 'AmeLat Group SIA © 2007 - '.date('Y'),
'year' => date('Y'),
'topMenu' => $this->topMenu,
'version' => $this->getVersion()
]
)
);
}
public function aboutUs(): Response
{
return new Response(
$this->renderView(
'aboutUs.html.twig',
[
'title' => 'About Us | AmeLat Group SIA © 2007 - '.date('Y'),
'year' => date('Y'),
'topMenu' => $this->topMenu,
'version' => $this->getVersion()
]
)
);
}
public function contacts(): Response
{
return new Response(
$this->renderView(
'contacts.html.twig',
[
'title' => 'Contacts | AmeLat Group SIA © 2007 - '.date('Y'),
'year' => date('Y'),
'topMenu' => $this->topMenu,
'version' => $this->getVersion()
]
)
);
}
public function seedPotatoesDeclaration(): RedirectResponse
{
return $this->redirect('https://lsa.onlinetrader.lv/client_form/');
}
private function getVersion(): string
{
if (null !== self::$version) {
return self::$version;
}
$versionFromFile = file_exists('../CURRENT_PRODUCTION_TAG') ? file_get_contents('../CURRENT_PRODUCTION_TAG') : '1.0.0b';
self::$version = $versionFromFile;
return self::$version;
}
}