Permalink
Browse files

Move listeners to an unique namespace

  • Loading branch information...
1 parent e25f933 commit 1bb5191d9633314a36c9ef65700ba778451e1dd8 @GromNaN committed May 5, 2012
View
33 src/Buzy/Listener/AbstractListener.php
@@ -0,0 +1,33 @@
+<?php
+
+namespace Buzy\Listener;
+
+use Buzy\BrowserEvent;
+use Symfony\Component\EventDispatcher\EventSubscriberInterface;
+
+/**
+ * @author Jérôme Tamarelle <jerome@tamarelle.net>
+ */
+abstract class AbstractListener implements EventSubscriberInterface
+{
+ /**
+ * @param \Buzy\BrowserEvent $event
+ */
+ abstract public function onRequest(BrowserEvent $event);
+
+ /**
+ * @param \Buzy\BrowserEvent $event
+ */
+ abstract public function onResponse(BrowserEvent $event);
+
+ /**
+ * {@inheritDoc}
+ */
+ static public function getSubscribedEvents()
+ {
+ return array(
+ BrowserEvent::REQUEST => 'onRequest',
+ BrowserEvent::RESPONSE => 'onResponse',
+ );
+ }
+}
View
16 src/Buzy/Cache/CacheListener.php → src/Buzy/Listener/CacheListener.php
@@ -1,17 +1,16 @@
<?php
-namespace Buzy\Cache;
+namespace Buzy\Listener;
use Buzy\BrowserEvent;
-use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Doctrine\Common\Cache\Cache;
/**
* HTTP Cache listener provide standard cache features.
*
* @author Jérôme Tamarelle <jerome@tamarelle.net>
*/
-class CacheListener implements EventSubscriberInterface
+class CacheListener extends AbstractListener
{
/**
* @var \Doctrine\Common\Cache\Cache
@@ -78,15 +77,4 @@ protected function generateRequestIdentifier(Request $request)
{
return sha1($request->headers->all());
}
-
- /**
- * {@inheritDoc}
- */
- static public function getSubscribedEvents()
- {
- return array(
- BrowserEvent::REQUEST => 'onRequest',
- BrowserEvent::RESPONSE => 'onResponse',
- );
- }
}
View
16 src/Buzy/Cookie/CookieListener.php → src/Buzy/Listener/CookieListener.php
@@ -1,17 +1,16 @@
<?php
-namespace Buzy\Cookie;
+namespace Buzy\Listener;
use Buzy\BrowserEvent;
-use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\BrowserKit\CookieJar;
/**
* Use the Symfony BrowserKit CookieJar to store HTTP cookies.
*
* @author Jérôme Tamarelle <jerome@tamarelle.net>
*/
-class CookieListener implements EventSubscriberInterface
+class CookieListener extends AbstractListener
{
/**
* @var Jar
@@ -65,15 +64,4 @@ public function onResponse(BrowserEvent $event)
$this->jar->updateFromSetCookie(array($cookies), $uri);
}
-
- /**
- * {@inheritDoc}
- */
- static public function getSubscribedEvents()
- {
- return array(
- BrowserEvent::REQUEST => 'onRequest',
- BrowserEvent::RESPONSE => 'onResponse',
- );
- }
}
View
4 .../Buzy/Tests/Cookie/CookieListenerTest.php → ...uzy/Tests/Listener/CookieListenerTest.php
@@ -1,8 +1,8 @@
<?php
-namespace Buzy\Tests\Cookie;
+namespace Buzy\Tests\Listener;
-use Buzy\Cookie\CookieListener;
+use Buzy\Listener\CookieListener;
use Buzy\BrowserEvent;
use Symfony\Component\BrowserKit\CookieJar;
use Symfony\Component\BrowserKit\Cookie;

0 comments on commit 1bb5191

Please sign in to comment.