forked from 4iz278/cviceni
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap.php
37 lines (32 loc) · 1.02 KB
/
bootstrap.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
<?php
date_default_timezone_set("Europe/Prague");
session_start();
require_once './application/config.php';
require_once './application/library/Autoloader.php';
Autoloader::registerSplAutoload();
if (@$_REQUEST['controller']!=''){
$controllerName=ucfirst(trim($_REQUEST['controller'])).'Controller';
}else{
$controllerName='HomepageController';
$_REQUEST['controller']='default';
}
if (isset($_REQUEST['action'])){
$action=trim($_REQUEST['action']).'Action';
}else{
$action='defaultAction';
}
//overeni existence controlleru a jeho spusteni
//vytvoření controlleru a kontrola, jestli existuje požadovaná metoda
if(Autoloader::controllerExists($controllerName)){
/** @var $controller controller */
$controller=new $controllerName();
if (method_exists($controller,$action)){
$controller->$action();
}else{
$controller->generateError('404','Požadovaná stránka nebyla nalezena.');
}
}else{
header("HTTP/1.0 404 Not Found");
exit('Požadovaná stránka nebyla nalezena.');
}
$controller->display();