<?php
/**
* @author Antony Tkachenko <at@canaryknight.ru>
*/
namespace App\Controller;
use App\Helper\LastModifyHelper;
use App\Services\WalletRedirect\WalletRedirectService;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Component\Routing\Annotation\Route;
class WalletController extends AbstractController
{
private WalletRedirectService $walletRedirectService;
private LastModifyHelper $tracker;
public function __construct(WalletRedirectService $walletRedirectService, KernelInterface $appKernel)
{
$this->walletRedirectService = $walletRedirectService;
$this->tracker = new LastModifyHelper($appKernel);
}
/**
* @Route("/wallet", name="wallet_index", methods={"GET"})
*/
public function index()
{
$redirectRoute = $this->walletRedirectService->getWalletRouteName();
if ($redirectRoute){
return $this->redirectToRoute($redirectRoute);
}
$template = 'wallet/index.html.twig';
$modified = $this->tracker->get($template);
$response = $this->render($template, ['modified' => $modified]);
$response->headers->set('Last-Modified', $modified);
return $response;
}
/**
* @Route("/wallet/otkritie", name="wallet_otkritie", methods={"GET"})
*/
public function otkritie(): Response
{
// Временное скрытие страницы.
throw $this->createNotFoundException();
$this->walletRedirectService->setSource(WalletRedirectService::SOURCE_OPEN_BANK);
return $this->render('wallet/otkritie/index.html.twig', ['modified' => $this->tracker->get('wallet/otkritie/index.html.twig')]);
}
/**
* @Route("/wallet/otkritie/tariff", name="wallet_otkritie_tariff", methods={"GET"})
*/
public function otkritieTariff(): Response
{
// Временное скрытие страницы.
throw $this->createNotFoundException();
return $this->render('wallet/otkritie/tariff.html.twig', ['modified' => $this->tracker->get('wallet/otkritie/tariff.html.twig')]);
}
/**
* @Route("/wallet/gpb", name="wallet_gpb", methods={"GET"})
*/
public function gpb(): Response
{
$this->walletRedirectService->setSource(WalletRedirectService::SOURCE_GPB);
$template = 'wallet/gpb/index.html.twig';
$modified = $this->tracker->get($template);
$response = $this->render('wallet/gpb/index.html.twig', ['modified' => $modified]);
$response->headers->set('Last-Modified', $modified);
return $response;
}
/**
* @Route("/wallet/gpb/tariff", name="wallet_gpb_tariff", methods={"GET"})
*/
public function gpbTariff(): Response
{
$this->walletRedirectService->setSource(WalletRedirectService::SOURCE_GPB);
$template = 'wallet/gpb/tariff.html.twig';
$modified = $this->tracker->get($template);
$response = $this->render($template, ['modified' => $modified]);
$response->headers->set('Last-Modified', $modified);
return $response;
}
}