File tree 2 files changed +9
-5
lines changed
2 files changed +9
-5
lines changed Original file line number Diff line number Diff line change 4
4
5
5
use Symfony \Component \EventDispatcher \Event ;
6
6
7
+ // http://symfony.com/doc/current/components/event_dispatcher/generic_event.html
7
8
class ProxyEvent extends Event implements \ArrayAccess {
8
9
9
10
private $ data ;
@@ -13,14 +14,14 @@ public function __construct($data = array()){
13
14
}
14
15
15
16
public function offsetSet ($ offset , $ value ){
16
-
17
+
17
18
if (is_null ($ offset )) {
18
19
$ this ->data [] = $ value ;
19
20
} else {
20
21
$ this ->data [$ offset ] = $ value ;
21
22
}
22
- }
23
-
23
+ }
24
+
24
25
public function offsetExists ($ offset ){
25
26
return isset ($ this ->data [$ offset ]);
26
27
}
Original file line number Diff line number Diff line change 3
3
namespace Proxy \Plugin ;
4
4
5
5
use Symfony \Component \EventDispatcher \EventSubscriberInterface ;
6
+ use Symfony \Component \EventDispatcher \EventDispatcherInterface ;
6
7
use Proxy \Event \ProxyEvent ;
7
8
8
9
abstract class AbstractPlugin implements EventSubscriberInterface {
@@ -27,7 +28,7 @@ public function onCompleted(ProxyEvent $event){
27
28
}
28
29
29
30
// dispatch based on filter
30
- final public function route (ProxyEvent $ event ){
31
+ final public function route (ProxyEvent $ event, $ event_name , EventDispatcherInterface $ dispatcher ){
31
32
32
33
$ url = $ event ['request ' ]->getUri ();
33
34
@@ -44,7 +45,7 @@ final public function route(ProxyEvent $event){
44
45
}
45
46
}
46
47
47
- switch ($ event -> getName () ){
48
+ switch ($ event_name ){
48
49
49
50
case 'request.before_send ' :
50
51
$ this ->onBeforeRequest ($ event );
@@ -64,6 +65,8 @@ final public function route(ProxyEvent $event){
64
65
}
65
66
}
66
67
68
+ // This method returns an array indexed by event names and whose values are either the method name to call
69
+ // or an array composed of the method name to call and a priority.
67
70
final public static function getSubscribedEvents (){
68
71
return array (
69
72
'request.before_send ' => 'route ' ,
You can’t perform that action at this time.
0 commit comments