-
Notifications
You must be signed in to change notification settings - Fork 0
/
startup.php
44 lines (38 loc) · 1.98 KB
/
startup.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
include_once "libs/includes.php";
define("DB_NAME", 'db_users_stampy');
define("DB_USER", 'root');
define("DB_PASSWORD", '');
define("DB_HOST", 'localhost');
class Startup{
private $router;
public function init(){
$this->router = new Router();
//Añadimos las dependencias
DependencyInjectorEngine::add("UserController","UserController");
DependencyInjectorEngine::add("UserView","UserView");
DependencyInjectorEngine::add("HomeView","HomeView");
DependencyInjectorEngine::addSingleton("UserModel","UserModel");
DependencyInjectorEngine::addSingleton("IAuthService","AuthService");
DependencyInjectorEngine::add("INavigationService","NavigationService");
$this->setRoutes();
$this->startRouter();
}
private function setRoutes(){
//"encendemos" el router
$this->router->addRoute("home", "GET", "HomeController", "showList");
$this->router->addRoute("login", "GET", "UserController", "login");
$this->router->addRoute("logout", "GET", "UserController", "logout");
$this->router->addRoute("log-user", "POST", "UserController", "logUser");
$this->router->addRoute("editar-usuario/:ID","GET","UserController","editUser");
$this->router->addRoute("anadir-usuario","GET","UserController","editUser");
$this->router->addRoute("eliminar-usuario/:ID","GET","HomeController","deleteUser");
$this->router->addRoute("guardar-usuario/:ID","POST","UserController","saveUser");
$this->router->addRoute("guardar-usuario","POST","UserController","saveNewUser");
$this->router->setDefaultRoute("HomeController", "showList");
}
private function startRouter(){
$this->router->route($_GET['action'], $_SERVER['REQUEST_METHOD']);
}
}
(new Startup())->init();