protected function executeListeners(RequestInterface $request, $when = 'preSend', MessageInterface $response = null)
    {
        $haveListeners  = count($this->listeners) > 0;

        if (!$haveListeners) {
            return;
        }

        $params = array($request);

        if (null !== $response) {
            $params[] = $response;
        }

        ksort($this->listeners, SORT_ASC);

        array_walk_recursive(
            $this->listeners,
            function ($class) use ($when, $params) {
                if ($class instanceof ListenerInterface) {
                    call_user_func_array(array($class, $when), $params);
                }
            }
        );
    }
protected function executeListeners(RequestInterface $request, $when = 'preSend', MessageInterface $response = null)
    {
        $haveListeners  = count($this->listeners) > 0;

        if (!$haveListeners) {
            return;
        }

        $params = array($request);

        if (null !== $response) {
            $params[] = $response;
        }

        ksort($this->listeners, SORT_ASC);

        array_walk_recursive(
            $this->listeners,
            function ($class) use ($when, $params) {
                if ($class instanceof ListenerInterface) {
                    call_user_func_array(array($class, $when), $params);
                }
            }
        );
    }
protected function executeListeners ( RequestInterface $ request , $ when = 'preSend' , MessageInterface $ response = null ) { $ haveListeners = count ( $ this -> listeners ) > 0 ; if ( ! $ haveListeners ) { return ; } $ params = array ( $ request ) ; if ( null !== $ response ) { $ params [ ] = $ response ; } ksort ( $ this -> listeners , SORT_ASC ) ; array_walk_recursive ( $ this -> listeners , function ( $ class ) use ( $ when , $ params ) { if ( $ class instanceof ListenerInterface ) { call_user_func_array ( array ( $ class , $ when ) , $ params ) ; } } ) ; }
Execute all available listeners.

$when can be: preSend or postSend

@access protected
@param RequestInterface $request
@param string           $when     When to execute the listener
@param MessageInterface $response
Execute all available listeners .