1 | <?php |
||
12 | class App |
||
13 | { |
||
14 | /** |
||
15 | * Events |
||
16 | */ |
||
17 | private static $events; |
||
18 | |||
19 | /** |
||
20 | * Return value from application |
||
21 | * |
||
22 | * @var string |
||
23 | */ |
||
24 | private $output = false; |
||
25 | |||
26 | /** |
||
27 | * Namespaced controller path |
||
28 | * |
||
29 | * @var string |
||
30 | */ |
||
31 | private $class; |
||
32 | |||
33 | /** |
||
34 | * Instantiated class object |
||
35 | * |
||
36 | * @var Controller |
||
37 | */ |
||
38 | private $instantiatedClass; |
||
39 | |||
40 | /** |
||
41 | * Module being accessed |
||
42 | * |
||
43 | * @var string |
||
44 | */ |
||
45 | private $module; |
||
46 | |||
47 | /** |
||
48 | * Controller being accessed |
||
49 | * |
||
50 | * @var string |
||
51 | */ |
||
52 | private $controller; |
||
53 | |||
54 | /** |
||
55 | * Method being accessed |
||
56 | * |
||
57 | * @var string |
||
58 | */ |
||
59 | private $method; |
||
60 | |||
61 | /** |
||
62 | * Params being passed |
||
63 | * |
||
64 | * @var array |
||
65 | */ |
||
66 | private $params; |
||
67 | |||
68 | /** |
||
69 | * @var DIContainer $container |
||
70 | */ |
||
71 | private $container; |
||
72 | |||
73 | /** |
||
74 | * Application bootstrap process |
||
75 | * |
||
76 | * The application registers the configuration in the app/config/core.php |
||
77 | * and then processes, and makes available the configured resources |
||
78 | * |
||
79 | * App constructor. |
||
80 | * @param DIContainer $container |
||
81 | */ |
||
82 | 28 | public function __construct(DIContainer $container) |
|
93 | |||
94 | /** |
||
95 | * Calls the proper shell for app execution |
||
96 | * |
||
97 | * @access private |
||
98 | */ |
||
99 | public function initialize() |
||
104 | |||
105 | /** |
||
106 | * App preparation cycle |
||
107 | */ |
||
108 | 18 | private function prepare() |
|
118 | |||
119 | // public function setContainer(Container $container) |
||
120 | // { |
||
121 | // $this->container = $container; |
||
122 | // } |
||
123 | |||
124 | /** |
||
125 | * Verifies the provided application request is a valid request |
||
126 | * |
||
127 | * @access private |
||
128 | */ |
||
129 | private function validateRequest() |
||
143 | |||
144 | /** |
||
145 | * Processes the application request |
||
146 | * |
||
147 | * @access private |
||
148 | */ |
||
149 | private function start() |
||
170 | |||
171 | /** |
||
172 | * Attach (or remove) multiple callbacks to an event and trigger those callbacks when that event is called. |
||
173 | * |
||
174 | * @param string $event name |
||
175 | * @param mixed $value the optional value to pass to each callback |
||
176 | * @param mixed $callback the method or function to call - FALSE to remove all callbacks for event |
||
177 | */ |
||
178 | |||
179 | public static function addEvent($event, $callback = false) |
||
188 | |||
189 | public function callEvent($event, $method = false, $arguments = []) |
||
211 | |||
212 | |||
213 | /** |
||
214 | * Prepare application return value into a string |
||
215 | * |
||
216 | * @access public |
||
217 | * @return string |
||
218 | */ |
||
219 | public function __toString() |
||
229 | } |
||
230 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: