/+junk/StupidMVC

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/%2Bjunk/StupidMVC

« back to all changes in this revision

Viewing changes to Common/AbstractController.php

  • Committer: Gustav Hartvigsson
  • Date: 2016-03-15 21:09:11 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20160315210911-3jgqymrctds0lj8n
* initial code

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
}