Skip to content
This repository
Browse code

Merge branch 'release-0.6.0'

Conflicts:
	lib/Proem/Api/IO/Response/Http/Standard.php
	lib/Proem/Api/Proem.php
  • Loading branch information...
commit c0dd9e28ce6680f162ffd01f277cf6fbb35d7301 2 parents 930eac9 + e64f740
Tony R Quilkey authored August 04, 2012

Showing 24 changed files with 325 additions and 605 deletions. Show diff stats Hide diff stats

  1. 45  lib/Proem/Api/Bootstrap/Filter/Event/Dispatch.php
  2. 45  lib/Proem/Api/Bootstrap/Filter/Event/Request.php
  3. 45  lib/Proem/Api/Bootstrap/Filter/Event/Response.php
  4. 45  lib/Proem/Api/Bootstrap/Filter/Event/Route.php
  5. 16  lib/Proem/Api/Controller/Standard.php
  6. 34  lib/Proem/Api/Dispatch/Stage.php
  7. 40  lib/Proem/Api/IO/Response/Http/Standard.php
  8. 61  lib/Proem/Api/Proem.php
  9. 25  lib/Proem/Api/Routing/Route/Generic.php
  10. 10  lib/Proem/Api/Routing/Route/Standard.php
  11. 14  lib/Proem/Api/Routing/Route/StaticRoute.php
  12. 68  lib/Proem/Api/Signal/Event/Standard.php
  13. 41  lib/Proem/Api/Signal/Event/Template.php
  14. 111  lib/Proem/Api/Signal/Manager/Standard.php
  15. 10  lib/Proem/Api/Signal/Manager/Template.php
  16. 4  lib/Proem/Api/Util/Opt/Options.php
  17. 10  lib/Proem/Autoloader.php
  18. 5  tests/lib/Proem/Tests/Ext/Fixtures/MyApp/Module/Foo.php
  19. 18  tests/lib/Proem/Tests/Fixtures/Controller/Bar.php
  20. 5  tests/lib/Proem/Tests/Fixtures/Proem/Ext/Plugin/Foo.php
  21. 91  tests/lib/Proem/Tests/ProemTest.php
  22. 108  tests/lib/Proem/Tests/SignalTest.php
  23. 25  tests/lib/Proem/Tests/Util/OptTest.php
  24. 54  tests/lib/Proem/Tests/Util/Options/Fixtures/OptionsFixture3.php
45  lib/Proem/Api/Bootstrap/Filter/Event/Dispatch.php
@@ -56,18 +56,14 @@ class Dispatch extends Event
56 56
     public function preIn(Manager $assets)
