|
@@ -19,6 +19,7 @@ class LuticateApplication implements MessageComponentInterface
|
19
|
19
|
private $_version = 1.0;
|
20
|
20
|
private $_config = null;
|
21
|
21
|
private $_clients = null;
|
|
22
|
+ private $_router = null;
|
22
|
23
|
|
23
|
24
|
private static $_app = null;
|
24
|
25
|
|
|
@@ -34,9 +35,26 @@ class LuticateApplication implements MessageComponentInterface
|
34
|
35
|
{
|
35
|
36
|
$this->_config = $configuration;
|
36
|
37
|
$this->_clients = new \SplObjectStorage;
|
|
38
|
+ $this->_router = new LuRoute();
|
37
|
39
|
self::$_app = $this;
|
38
|
40
|
}
|
39
|
41
|
|
|
42
|
+ /**
|
|
43
|
+ * @return LuRoute
|
|
44
|
+ */
|
|
45
|
+ public function getRouter()
|
|
46
|
+ {
|
|
47
|
+ return $this->_router;
|
|
48
|
+ }
|
|
49
|
+
|
|
50
|
+ /**
|
|
51
|
+ * @param LuRoute|null $router
|
|
52
|
+ */
|
|
53
|
+ public function setRouter($router)
|
|
54
|
+ {
|
|
55
|
+ $this->_router = $router;
|
|
56
|
+ }
|
|
57
|
+
|
40
|
58
|
/**
|
41
|
59
|
* @param $version float
|
42
|
60
|
*/
|
|
@@ -55,21 +73,22 @@ class LuticateApplication implements MessageComponentInterface
|
55
|
73
|
|
56
|
74
|
public function setupRoutes()
|
57
|
75
|
{
|
58
|
|
- require_once __DIR__ . '/../../../../../../app/routes.php';
|
59
|
|
- $router = LuRoute::getInstance();
|
|
76
|
+ function($app)
|
|
77
|
+ {
|
|
78
|
+ require_once __DIR__ . '/../../../../../../app/routes.php';
|
|
79
|
+ }($this);
|
60
|
80
|
|
61
|
|
- $router->setup();
|
|
81
|
+ $this->_router->setup();
|
62
|
82
|
}
|
63
|
83
|
|
64
|
84
|
public function runHttp()
|
65
|
85
|
{
|
66
|
86
|
$httpMethod = $_SERVER['REQUEST_METHOD'];
|
67
|
87
|
$url = $_SERVER['REQUEST_URI'];
|
68
|
|
- $router = LuRoute::getInstance();
|
69
|
88
|
|
70
|
89
|
$parameters = array_merge($_GET, $_POST);
|
71
|
90
|
|
72
|
|
- $router->dispatch($httpMethod, $url, $parameters);
|
|
91
|
+ $this->_router->dispatch($httpMethod, $url, $parameters);
|
73
|
92
|
}
|
74
|
93
|
|
75
|
94
|
public function runWs()
|