forked from dyorg/Lean
/
App.php
51 lines (45 loc) · 799 Bytes
/
App.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
namespace Lean;
class App extends Singleton
{
/**
* Verify either action is a method pre defined
*
* <exemples>
*
* $_REQUEST[action] = 'test';
* $this->test_action();
*
* $_POST[action] = 'hello';
* $this->hello_action();
*
* </exemples>
*/
public function __construct()
{
if(!empty($this->request()->action))
{
$method_action = $this->request()->action . '_action';
if(method_exists($this, $method_action))
{
$this->{$method_action}();
}
}
}
public function format()
{
return Format::singleton();
}
public function logger()
{
return Logger::singleton();
}
public function request()
{
return Request::singleton();
}
public function view()
{
return View::singleton(get_class($this));
}
}