PHP 8.4 + MINIMAL 3.2.0 + many improvements
This commit is contained in:
53
author/project/system/controllers/index.php
Normal file → Executable file
53
author/project/system/controllers/index.php
Normal file → Executable file
@@ -7,24 +7,61 @@ namespace ${REPO_OWNER}\${REPO_NAME}\controllers;
|
||||
// Files of the project
|
||||
use ${REPO_OWNER}\${REPO_NAME}\controllers\core;
|
||||
|
||||
// Framework for PHP
|
||||
use mirzaev\minimal\http\enumerations\status;
|
||||
|
||||
/**
|
||||
* Index controller
|
||||
* Index
|
||||
*
|
||||
* @package ${REPO_OWNER}\${REPO_NAME}\controllers
|
||||
* @author ${REPO_OWNER} < mail >
|
||||
*
|
||||
* @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>
|
||||
*/
|
||||
final class index extends core
|
||||
{
|
||||
/**
|
||||
* Render the main page
|
||||
* Errors
|
||||
*
|
||||
* @param array $parameters Parameters of the request (POST + GET)
|
||||
* @var array $errors Registry of errors
|
||||
*/
|
||||
public function index(array $parameters = []): ?string
|
||||
protected array $errors = [
|
||||
'session' => []
|
||||
];
|
||||
|
||||
/**
|
||||
* Main page
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public function index(): null
|
||||
{
|
||||
// Exit (success)
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'GET') return $this->view->render(DIRECTORY_SEPARATOR . 'index.html');
|
||||
else if ($_SERVER['REQUEST_METHOD'] === 'POST') return $main;
|
||||
if (str_contains($this->request->headers['accept'], content::any->value)) {
|
||||
// Request for any response
|
||||
|
||||
// Render page
|
||||
$page = $this->view->render('index.html');
|
||||
|
||||
// Sending response
|
||||
$this->response
|
||||
->start()
|
||||
->clean()
|
||||
->sse()
|
||||
->write($page)
|
||||
->validate($this->request)
|
||||
?->body()
|
||||
->end();
|
||||
|
||||
// Deinitializing rendered page
|
||||
unset($page);
|
||||
|
||||
// Exit (success)
|
||||
return null;
|
||||
}
|
||||
|
||||
// Exit (fail)
|
||||
return null;
|
||||
|
Reference in New Issue
Block a user