pot/author/project/system/controllers/index.php

71 lines
1.2 KiB
PHP
Raw Normal View History

2024-01-11 04:35:40 +07:00
<?php
declare(strict_types=1);
2024-01-11 05:38:30 +07:00
namespace ${REPO_OWNER}\${REPO_NAME}\controllers;
2024-01-11 04:35:40 +07:00
// Files of the project
2024-01-11 05:38:30 +07:00
use ${REPO_OWNER}\${REPO_NAME}\controllers\core;
2024-01-11 04:35:40 +07:00
// Framework for PHP
use mirzaev\minimal\http\enumerations\content,
mirzaev\minimal\http\enumerations\status;
2024-01-11 04:35:40 +07:00
/**
* Index
2024-01-11 04:35:40 +07:00
*
2024-01-11 05:38:30 +07:00
* @package ${REPO_OWNER}\${REPO_NAME}\controllers
*
2024-12-15 22:16:01 +07:00
* @param array $$errors Registry of errors
*
* @method null index() Main page
*
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
* @author ${REPO_OWNER} <mail@domain.zone>
2024-01-11 04:35:40 +07:00
*/
final class index extends core
{
/**
* Errors
*
2024-12-15 22:16:01 +07:00
* @var array $$errors Registry of errors
*/
2024-12-15 22:16:01 +07:00
protected array $$errors = [
'session' => []
];
/**
* Main page
2024-01-11 04:35:40 +07:00
*
* @return null
2024-01-11 04:35:40 +07:00
*/
public function index(): null
2024-01-11 04:35:40 +07:00
{
2024-12-15 22:16:01 +07:00
if (str_contains($$this->request->headers['accept'], content::any->value)) {
// Request for any response
// Render page
2024-12-15 22:16:01 +07:00
$$page = $$this->view->render('index.html');
// Sending response
2024-12-15 22:16:01 +07:00
$$this->response
->start()
->clean()
->sse()
2024-12-15 22:16:01 +07:00
->write($$page)
->validate($$this->request)
?->body()
->end();
// Deinitializing rendered page
2024-12-15 22:16:01 +07:00
unset($$page);
// Exit (success)
return null;
}
2024-01-11 04:35:40 +07:00
// Exit (fail)
return null;
}
}