You are on page 1of 2

<?

php

class Router {

public function __construct($ruta) {


Self::get_router($ruta);
}

public function get_router($ruta) {


switch ($ruta) {
case 'home':
include_once "controllers/Home.php";
$controllers = new Home();
break;
case 'post':
include_once "controllers/Post.php";
$controllers = new Post();
break;
case 'search':
include_once "controllers/Search.php";
$controllers = new Search();
break;
}

if (isset($_GET['view'])) {
$array = explode('/', $_GET['view']);
$ruta = $array[0];
$deineRoute = new Router($ruta);
} else {
include_once "controllers/Home.php";
$login = new Home();
}
case 'wall':
include_once "controllers/Wall.php";
$controllers = new Wall();
break;
case 'support':
include_once "controllers/Support.php";
$controllers = new Support();
break;
case 'add':
include_once "controllers/AddPost.php";
$controllers = new AddPost();
break;
case 'login':
include_once "controllers/Login.php";
$controllers = new Login();
break;
case 'register':
include_once "controllers/Register.php";
$controllers = new Register();
break;
default:
include_once "controllers/Default.php";
$controllers = new PageDefault();
break;
}
}

You might also like