aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvan Enderlin <ivan.enderlin@hoa-project.net>2015-11-23 22:02:52 +0100
committerIvan Enderlin <ivan.enderlin@hoa-project.net>2015-11-23 22:11:34 +0100
commit7c77ba5321ae8e7c20049e29626882459a2899d4 (patch)
tree960d24aa30d11689c62f1f2c1edcd002c0efc51b
parent301b6ab45b8562f0e81ac0b8ae592ffbff3c4507 (diff)
downloadDns-7c77ba5321ae8e7c20049e29626882459a2899d4.zip
Dns-7c77ba5321ae8e7c20049e29626882459a2899d4.tar.gz
Dns-7c77ba5321ae8e7c20049e29626882459a2899d4.tar.bz2
Event: Use `Hoa\Event`.
The core is being splitted into several libraries. `Hoa\Event` is one of them.
-rw-r--r--Bin/Resolve.php4
-rw-r--r--Resolver.php29
-rw-r--r--composer.json1
3 files changed, 8 insertions, 26 deletions
diff --git a/Bin/Resolve.php b/Bin/Resolve.php
index 58ce344..fda03a4 100644
--- a/Bin/Resolve.php
+++ b/Bin/Resolve.php
@@ -37,8 +37,8 @@
namespace Hoa\Dns\Bin;
use Hoa\Console;
-use Hoa\Core;
use Hoa\Dns;
+use Hoa\Event;
use Hoa\Socket;
/**
@@ -119,7 +119,7 @@ class Resolve extends Console\Dispatcher\Kit
}
$dns = new Dns\Resolver(new Socket\Server('udp://' . $listen));
- $dns->on('query', function (Core\Event\Bucket $bucket) use (&$redirections) {
+ $dns->on('query', function (Event\Bucket $bucket) use (&$redirections) {
$data = $bucket->getData();
echo
diff --git a/Resolver.php b/Resolver.php
index cbfe2a9..194f1af 100644
--- a/Resolver.php
+++ b/Resolver.php
@@ -37,6 +37,7 @@
namespace Hoa\Dns;
use Hoa\Core;
+use Hoa\Event;
use Hoa\Socket;
/**
@@ -48,14 +49,9 @@ use Hoa\Socket;
* @copyright Copyright © 2007-2015 Hoa community
* @license New BSD License
*/
-class Resolver implements Core\Event\Listenable
+class Resolver implements Event\Listenable
{
- /**
- * Listeners.
- *
- * @var \Hoa\Core\Event\Listener
- */
- protected $_on = null;
+ use Event\Listens;
/**
* Socket.
@@ -173,27 +169,12 @@ class Resolver implements Core\Event\Listenable
set_time_limit(0);
$this->_server = $server;
- $this->_on = new Core\Event\Listener($this, ['query']);
+ $this->setListener(new Event\Listener($this, ['query']));
return;
}
/**
- * Attach a callable to this listenable object.
- *
- * @param string $listenerId Listener ID.
- * @param mixed $callable Callable.
- * @return \Hoa\Dns\Resolver
- * @throws \Hoa\Core\Exception
- */
- public function on($listenerId, $callable)
- {
- $this->_on->attach($listenerId, $callable);
-
- return $this;
- }
-
- /**
* Run the server.
*
* @return void
@@ -239,7 +220,7 @@ class Resolver implements Core\Event\Listenable
$qclass = (int) (string) ord($handle[$i]);
$class = array_search($qclass, static::$_classes) ?: $qclass;
- $ips = $this->_on->fire('query', new Core\Event\Bucket([
+ $ips = $this->getListener()->fire('query', new Event\Bucket([
'domain' => $domain,
'type' => $type,
'class' => $class
diff --git a/composer.json b/composer.json
index f81c3ce..622c426 100644
--- a/composer.json
+++ b/composer.json
@@ -22,6 +22,7 @@
},
"require": {
"hoa/core" : "~2.0",
+ "hoa/event" : "~0.0",
"hoa/exception": "~0.0"
},
"require-dev": {