ladogton2010 commited on
Commit
023cdb0
·
1 Parent(s): 21dd205

test controllers

Browse files
mvc/app/controllers/Welcome.php CHANGED
@@ -2,6 +2,13 @@
2
  class Welcome{
3
  public function __construct(){
4
  echo('Welcome to app');
5
- }
6
- }
7
-
 
 
 
 
 
 
 
 
2
  class Welcome{
3
  public function __construct(){
4
  echo('Welcome to app');
5
+ }
6
+
7
+ public function index(){
8
+ echo('index loaded');
9
+ }
10
+
11
+ public function test($data){
12
+ echo('Received: ' . $data);
13
+ }
14
+ }
mvc/app/libs/Core.php CHANGED
@@ -26,9 +26,21 @@
26
  $this->defaultController = ucwords($url[0]);
27
  unset($url[0]);
28
  }
 
29
  }
30
  require_once('../app/controllers/' . $this->defaultController . '.php');
31
  $this->defaultController = new $this->defaultController;
 
 
 
 
 
 
 
 
 
 
 
32
  }
33
 
34
  public function getURL(){
 
26
  $this->defaultController = ucwords($url[0]);
27
  unset($url[0]);
28
  }
29
+
30
  }
31
  require_once('../app/controllers/' . $this->defaultController . '.php');
32
  $this->defaultController = new $this->defaultController;
33
+
34
+ if (isset($url[1])) {
35
+ if (method_exists($this->defaultController, $url[1])) {
36
+ $this->defaultMethod = $url[1];
37
+ unset($url[1]);
38
+ }
39
+ }
40
+
41
+ $this->defaultParams = $url ? array_values($url) : [];
42
+
43
+ call_user_func_array([$this->defaultController,$this->defaultMethod],$this->defaultParams);
44
  }
45
 
46
  public function getURL(){