Skip to content

Commit

Permalink
Updated
Browse files Browse the repository at this point in the history
  • Loading branch information
bacinsky committed Jun 24, 2019
1 parent 8616c9b commit 33cb5c7
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 19 deletions.
9 changes: 0 additions & 9 deletions CHANGELOG.md

This file was deleted.

3 changes: 2 additions & 1 deletion src/EventDispatcherInterface.php
Expand Up @@ -44,7 +44,8 @@ public function off($callback = null, $event = null): void;
* @api
* @param string|EventInterface $event Event name or object
* @param callable|null $until Invoke handlers until callback return value evaluate to true
* @param EventEmitterInterface|null $target
* @return EventInterface Event object
*/
public function emit($event, callable $until = null): EventInterface;
public function emit($event, callable $until = null, EventEmitterInterface $target = null): EventInterface;
}
8 changes: 5 additions & 3 deletions src/EventDispatcherTrait.php
Expand Up @@ -51,10 +51,10 @@ trait EventDispatcherTrait
* @api
* @param string|EventInterface $event Event name or object
* @param callable|null $until Invoke handlers until callback return value evaluate to true
* @param EventEmitterInterface|null $target
* @return EventInterface Event object
* @throws InvalidEventException Invalid event
*/
public function emit($event, callable $until = null): EventInterface
public function emit($event, callable $until = null, EventEmitterInterface $target = null): EventInterface
{
$event = $this->normalizeEvent($event);
$name = $event->getName();
Expand All @@ -71,7 +71,9 @@ public function emit($event, callable $until = null): EventInterface
$event->setResults([]);
$event->stop(false);

if ($this instanceof EventEmitterInterface) {
if ($target) {
$event->setTarget($target);
} elseif ($this instanceof EventEmitterInterface) {
$event->setTarget($this);
}

Expand Down
1 change: 0 additions & 1 deletion src/EventEmitterInterface.php
Expand Up @@ -20,7 +20,6 @@ interface EventEmitterInterface extends EventDispatcherInterface
* Inject event dispatcher.
*
* @api
* @since 1.1.0
* @param EventDispatcherInterface $dispatcher
*/
public function setEventDispatcher(EventDispatcherInterface $dispatcher): void;
Expand Down
8 changes: 3 additions & 5 deletions src/EventEmitterTrait.php
Expand Up @@ -24,7 +24,6 @@ trait EventEmitterTrait
/**
* Returns event dispatcher.
*
* @since 1.1.0
* @return EventDispatcherInterface
*/
public function getEventDispatcher(): EventDispatcherInterface
Expand All @@ -39,7 +38,6 @@ public function getEventDispatcher(): EventDispatcherInterface
* Inject event dispatcher.
*
* @api
* @since 1.1.0
* @param EventDispatcherInterface $dispatcher
*/
public function setEventDispatcher(EventDispatcherInterface $dispatcher): void
Expand All @@ -53,12 +51,12 @@ public function setEventDispatcher(EventDispatcherInterface $dispatcher): void
* @api
* @param string|EventInterface $event Event name or object
* @param callable|null $until Invoke handlers until callback return value evaluate to true
* @param EventEmitterInterface|null $target
* @return EventInterface Event object
* @throws InvalidEventException Invalid event
*/
public function emit($event, callable $until = null): EventInterface
public function emit($event, callable $until = null, EventEmitterInterface $target = null): EventInterface
{
return $this->getEventDispatcher()->emit($event, $until);
return $this->getEventDispatcher()->emit($event, $until, $this);
}

/**
Expand Down

0 comments on commit 33cb5c7

Please sign in to comment.