mirror of
https://github.com/openvk/chandler.git
synced 2025-03-31 21:43:59 +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;
|
use Chandler\MVC\Routing\Router;
|
||||||
|
|
||||||
/**
|
|
||||||
* Bootstrap class, that is called during framework starting phase.
|
|
||||||
* Initializes everything.
|
|
||||||
*
|
|
||||||
* @author kurotsun <celestine@vriska.ru>
|
|
||||||
* @internal
|
|
||||||
*/
|
|
||||||
class Bootstrap
|
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
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function ignite(): void
|
public function ignite(): void
|
||||||
{
|
{
|
||||||
$this->igniteExtensions();
|
Chandler\Extensions\ExtensionManager::getInstance();
|
||||||
header("Referrer-Policy: strict-origin-when-cross-origin");
|
ob_start();
|
||||||
$this->route($_SERVER["REQUEST_URI"]);
|
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