2020-05-31 20:44:14 +02:00
|
|
|
<?php namespace MapGuesser\Controller;
|
|
|
|
|
2020-06-25 14:01:17 +02:00
|
|
|
use MapGuesser\Interfaces\Request\IRequest;
|
|
|
|
use MapGuesser\Interfaces\Response\IContent;
|
2020-05-31 20:44:14 +02:00
|
|
|
use MapGuesser\Interfaces\Response\IRedirect;
|
2020-06-25 14:01:17 +02:00
|
|
|
use MapGuesser\Response\JsonContent;
|
2020-05-31 20:44:14 +02:00
|
|
|
use MapGuesser\Response\Redirect;
|
|
|
|
|
|
|
|
class HomeController
|
|
|
|
{
|
2020-06-25 14:01:17 +02:00
|
|
|
private IRequest $request;
|
|
|
|
|
|
|
|
public function __construct(IRequest $request)
|
|
|
|
{
|
|
|
|
$this->request = $request;
|
|
|
|
}
|
|
|
|
|
2020-05-31 20:44:14 +02:00
|
|
|
public function getIndex(): IRedirect
|
|
|
|
{
|
2020-06-21 01:27:37 +02:00
|
|
|
return new Redirect(\Container::$routeCollection->getRoute('maps')->generateLink(), IRedirect::TEMPORARY);
|
2020-05-31 20:44:14 +02:00
|
|
|
}
|
2020-06-25 14:01:17 +02:00
|
|
|
|
|
|
|
public function startSession(): IContent
|
|
|
|
{
|
|
|
|
// session starts with the request, this method just sends valid data to the client
|
|
|
|
|
2020-07-05 00:58:03 +02:00
|
|
|
return new JsonContent(['antiCsrfToken' => $this->request->session()->get('anti_csrf_token')]);
|
2020-06-25 14:01:17 +02:00
|
|
|
}
|
2020-05-31 20:44:14 +02:00
|
|
|
}
|