mirror of
https://github.com/openvk/chandler.git
synced 2025-03-29 12:38:12 +03:00
Simplifying the Bootstrap class.
This commit is contained in:
parent
6c8dcb3017
commit
03862ad43c
1 changed files with 9 additions and 41 deletions
|
@ -4,53 +4,21 @@ declare(strict_types = 1);
|
|||
|
||||
use Chandler\MVC\Routing\Router;
|
||||
|
||||
/**
|
||||
* Bootstrap class, that is called during framework starting phase.
|
||||
* Initializes everything.
|
||||
*
|
||||
* @author kurotsun <celestine@vriska.ru>
|
||||
* @internal
|
||||
*/
|
||||
class Bootstrap
|
||||
{
|
||||
/**
|
||||
* Bootstraps extensions.
|
||||
*
|
||||
* @return void
|
||||
* @internal
|
||||
*/
|
||||
private function igniteExtensions(): void
|
||||
{
|
||||
Chandler\Extensions\ExtensionManager::getInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts router and serves request.
|
||||
*
|
||||
* @param string $url Request URL
|
||||
*
|
||||
* @return void
|
||||
* @internal
|
||||
*/
|
||||
private function route(string $url): void
|
||||
{
|
||||
ob_start();
|
||||
if (($output = Router::getInstance()->execute($url)) !== null)
|
||||
echo $output;
|
||||
else
|
||||
chandler_http_panic(404, "Not Found", "No routes for $url.");
|
||||
ob_flush();
|
||||
ob_end_flush();
|
||||
flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function ignite(): void
|
||||
{
|
||||
$this->igniteExtensions();
|
||||
header("Referrer-Policy: strict-origin-when-cross-origin");
|
||||
$this->route($_SERVER["REQUEST_URI"]);
|
||||
Chandler\Extensions\ExtensionManager::getInstance();
|
||||
ob_start();
|
||||
if (($output = Router::getInstance()->execute($_SERVER["REQUEST_URI"])) !== null)
|
||||
echo $output;
|
||||
else
|
||||
chandler_http_panic(404, "Not Found", "No routes for {$_SERVER["REQUEST_URI"]}.");
|
||||
ob_flush();
|
||||
ob_end_flush();
|
||||
flush();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue