1 | <?php |
||
5 | class RouterController { |
||
6 | private $page; |
||
7 | private $controller; |
||
8 | private $part; |
||
9 | private $erreur; |
||
10 | |||
11 | //-------------------------- BUILDER ----------------------------------------------------------------------------// |
||
12 | public function __construct($page, $admin = null) { |
||
13 | if (strpos($page, "controller") !== false) { |
||
14 | $this->part = "app"; |
||
15 | if ($admin !== null) { |
||
16 | $this->part = "admin"; |
||
17 | } |
||
18 | |||
19 | $this->page = $page; |
||
20 | |||
21 | if (($this->getTestCoreController() === false) && ($this->getTestModuleController() === false)) { |
||
22 | $this->controller = $this->part."/".$this->page.".php"; |
||
23 | } |
||
24 | |||
25 | $this->getTestControllerExist(); |
||
26 | $this->erreur = false; |
||
27 | } |
||
28 | } |
||
29 | //-------------------------- END BUILDER ----------------------------------------------------------------------------// |
||
30 | |||
31 | |||
32 | //-------------------------- GETTER ----------------------------------------------------------------------------// |
||
33 | public function getController(){ |
||
34 | return $this->controller; |
||
35 | } |
||
36 | public function getErreur(){ |
||
37 | return $this->erreur; |
||
38 | } |
||
39 | |||
40 | /** |
||
41 | * @return bool |
||
42 | * this function set if is a controller core the link to the controller |
||
43 | */ |
||
44 | private function getTestCoreController() { |
||
52 | |||
53 | /** |
||
54 | * @return bool |
||
55 | * this function set if is a controller module the link to the controller |
||
56 | */ |
||
57 | private function getTestModuleController() { |
||
66 | |||
67 | /** |
||
68 | * @return mixed |
||
69 | * this function return link and delete controller at the begining of the link |
||
70 | */ |
||
71 | private function getBaseLink() { |
||
75 | |||
76 | /** |
||
77 | * redirect on 404 if controller doesn't exist |
||
78 | */ |
||
79 | private function getTestControllerExist() { |
||
84 | //-------------------------- END GETTER ----------------------------------------------------------------------------// |
||
85 | |||
86 | |||
87 | //-------------------------- SETTER ----------------------------------------------------------------------------// |
||
88 | //-------------------------- END SETTER ----------------------------------------------------------------------------// |
||
89 | } |