12
12
*/
13
13
namespace Tmdb \Event ;
14
14
15
+ use Symfony \Component \EventDispatcher \EventDispatcherInterface ;
15
16
use Tmdb \Exception \RuntimeException ;
16
17
use Tmdb \HttpClient \HttpClientEventSubscriber ;
17
18
use Tmdb \HttpClient \Response ;
@@ -29,10 +30,17 @@ public static function getSubscribedEvents()
29
30
];
30
31
}
31
32
32
- public function send (RequestEvent $ event )
33
+ /**
34
+ * @param RequestEvent $event
35
+ * @param string $eventName
36
+ * @param EventDispatcherInterface $eventDispatcher
37
+ *
38
+ * @return string|Response
39
+ */
40
+ public function send (RequestEvent $ event , $ eventName , EventDispatcherInterface $ eventDispatcher )
33
41
{
34
42
// Preparation of request parameters / Possibility to use for logging and caching etc.
35
- $ event -> getDispatcher () ->dispatch (TmdbEvents::BEFORE_REQUEST , $ event );
43
+ $ eventDispatcher ->dispatch (TmdbEvents::BEFORE_REQUEST , $ event );
36
44
37
45
if ($ event ->isPropagationStopped () && $ event ->hasResponse ()) {
38
46
return $ event ->getResponse ();
@@ -42,7 +50,7 @@ public function send(RequestEvent $event)
42
50
$ event ->setResponse ($ response );
43
51
44
52
// Possibility to cache the request
45
- $ event -> getDispatcher () ->dispatch (TmdbEvents::AFTER_REQUEST , $ event );
53
+ $ eventDispatcher ->dispatch (TmdbEvents::AFTER_REQUEST , $ event );
46
54
47
55
return $ response ;
48
56
}
@@ -56,8 +64,6 @@ public function send(RequestEvent $event)
56
64
*/
57
65
public function sendRequest (RequestEvent $ event )
58
66
{
59
- $ response = null ;
60
-
61
67
switch ($ event ->getMethod ()) {
62
68
case 'GET ' :
63
69
$ response = $ this ->getHttpClient ()->getAdapter ()->get ($ event ->getRequest ());
0 commit comments