57 57
     {
58 58
         if ($assets->provides('events', 'Proem\Signal\Manager\Template')) {
59  
-            $assets->get('events')->trigger([
60  
-                'name'      => 'proem.pre.in.dispatch',
61  
-                'params'    => [],
62  
-                'target'    => $this,
63  
-                'method'    => __FUNCTION__,
64  
-                'event'     => (new Bootstrap())->setServiceManager($assets),
65  
-                'callback'  => function($responseAsset) use ($assets) {
66  
-                    if ($responseAsset->provides('Proem\Dispatch\Template')) {
67  
-                        $assets->set('dispatch', $responseAsset);
  59
+            $assets->get('events')->trigger(
  60
+                (new Bootstrap('proem.pre.in.dispatch'))->setServiceManager($assets),
  61
+                function($response) use ($assets) {
  62
+                    if ($response->provides('Proem\Dispatch\Template')) {
  63
+                        $assets->set('dispatch', $response);
68 64
                     }
69  
-                },
70  
-            ]);
  65
+                }
  66
+            );
71 67
         }
72 68
     }
73 69
 
@@ -106,14 +102,7 @@ public function inBound(Manager $assets)
106 102
     public function postIn(Manager $assets)
107 103
     {
108 104
         if ($assets->provides('events', 'Proem\Signal\Manager\Template')) {
109  
-            $assets->get('events')->trigger([
110  
-                'name'      => 'proem.post.in.dispatch',
111  
-                'params'    => [],
112  
-                'target'    => $this,
113  
-                'method'    => __FUNCTION__,
114  
-                'event'     => (new Bootstrap())->setServiceManager($assets),
115  
-                'callback'  => function($responseAsset) {},
116  
-            ]);
  105
+            $assets->get('events')->trigger((new Bootstrap('proem.post.in.dispatch'))->setServiceManager($assets));
117 106
         }
118 107
 
119 108
         (new DispatchStage($assets));
@@ -128,14 +117,7 @@ public function postIn(Manager $assets)
128 117
     public function preOut(Manager $assets)
129 118
     {
130 119
         if ($assets->provides('events', 'Proem\Signal\Manager\Template')) {
131  
-            $assets->get('events')->trigger([
132  
-                'name'      => 'proem.pre.out.dispatch',
133  
-                'params'    => [],
134  
-                'target'    => $this,
135  
-                'method'    => __FUNCTION__,
136  
-                'event'     => (new Bootstrap())->setServiceManager($assets),
137  
-                'callback'  => function($responseAsset) {},
138  
-            ]);
  120
+            $assets->get('events')->trigger((new Bootstrap('proem.pre.out.dispatch'))->setServiceManager($assets));
139 121
         }
140 122
     }
141 123
 
@@ -158,14 +140,7 @@ public function outBound(Manager $assets)
158 140
     public function postOut(Manager $assets)
159 141
     {
160 142
         if ($assets->provides('events', 'Proem\Signal\Manager\Template')) {
161  
-            $assets->get('events')->trigger([
162  
-                'name'      => 'proem.post.out.dispatch',
163  
-                'params'    => [],
164  
-                'target'    => $this,
165  
-                'method'    => __FUNCTION__,
166  
-                'event'     => (new Bootstrap())->setServiceManager($assets),
167  
-                'callback'  => function($responseAsset) {},
168  
-            ]);
  143
+            $assets->get('events')->trigger((new Bootstrap('proem.post.out.dispatch'))->setServiceManager($assets));
169 144
         }
170 145
     }
171 146
 }
45  lib/Proem/Api/Bootstrap/Filter/Event/Request.php
@@ -54,18 +54,14 @@ class Request extends Event
54 54
     public function preIn(Manager $assets)
55 55
     {
56 56
         if ($assets->provides('events', 'Proem\Signal\Manager\Template')) {
57  
-            $assets->get('events')->trigger([
58  
-                'name'      => 'proem.pre.in.request',
59  
-                'params'    => [],
60  
-                'target'    => $this,
61  
-                'method'    => __FUNCTION__,
62  
-                'event'     => (new Bootstrap())->setServiceManager($assets),
63  
-                'callback'  => function($responseAsset) use ($assets) {
64  
-                    if ($responseAsset->provides('Proem\IO\Request\Template')) {
65  
-                        $assets->set('request', $responseAsset);
  57
+            $assets->get('events')->trigger(
  58
+                (new Bootstrap('proem.pre.in.request'))->setServiceManager($assets),
  59
+                function($response) use ($assets) {
  60
+                    if ($response->provides('Proem\IO\Request\Template')) {
  61
+                        $assets->set('request', $response);
66 62
                     }
67  
-                },
68  
-            ]);
  63
+                }
  64
+            );
69 65
         }
70 66
     }
71 67
 
@@ -100,14 +96,7 @@ public function inBound(Manager $assets)
100 96
     public function postIn(Manager $assets)
101 97
     {
102 98
         if ($assets->provides('events', 'Proem\Signal\Manager\Template')) {
103  
-            $assets->get('events')->trigger([
104  
-                'name'      => 'proem.post.in.request',
105  
-                'params'    => [],
106  
-                'target'    => $this,
107  
-                'method'    => __FUNCTION__,
108  
-                'event'     => (new Bootstrap())->setServiceManager($assets),
109  
-                'callback'  => function($responseAsset) {},
110  
-            ]);
  99
+            $assets->get('events')->trigger((new Bootstrap('proem.post.in.request'))->setServiceManager($assets));
111 100
         }
112 101
     }
113 102
 
@@ -120,14 +109,7 @@ public function postIn(Manager $assets)
120 109
     public function preOut(Manager $assets)
121 110
     {
122 111
         if ($assets->provides('events', 'Proem\Signal\Manager\Template')) {
123  
-            $assets->get('events')->trigger([
124  
-                'name'      => 'proem.pre.out.request',
125  
-                'params'    => [],
126  
-                'target'    => $this,
127  
-                'method'    => __FUNCTION__,
128  
-                'event'     => (new Bootstrap())->setServiceManager($assets),
129  
-                'callback'  => function($responseAsset) {},
130  
-            ]);
  112
+            $assets->get('events')->trigger((new Bootstrap('proem.pre.out.request'))->setServiceManager($assets));
131 113
         }
132 114
     }
133 115
 
@@ -150,14 +132,7 @@ public function outBound(Manager $assets)
150 132
     public function postOut(Manager $assets)
151 133
     {
152 134
         if ($assets->provides('events', 'Proem\Signal\Manager\Template')) {
153  
-            $assets->get('events')->trigger([
154  
-                'name'      => 'proem.post.out.request',
155  
-                'params'    => [],
156  
-                'target'    => $this,
157  
-                'method'    => __FUNCTION__,
158  
-                'event'     => (new Bootstrap())->setServiceManager($assets),
159  
-                'callback'  => function($responseAsset) {},
160  
-            ]);
  135
+            $assets->get('events')->trigger((new Bootstrap('proem.post.out.request'))->setServiceManager($assets));
161 136
         }
162 137
     }
163 138
 }
45  lib/Proem/Api/Bootstrap/Filter/Event/Response.php
@@ -55,18 +55,14 @@ class Response extends Event
55 55
     public function preIn(Manager $assets)
56 56
     {
57 57
         if ($assets->provides('events', 'Proem\Signal\Manager\Template')) {
58  
-            $assets->get('events')->trigger([
59  
-                'name'      => 'proem.pre.in.response',
60  
-                'params'    => [],
61  
-                'target'    => $this,
62  
-                'method'    => __FUNCTION__,
63  
-                'event'     => (new Bootstrap())->setServiceManager($assets),
64  
-                'callback'  => function($responseAsset) use ($assets) {
65  
-                    if ($responseAsset->provides('Proem\IO\Response\Template')) {
66  
-                        $assets->set('response', $responseAsset);
  58
+            $assets->get('events')->trigger(
  59
+                (new Bootstrap('proem.pre.in.response'))->setServiceManager($assets),
  60
+                function($response) use ($assets) {
  61
+                    if ($response->provides('Proem\IO\Response\Template')) {
  62
+                        $assets->set('response', $response);
67 63
                     }
68  
-                },
69  
-            ]);
  64
+                }
  65
+            );
70 66
         }
71 67
     }
72 68
 
@@ -101,14 +97,7 @@ public function inBound(Manager $assets)
101 97
     public function postIn(Manager $assets)
102 98
     {
103 99
         if ($assets->provides('events', 'Proem\Signal\Manager\Template')) {
104  
-            $assets->get('events')->trigger([
105  
-                'name'      => 'proem.post.in.response',
106  
-                'params'    => [],
107  
-                'target'    => $this,
108  
-                'method'    => __FUNCTION__,
109  
-                'event'     => (new Bootstrap())->setServiceManager($assets),
110  
-                'callback'  => function($responseAsset) {},
111  
-            ]);
  100
+            $assets->get('events')->trigger((new Bootstrap('proem.post.in.response'))->setServiceManager($assets));
112 101
         }
113 102
     }
114 103
 
@@ -121,14 +110,7 @@ public function postIn(Manager $assets)
121 110
     public function preOut(Manager $assets)
122 111
     {
123 112
         if ($assets->provides('events', 'Proem\Signal\Manager\Template')) {
124  
-            $assets->get('events')->trigger([
125  
-                'name'      => 'proem.pre.out.response',
126  
-                'params'    => [],
127  
-                'target'    => $this,
128  
-                'method'    => __FUNCTION__,
129  
-                'event'     => (new Bootstrap())->setServiceManager($assets),
130  
-                'callback'  => function($responseAsset) {},
131  
-            ]);
  113
+            $assets->get('events')->trigger((new Bootstrap('proem.pre.out.response'))->setServiceManager($assets));
132 114
         }
133 115
     }
134 116
 
@@ -158,14 +140,7 @@ public function outBound(Manager $assets)
158 140
     public function postOut(Manager $assets)
159 141
     {
160 142
         if ($assets->provides('events', 'Proem\Signal\Manager\Template')) {
161  
-            $assets->get('events')->trigger([
162  
-                'name'      => 'proem.post.out.response',
163  
-                'params'    => [],
164  
-                'target'    => $this,
165  
-                'method'    => __FUNCTION__,
166  
-                'event'     => (new Bootstrap())->setServiceManager($assets),
167  
-                'callback'  => function($responseAsset) {},
168  
-            ]);
  143
+            $assets->get('events')->trigger((new Bootstrap('proem.post.out.response'))->setServiceManager($assets));
169 144
         }
170 145
     }
171 146
 }
45  lib/Proem/Api/Bootstrap/Filter/Event/Route.php
@@ -56,18 +56,14 @@ class Route extends Event
56 56
     public function preIn(Manager $assets)
57 57
     {
58 58
         if ($assets->provides('events', 'Proem\Signal\Manager\Template')) {
59  
-            $assets->get('events')->trigger([
60  
-                'name'      => 'proem.pre.in.router',
61  
-                'params'    => [],
62  
-                'target'    => $this,
63  
-                'method'    => __FUNCTION__,
64  
-                'event'     => (new Bootstrap())->setServiceManager($assets),
65  
-                'callback'  => function($responseAsset) use ($assets) {
66  
-                    if ($responseAsset->provides('Proem\Routing\Router\Template')) {
67  
-                        $assets->set('router', $responseAsset);
  59
+            $assets->get('events')->trigger(
  60
+                (new Bootstrap('proem.pre.in.router'))->setServiceManager($assets),
  61
+                function($response) use ($assets) {
  62
+                    if ($response->provides('Proem\Routing\Router\Template')) {
  63
+                        $assets->set('router', $response);
68 64
                     }
69  
-                },
70  
-            ]);
  65
+                }
  66
+            );
71 67
         }
72 68
     }
73 69
 
@@ -155,14 +151,7 @@ public function inBound(Manager $assets)
155 151
     public function postIn(Manager $assets)
156 152
     {
157 153
         if ($assets->provides('events', 'Proem\Signal\Manager\Template')) {
158  
-            $assets->get('events')->trigger([
159  
-                'name'      => 'proem.post.in.router',
160  
-                'params'    => [],
161  
-                'target'    => $this,
162  
-                'method'    => __FUNCTION__,
163  
-                'event'     => (new Bootstrap())->setServiceManager($assets),
164  
-                'callback'  => function($responseAsset) {},
165  
-            ]);
  154
+            $assets->get('events')->trigger((new Bootstrap('proem.post.in.router'))->setServiceManager($assets));
166 155
         }
167 156
     }
168 157
 
@@ -175,14 +164,7 @@ public function postIn(Manager $assets)
175 164
     public function preOut(Manager $assets)
176 165
     {
177 166
         if ($assets->provides('events', 'Proem\Signal\Manager\Template')) {
178  
-            $assets->get('events')->trigger([
179  
-                'name'      => 'proem.pre.out.router',
180  
-                'params'    => [],
181  
-                'target'    => $this,
182  
-                'method'    => __FUNCTION__,
183  
-                'event'     => (new Bootstrap())->setServiceManager($assets),
184  
-                'callback'  => function($responseAsset) {},
185  
-            ]);
  167
+            $assets->get('events')->trigger((new Bootstrap('proem.pre.out.router'))->setServiceManager($assets));
186 168
         }
187 169
     }
188 170
 
@@ -205,14 +187,7 @@ public function outBound(Manager $assets)
205 187
     public function postOut(Manager $assets)
206 188
     {
207 189
         if ($assets->provides('events', 'Proem\Signal\Manager\Template')) {
208  
-            $assets->get('events')->trigger([
209  
-                'name'      => 'proem.post.out.router',
210  
-                'params'    => [],
211  
-                'target'    => $this,
212  
-                'method'    => __FUNCTION__,
213  
-                'event'     => (new Bootstrap())->setServiceManager($assets),
214  
-                'callback'  => function($responseAsset) {},
215  
-            ]);
  190
+            $assets->get('events')->trigger((new Bootstrap('proem.post.out.router'))->setServiceManager($assets));
216 191
         }
217 192
     }
218 193
 }
16  lib/Proem/Api/Controller/Standard.php
@@ -73,26 +73,14 @@ public function dispatch($action) {
73 73
         $action = strtolower($action);
74 74
 
75 75
         if ($this->assets->provides('events', '\Proem\Signal\Manager\Template')) {
76  
-            $this->assets->get('events')->trigger([
77  
-                'name'      => 'proem.pre.action.' . $action,
78  
-                'params'    => [],
79  
-                'target'    => $this,
80  
-                'method'    => __FUNCTION__,
81  
-                'event'     => (new Bootstrap())->setServiceManager($this->assets)
82  
-            ]);
  76
+            $this->assets->get('events')->trigger((new Bootstrap('proem.pre.action.' . $action))->setServiceManager($this->assets));
83 77
         }
84 78
 
85 79
         $method = $action . 'Action';
86 80
         $result = $this->{$method}();
87 81
 
88 82
         if ($this->assets->provides('events', '\Proem\Signal\Manager\Template')) {
89  
-            $this->assets->get('events')->trigger([
90  
-                'name'      => 'proem.post.action.' . $action,
91  
-                'params'    => [],
92  
-                'target'    => $this,
93  
-                'method'    => __FUNCTION__,
94  
-                'event'     => (new Bootstrap())->setServiceManager($this->assets)
95  
-            ]);
  83
+            $this->assets->get('events')->trigger((new Bootstrap('proem.post.action.' . $action))->setServiceManager($this->assets));
96 84
         }
97 85
 
98 86
         return $result;
34  lib/Proem/Api/Dispatch/Stage.php
@@ -83,10 +83,7 @@ public function __construct(Manager $assets)
83 83
     protected function attachRouteMatchListener()
84 84
     {
85 85
         if ($this->assets->has('events')) {
86  
-            $this->assets->get('events')->attach([
87  
-                'name'      => 'proem.route.match',
88  
-                'callback'  => [$this, 'testRoute']
89  
-            ]);
  86
+            $this->assets->get('events')->attach('proem.route.match', [$this, 'testRoute']);
90 87
         }
91 88
     }
92 89
 
@@ -96,10 +93,7 @@ protected function attachRouteMatchListener()
96 93
     protected function attachRouteExhaustedListener()
97 94
     {
98 95
         if ($this->assets->has('events')) {
99  
-            $this->assets->get('events')->attach([
100  
-                'name'      => 'proem.route.exhausted',
101  
-                'callback'  => [$this, 'routesExhausted']
102  
-            ]);
  96
+            $this->assets->get('events')->attach('proem.route.exhausted', [$this, 'routesExhausted']);
103 97
         }
104 98
     }
105 99
 
@@ -109,10 +103,7 @@ protected function attachRouteExhaustedListener()
109 103
     protected function attachRouteDispatchListener()
110 104
     {
111 105
         if ($this->assets->has('events')) {
112  
-            $this->assets->get('events')->attach([
113  
-                'name'      => 'proem.route.dispatch',
114  
-                'callback'  => [$this, 'dispatch']
115  
-            ]);
  106
+            $this->assets->get('events')->attach('proem.route.dispatch', [$this, 'dispatch']);
116 107
         }
117 108
     }
118 109
 
@@ -138,29 +129,22 @@ protected function processRoutes()
138 129
             $router     = $assets->get('router');
139 130
             $dispatched = false;
140 131
             while ($payload = $router->route()) {
141  
-                $assets->get('events')->trigger([
142  
-                    'name'      => 'proem.route.match',
143  
-                    'event'     => (new RouteMatch())->setPayload($payload),
144  
-                    'callback'  => function($e) use (&$dispatched, &$assets) {
  132
+                $assets->get('events')->trigger(
  133
+                    (new RouteMatch('proem.route.match'))->setPayload($payload),
  134
+                    function($e) use (&$dispatched, &$assets) {
145 135
                         if ($e) {
146 136
                             $dispatched = true;
147  
-                            $assets->get('events')->trigger([
148  
-                                'name' => 'proem.route.dispatch',
149  
-                                'event' => (new RouteDispatch)
150  
-                            ]);
  137
+                            $assets->get('events')->trigger(new RouteDispatch('proem.route.dispatch'));
151 138
                         }
152 139
                     }
153  
-                ]);
  140
+                );
154 141
                 if ($dispatched) {
155 142
                     break;
156 143
                 }
157 144
             }
158 145
 
159 146
             if (!$dispatched) {
160  
-                $assets->get('events')->trigger([
161  
-                    'name' => 'proem.route.exhausted',
162  
-                    'event' => (new RouteExhausted)
163  
-                ]);
  147
+                $assets->get('events')->trigger(new RouteExhausted('proem.route.exhausted'));
164 148
             }
165 149
         }
166 150
     }
40  lib/Proem/Api/IO/Response/Http/Standard.php
@@ -43,7 +43,7 @@ class Standard implements Template
43 43
      *
44 44
      * @var string
45 45
      */
46  
-    protected $httpVersion = '1.1';
  46
+    protected $httpVersion = '1.0';
47 47
 
48 48
     /**
49 49
      * Store the HTTP Status code
@@ -74,13 +74,6 @@ class Standard implements Template
74 74
     protected $length;
75 75
 
76 76
     /**
77  
-     * Store a flag indicating wether or not to send the closed header.
78  
-     *
79  
-     * @var bool
80  
-     */
81  
-    protected $sendClosed;
82  
-
83  
-    /**
84 77
      * Hash of status code -> message
85 78
      *
86 79
      * @var array
@@ -273,16 +266,6 @@ public function getBody()
273 266
     }
274 267
 
275 268
     /**
276  
-     * Send a connection closed header when output is sent.
277  
-     *
278  
-     * Under certain circumstances this can improve performance.
279  
-     */
280  
-    public function sendClosedHeader()
281  
-    {
282  
-        $this->sendClosed = true;
283  
-    }
284  
-
285  
-    /**
286 269
      * Retrieve the content length.
287 270
      *
288 271
      * @return int
@@ -294,13 +277,19 @@ public function getContentLength()
294 277
 
295 278
     /**
296 279
      * Send the HTTP headers to the client.
  280
+     *
  281
+     * @param bool $include_content_length Optionaly disable the Content-Length header.
297 282
      */
298  
-    public function sendHeaders()
  283
+    public function sendHeaders($include_content_length = true)
299 284
     {
300 285
         if (headers_sent()) {
301 286
             return;
302 287
         }
303 288
 
  289
+        if ($include_content_length) {
  290
+            $this->headers->set('Content-Length', $this->length);
  291
+        }
  292
+
304 293
         if (in_array($this->httpStatus, [204, 304])) {
305 294
             $this->headers->remove('Content-Type');
306 295
         }
@@ -310,23 +299,18 @@ public function sendHeaders()
310 299
         foreach ($this->headers->all() as $index => $value) {
311 300
             header(sprintf('%s: %s', $index, $value));
312 301
         }
313  
-
314  
-        if ($this->sendClosed) {
315  
-            $this->headers->set('Content-Length', $this->length);
316  
-            header('Connection: close');
317  
-        }
318  
-
319  
-        flush();
320 302
     }
321 303
 
322 304
     /**
323 305
      * Send the response to the client.
324 306
      *
325 307
      * This method will first send any headers and then the request body.
  308
+     *
  309
+     * @param bool $include_content_length Optionaly disable the Content-Length header.
326 310
      */
327  
-    public function send()
  311
+    public function send($include_content_length = true)
328 312
     {
329  
-        $this->sendHeaders();
  313
+        $this->sendHeaders($include_content_length);
330 314
 
331 315
         if (( $this->httpStatus < 100 || $this->httpStatus >= 200 ) && $this->httpStatus != 204 && $this->httpStatus != 304) {
332 316
             echo $this->body;
61  lib/Proem/Api/Proem.php
@@ -76,6 +76,19 @@ class Proem
76 76
     protected $serviceManager;
77 77
 
78 78
     /**
  79
+     * Setup bootstraping
  80
+     */
  81
+    public function __construct()
  82
+    {
  83
+        $this->events = new Asset;
  84
+        $this->events->set('Proem\Signal\Manager\Template', $this->events->single(function($asset) {
  85
+            return new SignalManager;
  86
+        }));
  87
+
  88
+        $this->serviceManager = new ServiceManager;
  89
+    }
  90
+
  91
+    /**
79 92
      * Register an extension
80 93
      *
81 94
      * An extension is just a lower level interface that modules and plugins implement
@@ -87,38 +100,25 @@ class Proem
87 100
      */
88 101
     protected function attachExtension(Extension $extension, $event = 'proem.init', $priority = 0)
89 102
     {
90  
-        $this->attachEventListener([
91  
-            'name'      => $event,
92  
-            'priority'  => $priority,
93  
-            'callback'  => function($e) use ($extension) {
94  
-                $extension->init($e->getServiceManager(), $e->getEnvironment());
95  
-            }
96  
-        ]);
97  
-        return $this;
98  
-    }
99  
-
100  
-    /**
101  
-     * Setup bootstraping
102  
-     */
103  
-    public function __construct()
104  
-    {
105  
-        $this->events = new Asset;
106  
-        $this->events->set('Proem\Signal\Manager\Template', $this->events->single(function($asset) {
107  
-            return new SignalManager;
108  
-        }));
  103
+        $this->attachEventListener($event, function($e) use ($extension) {
  104
+            $extension->init($e->getServiceManager(), $e->getEnvironment());
  105
+        }, $priority);
109 106
 
110  
-        $this->serviceManager = new ServiceManager;
  107
+        return $this;
111 108
     }
112 109
 
113 110
     /**
114 111
      * Attach a listener to the signal event manager
115 112
      *
116  
-     * @param array $listener
  113
+     * @param string $name The name of the event.
  114
+     * @param callable $callback The callback that will be executed when the event is triggered.
  115
+     * @param int $priority The priority that this listenever will have above other listeners attached to this same event.
  116
+     *
117 117
      * @return Proem\Api\Proem
118 118
      */
119  
-    public function attachEventListener(array $listener)
  119
+    public function attachEventListener($name, Callable $callback, $priority = 0)
120 120
     {
121  
-        $this->events->get()->attach($listener);
  121
+        $this->events->get()->attach($name, $callback, $priority);
122 122
         return $this;
123 123
     }
124 124
 
@@ -131,7 +131,7 @@ public function attachEventListener(array $listener)
131 131
     public function attachEventListeners(array $listeners)
132 132
     {
133 133
         foreach ($listeners as $listener) {
134  
-            $this->attachEventListener($listener);
  134
+            $this->attachEventListener($listener['name'], $listener['callback']);
135 135
         }
136 136
         return $this;
137 137
     }
@@ -173,15 +173,14 @@ public function init($environment = null)
173 173
     {
174 174
         $this->serviceManager->set('events', $this->events);
175 175
 
176  
-        $this->events->get()->trigger([
177  
-            'name'  => 'proem.init',
178  
-            'event' => (new Bootstrap)->setServiceManager($this->serviceManager)->setEnvironment($environment),
179  
-            'callback'  => function($e) {
180  
-                if ($e instanceof Proem\Filter\Manager\Template) {
181  
-                    $this->filterManager = $e;
  176
+        $this->events->get()->trigger(
  177
+            (new Bootstrap('proem.init'))->setServiceManager($this->serviceManager)->setEnvironment($environment),
  178
+            function($response) {
  179
+                if ($response instanceof Proem\Filter\Manager\Template) {
  180
+                    $this->filterManager = $response;
182 181
                 }
183 182
             }
184  
-        ]);
  183
+        );
185 184
 
186 185
         if ($this->filterManager === null) {
187 186
             $this->filterManager = new FilterManager;
25  lib/Proem/Api/Routing/Route/Generic.php
@@ -31,8 +31,6 @@
31 31
 namespace Proem\Api\Routing\Route;
32 32
 
33 33
 use Proem\Routing\Route\Payload,
34  
-    Proem\Util\Opt\Options,
35  
-    Proem\Util\Opt\Option,
36 34
     Proem\Util\ArrayHelper,
37 35
     Proem\Util\Process\Callback,
38 36
     Proem\IO\Request\Template as Request,
@@ -44,11 +42,6 @@
44 42
 abstract class Generic implements Template
45 43
 {
46 44
     /**
47  
-     * @uses Proem\Api\Util\Opt\Options
48  
-     */
49  
-    use Options;
50  
-
51  
-    /**
52 45
      * @uses Proem\Api\Util\ArrayHelper
53 46
      */
54 47
     use ArrayHelper;
@@ -84,19 +77,15 @@
84 77
     /**
85 78
      * Instantiate this route
86 79
      *
87  
-     * @param array $options An array of Proem\Api\Util\Opt\Option objects
  80
+     * $options = ['rule', 'targets', 'filters', 'method', 'callback'];
  81
+     *
  82
+     * @param array $options
88 83
      */
89 84
     public function __construct(array $options)
90 85
     {
91  
-        $this->options = $this->setOptions([
92  
-            'rule'      => (new Option)->type('string')->required(),
93  
-            'targets'   => (new Option([]))->type('array'),
94  
-            'filters'   => (new Option([]))->type('array'),
95  
-            'method'    => (new Option(null))->type('string'),
96  
-            'callback'  => (new Option)->type('callable')
97  
-        ], $options);
98  
-
99  
-        if (is_callable($this->options->callback)) {
  86
+        $this->options = $options;
  87
+
  88
+        if (isset($this->options['callback']) && is_callable($this->options['callback'])) {
100 89
             $this->hasCallback = true;
101 90
         }
102 91
 
@@ -154,7 +143,7 @@ public function getPayload()
154 143
      */
155 144
     public function call(Request $request)
156 145
     {
157  
-        (new Callback($this->options->callback, $request))->call();
  146
+        (new Callback($this->options['callback'], $request))->call();
158 147
     }
159 148
 
160 149
     /**
10  lib/Proem/Api/Routing/Route/Standard.php
@@ -109,14 +109,14 @@ public function __construct(array $options) {
109 109
      */
110 110
     public function process(Request $request)
111 111
     {
112  
-        if (!$this->options->rule) {
  112
+        if (!isset($this->options['rule'])) {
113 113
             return false;
114 114
         }
115 115
 
116  
-        $rule               = $this->options->rule;
117  
-        $target             = $this->options->targets;
118  
-        $custom_filters     = $this->options->filters;
119  
-        $method             = $this->options->method ?: 'GET';
  116
+        $rule               = $this->options['rule'];
  117
+        $target             = isset($this->options['targets']) ? $this->options['targets'] : [];
  118
+        $custom_filters     = isset($this->options['filters']) ? $this->options['filters'] : [];
  119
+        $method             = isset($this->options['method']) ? $this->options['method'] : 'GET';
120 120
 
121 121
         $default_tokens     = $this->default_tokens;
122 122
         $default_filters    = $this->default_filters;
14  lib/Proem/Api/Routing/Route/StaticRoute.php
@@ -41,18 +41,20 @@ class StaticRoute extends Generic
41 41
 {
42 42
     public function process(Request $request)
43 43
     {
44  
-        if (!$this->options->rule) {
  44
+        if (!isset($this->options['rule'])) {
45 45
             return false;
46 46
         }
47 47
 
48  
-        if (!isset($this->options->targets['module']) || !isset($this->options->targets['controller']) || !isset($this->options->targets['action'])) {
  48
+        $method = isset($this->options['method']) ? $this->options['method'] : 'GET';
  49
+
  50
+        if (!isset($this->options['targets']) || !isset($this->options['targets']['module']) || !isset($this->options['targets']['controller']) || !isset($this->options['targets']['action'])) {
49 51
             return false;
50 52
         }
51 53
 
52  
-        if ($request->getRequestUri() == $this->options->rule && $request->getMethod()  == ($this->options->method ?: 'GET')) {
53  
-            $this->getPayload()->set('module', $this->options->targets['module']);
54  
-            $this->getPayload()->set('controller', $this->options->targets['controller']);
55  
-            $this->getPayload()->set('action', $this->options->targets['action']);
  54
+        if ($request->getRequestUri() == $this->options['rule'] && $request->getMethod() == $method) {
  55
+            $this->getPayload()->set('module', $this->options['targets']['module']);
  56
+            $this->getPayload()->set('controller', $this->options['targets']['controller']);
  57
+            $this->getPayload()->set('action', $this->options['targets']['action']);
56 58
 
57 59
             $this->setMatch();
58 60
             $this->getPayload()->set('request', $request);
68  lib/Proem/Api/Signal/Event/Standard.php
@@ -40,6 +40,8 @@
40 40
 class Standard implements Template
41 41
 {
42 42
     /**
  43
+     * TODO: This can likely be removed.
  44
+     *
43 45
      * @use Proem\Api\Util\Opt\Options
44 46
      */
45 47
     use Options;
@@ -59,18 +61,12 @@ class Standard implements Template
59 61
     protected $name = null;
60 62
 
61 63
     /**
62  
-     * Store target
63  
-     *
64  
-     * @var object $target
65  
-     */
66  
-    protected $target = null;
67  
-
68  
-    /**
69  
-     * Store the method
70  
-     *
71  
-     * @var string
  64
+     * Instantiate the event and set it's name.
72 65
      */
73  
-    protected $method = null;
  66
+    public function __construct($name)
  67
+    {
  68
+        $this->name = $name;
  69
+    }
74 70
 
75 71
     /**
76 72
      * Set params
@@ -118,54 +114,4 @@ public function getName()
118 114
         return $this->name;
119 115
     }
120 116
 
121  
-    /**
122  
-     * Set the target.
123  
-     *
124  
-     * The target should be an instance of whatever object
125  
-     * this event was triggered from.
126  
-     *
127  
-     * @param object $target
128  
-     * @return Proem\Api\Signal\Event\Template
129  
-     */
130  
-    public function setTarget($target)
131  
-    {
132  
-        $this->target = $target;
133  
-        return $this;
134  
-    }
135  
-
136  
-    /**
137  
-     * Retrieve target.
138  
-     *
139  
-     * @return object
140  
-     */
141  
-    public function getTarget()
142  
-    {
143  
-        return $this->target;
144  
-    }
145  
-
146  
-    /**
147  
-     * Set the method.
148  
-     *
149  
-     * The method should be a string representing the name of
150  
-     * the method which has triggered this event.
151  
-     *
152  
-     * @param string $method
153  
-     * @return Proem\Api\Signal\Event\Template
154  
-     */
155  
-    public function setMethod($method)
156  
-    {
157  
-        $this->method = $method;
158  
-        return $this;
159  
-    }
160  
-
161  
-    /**
162  
-     * Retrieve method
163  
-     *
164  
-     * @return object
165  
-     */
166  
-    public function getMethod()
167  
-    {
168  
-        return $this->method;
169  
-    }
170  
-
171 117
 }
41  lib/Proem/Api/Signal/Event/Template.php
@@ -39,6 +39,11 @@
39 39
 interface Template
40 40
 {
41 41
     /**
  42
+     * Instantiate the Event and set it's name.
  43
+     */
  44
+    public function __construct($name);
  45
+
  46
+    /**
42 47
      * Set params
43 48
      *
44 49
      * @param array $params
@@ -70,40 +75,4 @@ public function setName($name);
70 75
      */
71 76
     public function getName();
72 77
 
73  
-    /**
74  
-     * Set the target.
75  
-     *
76  
-     * The target should be an instance of whatever object
77  
-     * this event was triggered from.
78  
-     *
79  
-     * @param object $target
80  
-     * @return Proem\Api\Signal\Event\Template
81  
-     */
82  
-    public function setTarget($target);
83  
-
84  
-    /**
85  
-     * Retrieve target.
86  
-     *
87  
-     * @return object
88  
-     */
89  
-    public function getTarget();
90  
-
91  
-    /**
92  
-     * Set the method.
93  
-     *
94  
-     * The method should be a string representing the name of
95  
-     * the method which has triggered this event.
96  
-     *
97  
-     * @param string $method
98  
-     * @return Proem\Api\Signal\Event\Template
99  
-     */
100  
-    public function setMethod($method);
101  
-
102  
-    /**
103  
-     * Retrieve method
104  
-     *
105  
-     * @return object
106  
-     */
107  
-    public function getMethod();
108  
-
109 78
 }
111  lib/Proem/Api/Signal/Manager/Standard.php
@@ -32,8 +32,6 @@
32 32
 
33 33
 use Proem\Util\Storage\Queue,
34 34
     Proem\Util\Process\Callback,
35  
-    Proem\Util\Opt\Options,
36  
-    Proem\Util\Opt\Option,
37 35
     Proem\Signal\Event\Standard as Event,
38 36
     Proem\Signal\Manager\Template;
39 37
 
@@ -46,11 +44,6 @@
46 44
 class Standard implements Template
47 45
 {
48 46
     /**
49  
-     * @use Proem\Api\Util\Opt\Options
50  
-     */
51  
-    use Options;
52  
-
53  
-    /**
54 47
      * Wildcard used when listening for all events
55 48
      */
56 49
     const WILDCARD = '*';
@@ -110,58 +103,47 @@ public function remove($name)
110 103
      * Be aware that attaching a listener to the same event multiple times will trigger
111 104
      * that listener multiple times. This includes using the wildcard.
112 105
      *
113  
-     * <code>
114  
-     *   $ops = $this->setOptions([
115  
-     *       'name'      => (new Option())->required(),                     // The name of the event to listen to
116  
-     *       'callback'  => (new Option())->required()->type('callable'),   // The Callable that will be executed when the event occurs
117  
-     *       'priority'  => 0                                               // The priority at which this listner will be executed
118  
-     *   ], $options);
119  
-     * </code>
  106
+     * @param string|array The name(s) of the event(s) to listen for.
  107
+     * @param callable $callback The callback to execute when the event is triggered.
  108
+     * @param int $priority The priority at which to execute this listener.
120 109
      *
121  
-     * @param array $options An array of Proem\Util\Opt\Options objects
122 110
      * @return Proem\Api\Signal\Manager\Template
123 111
      */
124  
-    public function attach(array $options)
  112
+    public function attach($name, Callable $callback, $priority = 0)
125 113
     {
126  
-        $ops = $this->setOptions([
127  
-            'name'      => (new Option())->required(),
128  
-            'callback'  => (new Option())->required()->type('callable'),
129  
-            'priority'  => 0
130  
-        ], $options);
131  
-
132 114
         $key = md5(microtime());
133  
-        $this->callbacks[$key] = $ops->callback;
  115
+        $this->callbacks[$key] = $callback;
134 116
 
135  
-        if (is_array($ops->name)) {
136  
-            foreach ($ops->name as $event) {
  117
+        if (is_array($name)) {
  118
+            foreach ($name as $event) {
137 119
                 if (isset($this->queues[$event])) {
138 120
                     if ($event == self::WILDCARD) {
139  
-                        $this->queues[self::WILDCARD][] = [$key, $ops->priority];
  121
+                        $this->queues[self::WILDCARD][] = [$key, $priority];
140 122
                     } else {
141  
-                        $this->queues[$event]->insert($key, $ops->priority);
  123
+                        $this->queues[$event]->insert($key, $priority);
142 124
                     }
143 125
                 } else {
144 126
                     if ($event == self::WILDCARD) {
145  
-                        $this->queues[self::WILDCARD][] = [$key, $ops->priority];
  127
+                        $this->queues[self::WILDCARD][] = [$key, $priority];
146 128
                     } else {
147 129
                         $this->queues[$event] = new Queue;
148  
-                        $this->queues[$event]->insert($key, $ops->priority);
  130
+                        $this->queues[$event]->insert($key, $priority);
149 131
                     }
150 132
                 }
151 133
             }
152 134
         } else {
153  
-            if (isset($this->queues[$ops->name])) {
154  
-                if ($ops->name == self::WILDCARD) {
155  
-                    $this->queues[self::WILDCARD][] = [$key, $ops->priority];
  135
+            if (isset($this->queues[$name])) {
  136
+                if ($name == self::WILDCARD) {
  137
+                    $this->queues[self::WILDCARD][] = [$key, $priority];
156 138
                 } else {
157  
-                    $this->queues[$ops->name]->insert($key, $ops->priority);
  139
+                    $this->queues[$name]->insert($key, $priority);
158 140
                 }
159 141
             } else {
160  
-                if ($ops->name == self::WILDCARD) {
161  
-                    $this->queues[self::WILDCARD][] = [$key, $ops->priority];
  142
+                if ($name == self::WILDCARD) {
  143
+                    $this->queues[self::WILDCARD][] = [$key, $priority];
162 144
                 } else {
163  
-                    $this->queues[$ops->name] = new Queue;
164  
-                    $this->queues[$ops->name]->insert($key, $ops->priority);
  145
+                    $this->queues[$name] = new Queue;
  146
+                    $this->queues[$name]->insert($key, $priority);
165 147
                 }
166 148
             }
167 149
         }
@@ -172,55 +154,32 @@ public function attach(array $options)
172 154
     /**
173 155
      * Trigger the execution of all event listeners attached to a named event.
174 156
      *
175  
-     * <code>
176  
-     *   $ops = $this->setOptions([
177  
-     *       'name'      => (new Option())->required(),
178  
-     *       'params'    => (new Option())->type('array'),
179  
-     *       'callback'  => (new Option())->type('callable'),
180  
-     *       'target'    => (new Option())->type('object'),
181  
-     *       'method'    => (new Option())->type('string'),
182  
-     *       'event'     => (new Option(new Event))->object('\Proem\Signal\Event\Template')
183  
-     *   ], $options);
184  
-     * </code>
  157
+     * @param Proem\Signal\Event\Standard $event The event being triggered.
  158
+     * @param callable $callback A callback that can be used to respond to any response sent back from a listener.
185 159
      *
186  
-     * @param array $options An array of Proem\Util\Opt\Options objects
187 160
      * @return Proem\Api\Signal\Manager\Template
188 161
      */
189  
-    public function trigger(array $options)
  162
+    public function trigger(Event $event, Callable $callback = null)
190 163
     {
191  
-        $ops = $this->setOptions([
192  
-            'name'      => (new Option())->required(),
193  
-            'params'    => (new Option())->type('array'),
194  
-            'callback'  => (new Option())->type('callable'),
195  
-            'target'    => (new Option())->type('object'),
196  
-            'method'    => (new Option())->type('string'),
197  
-            'event'     => (new Option(new Event))->object('\Proem\Signal\Event\Template')
198  
-        ], $options);
199  
-
200  
-        if (isset($this->queues[$ops->name]) || isset($this->queues[self::WILDCARD])) {
  164
+        $name = $event->getName();
  165
+        if (isset($name) || isset($this->queues[self::WILDCARD])) {
201 166
             if (isset($this->queues[self::WILDCARD])) {
202 167
                 foreach ($this->queues[self::WILDCARD] as $listener) {
203  
-                    if (isset($this->queues[$ops->name])) {
204  
-                        $this->queues[$ops->name]->insert($listener[0], $listener[1]);
  168
+                    if (isset($this->queues[$name])) {
  169
+                        $this->queues[$name]->insert($listener[0], $listener[1]);
205 170
                     } else {
206  
-                        $this->queues[$ops->name] = new Queue;
207  
-                        $this->queues[$ops->name]->insert($listener[0], $listener[1]);
  171
+                        $this->queues[$name] = new Queue;
  172
+                        $this->queues[$name]->insert($listener[0], $listener[1]);
208 173
                     }
209 174
                 }
210 175
             }
211  
-            foreach ($this->queues[$ops->name] as $key) {
212  
-                $event = $ops->event;
213  
-                if ($event instanceof \Proem\Signal\Event\Template) {
214  
-                    if ($ops->has('params')) {
215  
-                        $event->setParams($ops->params);
216  
-                    }
217  
-                }
218  
-                $event->setName($ops->name);
219  
-                $event->setTarget($ops->target);
220  
-                $event->setMethod($ops->method);
221  
-                if ($return = (new Callback($this->callbacks[$key], $event))->call()) {
222  
-                    if ($ops->has('callback')) {
223  
-                        (new Callback($ops->callback, $return))->call();
  176
+
  177
+            if (isset($this->queues[$name])) {
  178
+                foreach ($this->queues[$name] as $key) {
  179
+                    if ($return = (new Callback($this->callbacks[$key], $event))->call()) {
  180
+                        if ($callback !== null) {
  181
+                            (new Callback($callback, $return))->call();
  182
+                        }
224 183
                     }
225 184
                 }
226 185
             }
10  lib/Proem/Api/Signal/Manager/Template.php
@@ -30,6 +30,8 @@
30 30
  */
31 31
 namespace Proem\Api\Signal\Manager;
32 32
 
  33
+use Proem\Signal\Event\Standard as Event;
  34
+
33 35
 /**
34 36
  * Interface that all signal managers must implement.
35 37
  */
@@ -46,10 +48,12 @@ public function remove($name);
46 48
     /**
47 49
      * Register a listener attached to a particular named event.
48 50
      *
49  
-     * @param array $options An array of Proem\Api\Util\Opt\Options objects
  51
+     * @param string $name The name of the event to attach to.
  52
+     * @param callable $callback The callback that will be executed when the event is triggered.
  53
+     *
50 54
      * @return Proem\Api\Signal\Manager\Template
51 55
      */
52  
-    public function attach(array $options);
  56
+    public function attach($name, Callable $callback);
53 57
 
54 58
     /**
55 59
      * Trigger the execution of all event listeners attached to a named event.
@@ -57,6 +61,6 @@ public function attach(array $options);
57 61
      * @param array $options An array of Proem\Api\Util\Opt\Options objects
58 62
      * @return Proem\Api\Signal\Manager\Template
59 63
      */
60  
-    public function trigger(array $options);
  64
+    public function trigger(Event $event, Callable $callback = null);
61 65
 
62 66
 }
4  lib/Proem/Api/Util/Opt/Options.php
@@ -52,7 +52,7 @@ public function setOptions($defaults, $options)
52 52
             if (isset($defaults[$key]) && ($defaults[$key] instanceof Option)) {
53 53
                 $defaults[$key]->setValue($value);
54 54
             } else {
55  
-                $defaults[$key] = new Option($value);
  55
+                $defaults[$key] = $value;
56 56
             }
57 57
         }
58 58
 
@@ -69,6 +69,8 @@ public function setOptions($defaults, $options)
69 69
                 } catch (\RuntimeException $e) {
70 70
                     throw new \RuntimeException($e->getMessage());
71 71
                 }
  72
+            } else {
  73
+                $payload->set($key, $value);
72 74
             }
73 75
         }
74 76
         return $payload;
10  lib/Proem/Autoloader.php
@@ -58,11 +58,13 @@ class Autoloader
58 58
     protected $apcEnabled = false;
59 59
 
60 60
     /**
61  
-     * Set enable APC caching.
  61
+     * Instantiate our Autoloader and check for APC.
62 62
      */
63  
-    public function enableAPC()
  63
+    public function __construct()
64 64
     {
65  
-        $this->apcEnabled = true;
  65
+        if (extension_loaded('apc')) {