Init
This commit is contained in:
35
src/Core/Routing/Router.php
Normal file
35
src/Core/Routing/Router.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Routing;
|
||||
|
||||
use Bramus\Router\Router as RouterRouter;
|
||||
|
||||
class Router
|
||||
{
|
||||
private $_router;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->init();
|
||||
}
|
||||
|
||||
public function run()
|
||||
{
|
||||
$this->_router->run();
|
||||
}
|
||||
|
||||
private function init()
|
||||
{
|
||||
$this->_router = new RouterRouter();
|
||||
$this->loadFromFile(ROOT . DS . "routes");
|
||||
$this->_router->set404("404 - Not found");
|
||||
}
|
||||
|
||||
private function loadFromFile($path)
|
||||
{
|
||||
if (is_dir($path)) {
|
||||
$router = $this->_router;
|
||||
require $path . DS . "routes.php";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user