Final Class Yiisoft\Test\Support\EventDispatcher\SimpleEventDispatcher
| Inheritance | Yiisoft\Test\Support\EventDispatcher\SimpleEventDispatcher |
|---|---|
| Implements | Psr\EventDispatcher\EventDispatcherInterface |
Public Methods
Method Details
| public __construct( Closure $listeners ): mixed | ||
| $listeners | Closure |
Functions that will handle each event. |
public function __construct(Closure ...$listeners)
{
$this->listeners = $listeners;
}
| public dispatch( object $event ): object | ||
| $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 getEventClasses( ): array |
public function getEventClasses(): array
{
return array_map('\get_class', $this->events);
}
| public isClassTriggered( string $class, integer|null $times = null ): boolean | ||
| $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 isInstanceOfTriggered( string $class, integer|null $times = null ): boolean | ||
| $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.