Commit 170fb52f authored by Bas de Nooijer's avatar Bas de Nooijer

Make sure an eventhandler instance is always available

parent ac46a00b
...@@ -220,6 +220,9 @@ class Client extends Configurable ...@@ -220,6 +220,9 @@ class Client extends Configurable
*/ */
protected function init() protected function init()
{ {
//@todo use injection
$this->eventDispatcher = new EventDispatcher();
foreach ($this->options as $name => $value) { foreach ($this->options as $name => $value) {
switch ($name) { switch ($name) {
case 'endpoint': case 'endpoint':
...@@ -561,33 +564,29 @@ class Client extends Configurable ...@@ -561,33 +564,29 @@ class Client extends Configurable
return $this->queryTypes; return $this->queryTypes;
} }
/** /**
* Gets the event dispatcher. * Gets the event dispatcher.
* *
* @return EventDispatcherInterface * @return EventDispatcherInterface
*/ */
public function getEventDispatcher() public function getEventDispatcher()
{ {
if (!$this->eventDispatcher) { return $this->eventDispatcher;
$this->eventDispatcher = new EventDispatcher();
} }
return $this->eventDispatcher; /**
} * Sets the event dispatcher.
*
/** * @param EventDispatcherInterface $eventDispatcher
* Sets the event dispatcher. *
* * @return $this
* @param EventDispatcherInterface $eventDispatcher */
* public function setEventDispatcher(EventDispatcherInterface $eventDispatcher)
* @return $this {
*/ $this->eventDispatcher = $eventDispatcher;
public function setEventDispatcher(EventDispatcherInterface $eventDispatcher)
{ return $this;
$this->eventDispatcher = $eventDispatcher; }
return $this;
}
/** /**
* Register a plugin * Register a plugin
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment