2019-06-13 15:18:47 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Engelsystem\Controllers;
|
|
|
|
|
2019-06-14 04:05:38 +02:00
|
|
|
use Engelsystem\Config\Config;
|
|
|
|
use Engelsystem\Helpers\Authenticator;
|
2020-05-10 15:55:44 +02:00
|
|
|
use Engelsystem\Http\Redirector;
|
|
|
|
use Engelsystem\Http\Response;
|
2019-06-13 15:18:47 +02:00
|
|
|
|
|
|
|
class HomeController extends BaseController
|
|
|
|
{
|
2020-05-10 15:55:44 +02:00
|
|
|
/** @var Authenticator */
|
2019-06-14 04:05:38 +02:00
|
|
|
protected $auth;
|
|
|
|
|
2020-05-10 15:55:44 +02:00
|
|
|
/** @var Config */
|
2019-06-14 04:05:38 +02:00
|
|
|
protected $config;
|
|
|
|
|
2020-05-10 15:55:44 +02:00
|
|
|
/** @var Redirector */
|
|
|
|
protected $redirect;
|
|
|
|
|
2019-06-14 04:05:38 +02:00
|
|
|
/**
|
|
|
|
* @param Authenticator $auth
|
|
|
|
* @param Config $config
|
2020-05-10 15:55:44 +02:00
|
|
|
* @param Redirector $redirect
|
2019-06-14 04:05:38 +02:00
|
|
|
*/
|
2020-05-10 15:55:44 +02:00
|
|
|
public function __construct(Authenticator $auth, Config $config, Redirector $redirect)
|
2019-06-14 04:05:38 +02:00
|
|
|
{
|
|
|
|
$this->auth = $auth;
|
|
|
|
$this->config = $config;
|
2020-05-10 15:55:44 +02:00
|
|
|
$this->redirect = $redirect;
|
2019-06-14 04:05:38 +02:00
|
|
|
}
|
|
|
|
|
2019-06-13 15:18:47 +02:00
|
|
|
/**
|
2020-05-10 15:55:44 +02:00
|
|
|
* @return Response
|
2019-06-13 15:18:47 +02:00
|
|
|
*/
|
2020-05-10 15:55:44 +02:00
|
|
|
public function index(): Response
|
2019-06-13 15:18:47 +02:00
|
|
|
{
|
2020-05-10 15:55:44 +02:00
|
|
|
return $this->redirect->to($this->auth->user() ? $this->config->get('home_site') : 'login');
|
2019-06-13 15:18:47 +02:00
|
|
|
}
|
|
|
|
}
|