src/event/ConfigurableEmitter.php
public function setListeners(array $listeners = [])
    {
        foreach ($listeners as $listener) {
            if (!isset($listener['event']) || !isset($listener['listener'])) {
                throw new InvalidConfigException('Both "event" and "listener" properties are required to attach a listener.');
            }

            if (is_string($listener['listener'])) {
                $listener['listener'] = $this->listenerFromClassName($listener['listener']);
            }

            $this->addListener($listener['event'], $listener['listener'], $listener['priority'] ?? self::P_NORMAL);
        }

        return $this;
    }
public function setListeners(array $listeners = [])
    {
        foreach ($listeners as $listener) {
            if (!isset($listener['event']) || !isset($listener['listener'])) {
                throw new InvalidConfigException('Both "event" and "listener" properties are required to attach a listener.');
            }

            if (is_string($listener['listener'])) {
                $listener['listener'] = $this->listenerFromClassName($listener['listener']);
            }

            $this->addListener($listener['event'], $listener['listener'], $listener['priority'] ?? self::P_NORMAL);
        }

        return $this;
    }
public function setListeners ( array $ listeners = [ ] ) { foreach ( $ listeners as $ listener ) { if ( ! isset ( $ listener [ 'event' ] ) || ! isset ( $ listener [ 'listener' ] ) ) { throw new InvalidConfigException ( 'Both "event" and "listener" properties are required to attach a listener.' ) ; } if ( is_string ( $ listener [ 'listener' ] ) ) { $ listener [ 'listener' ] = $ this -> listenerFromClassName ( $ listener [ 'listener' ] ) ; } $ this -> addListener ( $ listener [ 'event' ] , $ listener [ 'listener' ] , $ listener [ 'priority' ] ?? self :: P_NORMAL ) ; } return $ this ; }
Allows to set listeners with standard Yii configuration system

@param array[] $listeners
@return $this
@throws InvalidConfigException
Allows to set listeners with standard Yii configuration system