2023-08-16 23:45:46 +00:00
|
|
|
<?php
|
|
|
|
namespace Mince;
|
|
|
|
|
2024-03-28 23:28:19 +00:00
|
|
|
use Index\Http\Routing\{HttpGet,RouteHandler};
|
2023-08-24 23:13:29 +00:00
|
|
|
use Sasae\SasaeEnvironment;
|
2023-08-16 23:45:46 +00:00
|
|
|
|
2024-02-21 16:08:45 +00:00
|
|
|
class HomeRoutes extends RouteHandler {
|
2023-08-16 23:45:46 +00:00
|
|
|
public function __construct(
|
2023-08-24 23:13:29 +00:00
|
|
|
private SasaeEnvironment $templating,
|
2023-08-17 00:23:55 +00:00
|
|
|
private Servers $servers,
|
2023-08-22 23:47:37 +00:00
|
|
|
private object $userInfo,
|
|
|
|
private string $loginUrl
|
2023-08-16 23:45:46 +00:00
|
|
|
) {}
|
|
|
|
|
2024-03-28 23:28:19 +00:00
|
|
|
#[HttpGet('/')]
|
2023-08-16 23:45:46 +00:00
|
|
|
public function getIndex($response, $request) {
|
|
|
|
return $this->templating->render('index', [
|
2024-02-21 16:08:45 +00:00
|
|
|
'servers' => iterator_to_array($this->servers->getServers(deleted: false)),
|
2023-08-16 23:45:46 +00:00
|
|
|
]);
|
|
|
|
}
|
2023-08-22 23:47:37 +00:00
|
|
|
|
2024-03-28 23:28:19 +00:00
|
|
|
#[HttpGet('/login')]
|
2024-02-21 16:08:45 +00:00
|
|
|
public function getLogin($response) {
|
|
|
|
$response->redirect($this->userInfo->success ? '/' : $this->loginUrl);
|
|
|
|
}
|
|
|
|
|
2024-03-28 23:28:19 +00:00
|
|
|
#[HttpGet('/downloads')]
|
2023-08-22 23:47:37 +00:00
|
|
|
public function getDownloads() {
|
|
|
|
return $this->templating->render('downloads');
|
|
|
|
}
|
2023-08-23 20:59:04 +00:00
|
|
|
|
2024-03-28 23:28:19 +00:00
|
|
|
#[HttpGet('/guide')]
|
2023-08-23 20:59:04 +00:00
|
|
|
public function getGuide() {
|
|
|
|
return $this->templating->render('guide');
|
|
|
|
}
|
2024-02-21 16:08:45 +00:00
|
|
|
|
2024-03-28 23:28:19 +00:00
|
|
|
#[HttpGet('/index.php')]
|
2024-02-21 16:08:45 +00:00
|
|
|
public function getRedirect($response) {
|
|
|
|
$response->redirect('/', true);
|
|
|
|
}
|
2023-08-16 23:45:46 +00:00
|
|
|
}
|