Final Class Yiisoft\Test\Support\EventDispatcher\SimpleEventDispatcher
| Inheritance | Yiisoft\Test\Support\EventDispatcher\SimpleEventDispatcher |
|---|---|
| Implements | Psr\EventDispatcher\EventDispatcherInterface |
Public Methods
Method Details
| public mixed __construct ( Closure $listeners ) | ||
| $listeners | Closure |
Functions that will handle each event. |
public function __construct(Closure ...$listeners)
{
$this->listeners = $listeners;
}
| public object dispatch ( object $event ) | ||
| $event | object | |
public function dispatch(object $event): object
{
$this->events[] = $event;
foreach ($this->listeners as $listener) {
if ($event instanceof StoppableEventInterface && $event->isPropagationStopped()) {
return $event;
}
$listener($event);
}
return $event;
}
| public array getEventClasses ( ) |
public function getEventClasses(): array
{
return array_map('\get_class', $this->events);
}
| public boolean isClassTriggered ( string $class, integer|null $times = null ) | ||
| $class | string | |
| $times | integer|null | |
public function isClassTriggered(string $class, ?int $times = null): bool
{
return $this->processBoolResult(static fn (object $event): bool => $event::class === $class, $times);
}
| public boolean isInstanceOfTriggered ( string $class, integer|null $times = null ) | ||
| $class | string | |
| $times | integer|null | |
public function isInstanceOfTriggered(string $class, ?int $times = null): bool
{
return $this->processBoolResult(static fn (object $event): bool => $event instanceof $class, $times);
}
Signup or Login in order to comment.