bzr branch
http://gegoxaren.bato24.eu/bzr/%2Bjunk/StupidMVC
|
1
by Gustav Hartvigsson
* initial code |
1 |
<?php
|
2 |
||
3 |
abstract class AbstractController { |
|
4 |
protected function __contructor () { |
|
5 |
||
6 |
}
|
|
7 |
||
8 |
public function default_method () { |
|
9 |
echo "<h1>It Works!</h1>"; |
|
10 |
}
|
|
11 |
||
12 |
/**
|
|
13 |
* This should return a list of method names.
|
|
14 |
*
|
|
15 |
* @code{.php}
|
|
16 |
function get_methods () {
|
|
17 |
$ret_val = [
|
|
18 |
"method_one",
|
|
19 |
"method_two",
|
|
20 |
...
|
|
21 |
];
|
|
22 |
|
|
23 |
return ret_val;
|
|
24 |
}
|
|
25 |
* @endcode
|
|
26 |
*/
|
|
27 |
abstract public function get_methods (); |
|
28 |
||
29 |
/**
|
|
30 |
* Get the custom rout definitions.
|
|
31 |
*/
|
|
32 |
abstract public function get_routes (); |
|
33 |
||
34 |
/**
|
|
35 |
* load a view class.
|
|
36 |
*/
|
|
37 |
public function load_view ($view, $user_data) { |
|
38 |
require (ROOT_DIR . "View" . DS . $view . ".php"); |
|
39 |
$$view = new $view (); |
|
40 |
$$view->render ($user_data); |
|
41 |
}
|
|
42 |
||
43 |
/**
|
|
44 |
* Returns a model object
|
|
45 |
*/
|
|
46 |
public function load_model ($model) { |
|
47 |
require (ROOT_DIR . "Model" . DS . $model . ".php"); |
|
48 |
$$model = new $model (); |
|
49 |
||
50 |
return $$model; |
|
51 |
}
|
|
52 |
||
53 |
}
|