src/Vectorface/SnappyRouter/Handler/JsonRpcHandler.php
private function invokeMethod($service, JsonRpcRequest $request)
    {
        if (false === $request->isValid()) {
            /* Note: Method isn't known, so invocation hooks aren't called. */
            return new JsonRpcResponse(
                null,
                new Exception(
                    'The JSON sent is not a valid Request object',
                    self::ERR_INVALID_REQUEST
                )
            );
        }

        $action = $request->getAction();
        $this->invokePluginsHook(
            'afterServiceSelected',
            array($this, $request, $service, $action)
        );

        $this->invokePluginsHook(
            'beforeMethodInvoked',
            array($this, $request, $service, $action)
        );

        try {
            $response = new JsonRpcResponse(
                call_user_func_array(array($service, $action), $request->getParameters()),
                null,
                $request
            );
        } catch (Exception $e) {
            $error = new Exception($e->getMessage(), self::ERR_INTERNAL_ERROR);
            $response = new JsonRpcResponse(null, $error, $request);
        }

        $this->invokePluginsHook(
            'afterMethodInvoked',
            array($this, $request, $service, $action, $response)
        );

        return $response;
    }
private function invokeMethod($service, JsonRpcRequest $request)
    {
        if (false === $request->isValid()) {
            /* Note: Method isn't known, so invocation hooks aren't called. */
            return new JsonRpcResponse(
                null,
                new Exception(
                    'The JSON sent is not a valid Request object',
                    self::ERR_INVALID_REQUEST
                )
            );
        }

        $action = $request->getAction();
        $this->invokePluginsHook(
            'afterServiceSelected',
            array($this, $request, $service, $action)
        );

        $this->invokePluginsHook(
            'beforeMethodInvoked',
            array($this, $request, $service, $action)
        );

        try {
            $response = new JsonRpcResponse(
                call_user_func_array(array($service, $action), $request->getParameters()),
                null,
                $request
            );
        } catch (Exception $e) {
            $error = new Exception($e->getMessage(), self::ERR_INTERNAL_ERROR);
            $response = new JsonRpcResponse(null, $error, $request);
        }

        $this->invokePluginsHook(
            'afterMethodInvoked',
            array($this, $request, $service, $action, $response)
        );

        return $response;
    }
private function invokeMethod ( $ service , JsonRpcRequest $ request ) { if ( false === $ request -> isValid ( ) ) { /* Note: Method isn't known, so invocation hooks aren't called. */ return new JsonRpcResponse ( null , new Exception ( 'The JSON sent is not a valid Request object' , self :: ERR_INVALID_REQUEST ) ) ; } $ action = $ request -> getAction ( ) ; $ this -> invokePluginsHook ( 'afterServiceSelected' , array ( $ this , $ request , $ service , $ action ) ) ; $ this -> invokePluginsHook ( 'beforeMethodInvoked' , array ( $ this , $ request , $ service , $ action ) ) ; try { $ response = new JsonRpcResponse ( call_user_func_array ( array ( $ service , $ action ) , $ request -> getParameters ( ) ) , null , $ request ) ; } catch ( Exception $ e ) { $ error = new Exception ( $ e -> getMessage ( ) , self :: ERR_INTERNAL_ERROR ) ; $ response = new JsonRpcResponse ( null , $ error , $ request ) ; } $ this -> invokePluginsHook ( 'afterMethodInvoked' , array ( $ this , $ request , $ service , $ action , $ response ) ) ; return $ response ; }
Invokes a method on a service class, based on the raw JSON-RPC request.

@param mixed $service The service being invoked.
@param Vectorface\SnappyRouter\Request\JsonRpcRequest $request The request
to invoke.
@return JsonRpcResponse A response based on the result of the procedure call.
Invokes a method on a service class based on the raw JSON - RPC request .