Final Class Yiisoft\ActiveRecord\Event\EventDispatcherProvider
| Inheritance | Yiisoft\ActiveRecord\Event\EventDispatcherProvider |
|---|
Provider of event dispatchers for target object class names.
Public Methods
| Method | Description | Defined By |
|---|---|---|
| get() | Returns the dispatcher for the given target object class name. If the dispatcher is not defined, it will be created using the listeners defined in the target object class's attributes. | Yiisoft\ActiveRecord\Event\EventDispatcherProvider |
| reset() | Resets the list of dispatchers. | Yiisoft\ActiveRecord\Event\EventDispatcherProvider |
| set() | Sets the dispatcher for the target object class name. | Yiisoft\ActiveRecord\Event\EventDispatcherProvider |
Method Details
Returns the dispatcher for the given target object class name. If the dispatcher is not defined, it will be created using the listeners defined in the target object class's attributes.
| public static \Psr\EventDispatcher\EventDispatcherInterface get ( string $targetClass ) | ||
| $targetClass | string |
The target object class name. |
| return | \Psr\EventDispatcher\EventDispatcherInterface |
The dispatcher for the target. |
|---|---|---|
public static function get(string $targetClass): EventDispatcherInterface
{
if (!isset(self::$dispatchers[$targetClass])) {
self::$dispatchers[$targetClass] = new Dispatcher(new Provider(self::getListenersFromAttributes($targetClass)));
}
return self::$dispatchers[$targetClass];
}
Resets the list of dispatchers.
| public static void reset ( ) |
public static function reset(): void
{
self::$dispatchers = [];
}
Sets the dispatcher for the target object class name.
| public static void set ( string $targetClass, \Psr\EventDispatcher\EventDispatcherInterface $dispatcher ) | ||
| $targetClass | string |
The target object class name. |
| $dispatcher | \Psr\EventDispatcher\EventDispatcherInterface |
The dispatcher to be set |
public static function set(string $targetClass, EventDispatcherInterface $dispatcher): void
{
self::$dispatchers[$targetClass] = $dispatcher;
}
Signup or Login in order to comment.