42 lines
1.1 KiB
PHP
42 lines
1.1 KiB
PHP
<?php
|
|
namespace Mince;
|
|
|
|
use Index\Http\Routing\{HttpGet,RouteHandler};
|
|
use Sasae\SasaeEnvironment;
|
|
|
|
class HomeRoutes extends RouteHandler {
|
|
public function __construct(
|
|
private SasaeEnvironment $templating,
|
|
private Servers $servers,
|
|
private object $userInfo,
|
|
private string $loginUrl
|
|
) {}
|
|
|
|
#[HttpGet('/')]
|
|
public function getIndex($response, $request) {
|
|
return $this->templating->render('index', [
|
|
'servers' => iterator_to_array($this->servers->getServers(deleted: false)),
|
|
]);
|
|
}
|
|
|
|
#[HttpGet('/login')]
|
|
public function getLogin($response) {
|
|
$response->redirect($this->userInfo->success ? '/' : $this->loginUrl);
|
|
}
|
|
|
|
#[HttpGet('/downloads')]
|
|
public function getDownloads() {
|
|
return $this->templating->render('downloads');
|
|
}
|
|
|
|
#[HttpGet('/guide')]
|
|
public function getGuide() {
|
|
return $this->templating->render('guide');
|
|
}
|
|
|
|
#[HttpGet('/index.php')]
|
|
public function getRedirect($response) {
|
|
$response->redirect('/', true);
|
|
}
|
|
}
|