0 follower

Final Class Yiisoft\ActiveRecord\Event\EventDispatcherProvider

InheritanceYiisoft\ActiveRecord\Event\EventDispatcherProvider

Provider of event dispatchers for target object class names.

Public Methods

Hide inherited 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

Hide inherited methods

get() public static method

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];
}

            
reset() public static method

Resets the list of dispatchers.

public static void reset ( )

                public static function reset(): void
{
    self::$dispatchers = [];
}

            
set() public static method

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;
}