diff --git a/DependencyInjection/GuzzleExtension.php b/DependencyInjection/GuzzleExtension.php
index 2c97f2a..3e6875a 100644
--- a/DependencyInjection/GuzzleExtension.php
+++ b/DependencyInjection/GuzzleExtension.php
@@ -59,7 +59,7 @@ public function load(array $configs, ContainerBuilder $container) {
* Set up HTTP headers
*
* @author Florian Preusner
- * @version 1.0
+ * @version 2.0
* @since 2013-10
*
* @param array $headers
@@ -70,16 +70,16 @@ public function load(array $configs, ContainerBuilder $container) {
protected function setUpHeaders(array $headers, ContainerBuilder $container) {
$container->setParameter('guzzle.plugin.header.headers', $headers);
- $container->getDefinition('guzzle.client')
- ->addMethodCall('getEventDispatcher')
- ->addMethodCall('addSubscriber', array($container->getDefinition('guzzle.plugin.header')));
+
+ $container->getDefinition('guzzle.emitter')
+ ->addMethodCall('attach', array($container->getDefinition('guzzle.plugin.header')));
} // end: setUpHeaders
/**
* Set up WSSE settings
*
* @author Florian Preusner
- * @version 1.0
+ * @version 2.0
* @since 2013-10
*
* @param array $config
@@ -94,9 +94,8 @@ protected function setUpWsse(array $config, ContainerBuilder $container) {
$container->setParameter('guzzle.plugin.wsse.username', $config['username']);
$container->setParameter('guzzle.plugin.wsse.password', $config['password']);
- $container->getDefinition('guzzle.client')
- ->addMethodCall('getEventDispatcher')
- ->addMethodCall('addSubscriber', array($container->getDefinition('guzzle.plugin.wsse')));
+ $container->getDefinition('guzzle.emitter')
+ ->addMethodCall('attach', array($container->getDefinition('guzzle.plugin.wsse')));
}
} // end: setUpWsse
diff --git a/EventListener/HeaderSubscriber.php b/EventListener/HeaderSubscriber.php
index 21127b1..8101b59 100644
--- a/EventListener/HeaderSubscriber.php
+++ b/EventListener/HeaderSubscriber.php
@@ -2,8 +2,8 @@
namespace EightPoints\Bundle\GuzzleBundle\EventListener;
-use Guzzle\Common\Event,
- Symfony\Component\EventDispatcher\EventSubscriberInterface;
+use GuzzleHttp\Event\BeforeEvent,
+ GuzzleHttp\Event\SubscriberInterface;
/**
* Adds headers to request
@@ -11,10 +11,10 @@
* @package EightPoints\Bundle\GuzzleBundle\EventListener
* @author Florian Preusner
*
- * @version 1.0
+ * @version 2.0
* @since 2013-10
*/
-class HeaderSubscriber implements EventSubscriberInterface {
+class HeaderSubscriber implements SubscriberInterface {
/**
* @var array $headers
@@ -105,33 +105,33 @@ public function getHeader($key) {
* {@inheritdoc}
*
* @author Florian Preusner
- * @version 1.0
+ * @version 2.0
* @since 2013-10
*/
- public static function getSubscribedEvents() {
+ public function getEvents() {
- return array('client.create_request' => 'onRequestCreate');
- } // end: getSubscribedEvents
+ return ['before' => ['onBefore']];
+ } // end: getEvents
/**
* Add given headers to request
*
* @author Florian Preusner
- * @version 1.0
+ * @version 2.0
* @since 2013-10
*
- * @param Event $event
+ * @param BeforeEvent $event
*
* @return void
*/
- public function onRequestCreate(Event $event) {
+ public function onBefore(BeforeEvent $event) {
- $request = $event['request'];
+ $request = $event->getRequest();
// make sure to keep headers that have been already set
- foreach($this->headers as $key => $value) {
+ foreach($this->getHeaders() as $key => $value) {
$request->addHeader($key, $value);
}
- } // end: onRequestCreate
+ } // end: onBefore
} // end: HeaderSubscriber
diff --git a/Resources/config/services.xml b/Resources/config/services.xml
index 377c470..b7cc3eb 100644
--- a/Resources/config/services.xml
+++ b/Resources/config/services.xml
@@ -5,18 +5,21 @@
GuzzleHttp\Client
+ GuzzleHttp\Event\Emitter
EightPoints\Bundle\GuzzleBundle\EventListener\HeaderSubscriber
EightPoints\Guzzle\Plugin\WsseAuthPlugin
-
+
+
%guzzle.base_url%
+