Skip to content

Commit 12584d6

Browse files
committed
AbstractPlugin no longer depends on deprecated Event getName method
1 parent edac728 commit 12584d6

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/Event/ProxyEvent.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Symfony\Component\EventDispatcher\Event;
66

7+
// http://symfony.com/doc/current/components/event_dispatcher/generic_event.html
78
class ProxyEvent extends Event implements \ArrayAccess {
89

910
private $data;
@@ -13,14 +14,14 @@ public function __construct($data = array()){
1314
}
1415

1516
public function offsetSet($offset, $value){
16-
17+
1718
if(is_null($offset)) {
1819
$this->data[] = $value;
1920
} else {
2021
$this->data[$offset] = $value;
2122
}
22-
}
23-
23+
}
24+
2425
public function offsetExists($offset){
2526
return isset($this->data[$offset]);
2627
}

src/Plugin/AbstractPlugin.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Proxy\Plugin;
44

55
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
6+
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
67
use Proxy\Event\ProxyEvent;
78

89
abstract class AbstractPlugin implements EventSubscriberInterface {
@@ -27,7 +28,7 @@ public function onCompleted(ProxyEvent $event){
2728
}
2829

2930
// dispatch based on filter
30-
final public function route(ProxyEvent $event){
31+
final public function route(ProxyEvent $event, $event_name, EventDispatcherInterface $dispatcher){
3132

3233
$url = $event['request']->getUri();
3334

@@ -44,7 +45,7 @@ final public function route(ProxyEvent $event){
4445
}
4546
}
4647

47-
switch($event->getName()){
48+
switch($event_name){
4849

4950
case 'request.before_send':
5051
$this->onBeforeRequest($event);
@@ -64,6 +65,8 @@ final public function route(ProxyEvent $event){
6465
}
6566
}
6667

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.
6770
final public static function getSubscribedEvents(){
6871
return array(
6972
'request.before_send' => 'route',

0 commit comments

Comments
 (0)