public function trigger($eventName, array $params = []) {
        $event = clone $this->event;
        $event->setName($eventName);

        // Add optional extra arguments
        foreach ($params as $key => $value) {
            $event->setArgument($key, $value);
        }

        // Fetch current user
        $user = $event->getRequest()->getUser();

        // Trigger all listeners for this event and pass in the event instance
        foreach ($this->getListenersForEvent($eventName) as $listener) {
            $event->setArgument('handler', $listener['handler']);
            $callback = $this->getHandlerInstance($listener['handler']);

            if ($callback instanceof ListenerInterface) {
                $callback = [$callback, $listener['method']];
            }

            $users = $listener['users'];

            if (!$this->triggersFor($user, $users)) {
                continue;
            }

            $callback($event);

            if ($event->isPropagationStopped()) {
                break;
            }
        }

        return $this;
    }
public function trigger($eventName, array $params = []) {
        $event = clone $this->event;
        $event->setName($eventName);

        // Add optional extra arguments
        foreach ($params as $key => $value) {
            $event->setArgument($key, $value);
        }

        // Fetch current user
        $user = $event->getRequest()->getUser();

        // Trigger all listeners for this event and pass in the event instance
        foreach ($this->getListenersForEvent($eventName) as $listener) {
            $event->setArgument('handler', $listener['handler']);
            $callback = $this->getHandlerInstance($listener['handler']);

            if ($callback instanceof ListenerInterface) {
                $callback = [$callback, $listener['method']];
            }

            $users = $listener['users'];

            if (!$this->triggersFor($user, $users)) {
                continue;
            }

            $callback($event);

            if ($event->isPropagationStopped()) {
                break;
            }
        }

        return $this;
    }
public function trigger ( $ eventName , array $ params = [ ] ) { $ event = clone $ this -> event ; $ event -> setName ( $ eventName ) ; // Add optional extra arguments foreach ( $ params as $ key => $ value ) { $ event -> setArgument ( $ key , $ value ) ; } // Fetch current user $ user = $ event -> getRequest ( ) -> getUser ( ) ; // Trigger all listeners for this event and pass in the event instance foreach ( $ this -> getListenersForEvent ( $ eventName ) as $ listener ) { $ event -> setArgument ( 'handler' , $ listener [ 'handler' ] ) ; $ callback = $ this -> getHandlerInstance ( $ listener [ 'handler' ] ) ; if ( $ callback instanceof ListenerInterface ) { $ callback = [ $ callback , $ listener [ 'method' ] ] ; } $ users = $ listener [ 'users' ] ; if ( ! $ this -> triggersFor ( $ user , $ users ) ) { continue ; } $ callback ( $ event ) ; if ( $ event -> isPropagationStopped ( ) ) { break ; } } return $ this ; }
Trigger a given event

@param string $eventName The name of the event to trigger
@param array $params Extra parameters for the event
@return EventManager
Trigger a given event