<?php
namespace App\Action\PressSite\Localization;
use App\Action\PressSite\DomainAwareAction;
use App\Service\PressSite\DomainAwareManager;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\RouterInterface;
use Twig\Environment;
/**
* Class LandingPageAction.
*/
class LandingPageAction extends DomainAwareAction
{
/**
* The routing manager.
*
* @var \Symfony\Component\Routing\RouterInterface
*/
private $router;
public function __construct(Environment $twig, DomainAwareManager $domainAwareManager, RouterInterface $router)
{
parent::__construct($twig, $domainAwareManager);
$this->router = $router;
}
/**
* Responsible for validating the current domain based on hostname and setting the request locale.
*
* @return \Symfony\Component\HttpFoundation\Response
* The generated response object
*/
public function __invoke(): Response
{
return new RedirectResponse(
$this->router->generate('press_site.actions.account.sign_in', [
'_locale' => $this->getDomainManager()->getCurrentByHostnameAndLocale()->getLanguageCode(),
])
);
}
}