Processes a single JSON RPC request.

@param stdClass $request Object with attributes of JSON RPC request
@return Associative array with JSON RPC response or NULL in case of JSON RPC notifications
168105
protected function _processJson( stdClass $request )
	{
		$response = array(
			'jsonrpc' => '2.0',
		);

		try
		{
			if( !isset( $request->method ) )
			{
				$msg = sprintf( 'Required attribute "%1$s" missing in request', 'method' );
				throw new Controller_ExtJS_Exception( $msg, -32600 );
			}

			if( !isset( $request->params ) ) {
				throw new Controller_ExtJS_Exception( 'Required parameters are missing in request', -32600 );
			}

			$response['result'] = $this->_callMethod( $request->method, $request->params );
		}
		catch( Exception $e )
		{
			$response['error'] = array(
				'code' => ( $e->getCode() != 0 ? $e->getCode() : -1 ),
				'message' => $e->getMessage(),
			);
		}

		if( !isset( $request->id ) ) {
			return null;
		}

		$response['id'] = $request->id;
		return $response;
	}
1211322
protected function parseJsonBody(ServerRequestInterface $request)
    {
        $body = $request->getBody()->__toString();
        if ($request->hasHeader('Content-Encoding') && 'base64' === $request->getHeader('Content-Encoding')) {
            $body = base64_decode($body, true);
        }

        $bodyJson = @json_decode($body, true);
        if (JSON_ERROR_NONE !== json_last_error()) {
            throw new \Exception(json_last_error_msg());
        }

        return $bodyJson;
    }
699122
public function processRequest(IRequest $request): IResponse
    {
        $this->lastRequest = $request;
        foreach ($this->preRequestMiddlewares as $middleware) {
            $middleware->handle($request);
        }
        $request->incrementTries();

        $headers = $this->configuration->getProvider()->getHeaders($this->token);

        $options = $request->requestOptions();
        if (isset($options[RequestOptions::HEADERS])) {
            $options[RequestOptions::HEADERS] = array_merge($options[RequestOptions::HEADERS], $headers);
        } else {
            $options[RequestOptions::HEADERS] = $headers;
        }

        try {
            $response   = $this->guzzleClient->request($request->httpType()->getValue(), $request->toUri(), $options);
            $parsedData = JSONParsing::responseToJson($response);

            if (isset($this->postRequestMiddlewares[$response->getStatusCode()])) {
                foreach ($this->postRequestMiddlewares[$response->getStatusCode()] as $middleware) {
                    $parsedData = $middleware->handle($request, $response, $parsedData);
                }
            }
        } catch (BadResponseException $e) {
            /**
             * Check status code.
             */
            $response = $e->getResponse();
            $this->processThrottleData($response);

            if (!isset($this->postRequestMiddlewares[$response->getStatusCode()])) {
                throw new SDKException($e->getMessage(), $e->getCode(), $e);
            }
            $parsedData = JSONParsing::responseToJson($response);

            foreach ($this->postRequestMiddlewares[$response->getStatusCode()] as $middleware) {
                $parsedData = $middleware->handle($request, $response, $parsedData);
            }
        } catch (RequestException $e) {
            if ($request->requestType()->is(RequestType::HTTP_GET())
                && $request->tries() < 3) {
                return $this->processRequest($request);
            }

            throw new TooManyRetriesException($e->getMessage(), $e->getCode(), $e);
        } catch (\GuzzleHttp\Exception\GuzzleException $e) {
            throw new SDKException($e->getMessage(), $e->getCode(), $e);
        }

        /**
         * @var $data BaseResponse
         */
        $data = $request->processResponse($parsedData);

        if ($data instanceof BaseResponse) {
            $data->setRawData($parsedData);
        }

        if ($data instanceof IRateLimitedResponse) {
            $this->processThrottleData($response);
            $data->setRateLimit($this->rateLimit);
        }

        $request->setResponse($data);

        return $data;
    }
1273188
public function schema($request)
    {
        $formName = $request->param('FormName');
        $itemID = $request->param('ItemID');

        if (!$formName) {
            $this->jsonError(400, 'Missing request params');
            return null;
        }

        $formMethod = "get{$formName}";
        if (!$this->hasMethod($formMethod)) {
            $this->jsonError(404, 'Form not found');
            return null;
        }

        if (!$this->hasAction($formName)) {
            $this->jsonError(401, 'Form not accessible');
            return null;
        }

        if ($itemID) {
            $form = $this->{$formMethod}($itemID);
        } else {
            $form = $this->{$formMethod}();
        }
        $schemaID = $request->getURL();
        return $this->getSchemaResponse($schemaID, $form);
    }
804741
public function process($request)
    {
        $templateName = $this->configData->getRequired('template');
        
        $body = $this->template->render(
            $templateName,
            array(
                'request' => $request
            )
        );
        
        return $this->http->responses()->response($body, array(), 404);
    }
121904
private static function preprocessJsonRequest($request) {

        // check for required parameters

        if (
            !is_object($request) ||
            !property_exists($request, 'jsonrpc') ||
            !property_exists($request, 'method') ||
            $request->jsonrpc != '2.0' ||
            empty($request->method)
        ) {

            return array(
                'ERROR_CODE' => -32600,
                'ERROR_MESSAGE' => 'Invalid Request',
                'ID' => !isset($request['id']) ? null : $request['id']
            );

        }

        // parse request's components

        return array(
            'METHOD' => $request->method,
            'PARAMETERS' => property_exists($request, 'params') ? $request->params : [],
            'ID' => property_exists($request, 'id') ? $request->id : null
        );

    }
452490
function jsonSerialize(): \stdClass {
    return (object) [
      'sourceFile' => $this->getSourceFile(),
      'branches' => ($branches = $this->getBranches()) ? $branches->jsonSerialize() : null,
      'functions' => ($functions = $this->getFunctions()) ? $functions->jsonSerialize() : null,
      'lines' => ($lines = $this->getLines()) ? $lines->jsonSerialize() : null
    ];
  }
561350
public function executeCurlRequest($request)
    {
        $result = $this->request->cPost($request->getRequestUrl(), $this->config['cacert'], $request->params(), $this->getCharset());

        return $result;
    }
969023
public function toResponse($request)
    {
        if (!empty($this->resource)) {
            return $this->resource->response($request)->setStatusCode($this->status())->withHeaders($this->headers);
        }

        ///
        $data = [
            'status_code' => $this->getStatusCode(),
            'message' => $this->getContent(),
        ];

        if (!empty($this->meta)) {
            $data['meta'] = $this->meta;
        }

        if ($this->debug && !empty($this->debugData)) {
            $data['debug'] = $this->debugData;
        }

        return response()->json($data, $this->status())->withHeaders($this->headers);
    }
410229
public function updateOrder(Request $request): JsonResponse
    {
        Category::rebuildTree(
            $request->input('tree')
        );

        $this->clearCache();

        $movedNode = Category::findOrFail(
            $request->input('moved')
        );

        dispatch(
            new RegenerateCategoryFullSlugs($movedNode)
        );

        return response()->json([
            'state' => 'success',
        ]);
    }
918145
public function execute(Request $request): Response
    {
        $method = $request->getMethod();
        list($resp, $grpcStatus) = $request->getClient()->$method(
            $request->getMessage(),
            $request->getMetadata(),
            $request->getOptions()
        )->wait();

        $headers = new HeaderCollection();

        if (is_null($grpcStatus)) { // in the very bad case even this fails to return
            $status = new Error\Status(\Grpc\STATUS_UNKNOWN, '', $headers);
        } else {
            $metadata = $grpcStatus->metadata;
            foreach ($metadata as $k => $v) {
                if (is_array($v)) {
                    foreach ($v as $v2) {
                        $headers->add($k, $v2);
                    }
                } else {
                    $headers->add($k, $v);
                }
            }
            $status = new Error\Status(intval($grpcStatus->code), strval($grpcStatus->details), $headers);
        }

        if (is_null($resp)) {
            $request->fail($status);
        }

        return $request->succeed($resp, $status);
    }
134841
public function execute( Request $request )
    {
        $controllerClass = $request->attributes->get('_controller');
        if( !($this->isJwtRequired($controllerClass))) {
            return null;
        }

        if( !$this->authoriser->isAuthorised( $request ) ) {
            return new JsonResponse( ['error' => 'Invalid token'], 403 );
        }
        return null;
    }
702729
protected function dispatchRequestToAuthorizationServer(ServerRequest $request)
    {
        return json_decode($this->server->respondToAccessTokenRequest(
            $request, new Response
        )->getBody()->__toString(), true);
    }
1075307
protected function decodeRequestData(Request $request)
    {
        $dataRaw = $request->getContent();
        $data = null;

        if (!empty($dataRaw)) {
            $data = json_decode($dataRaw, true);
        }

        return $data;
    }
202874
protected function process(RequestInterface $request, string $responseClassName = null): ?ResponseInterface
    {
        $context = SerializationContext::create();

        $request = $this->serializer->serialize($request, $this->serializerFormat, $context);

        $response = $this->httpClient->post('', ['body' => $request]);

        if (!$responseClassName) {
            return null;
        }

        return $this->serializer->deserialize($response->getBody(), $responseClassName, $this->deserializerFormat);
    }
1024264
public function permissionsAction(Request $request)
    {
        $objectType = $request->get('objectType');

        $permissionRegistry = $this->get('phlexible_access_control.permission_registry');
        $permissions = array();
        foreach ($permissionRegistry->get($objectType)->all() as $permission) {
            $permissions[] = array(
                'name' => $permission->getName(),
                'bit' => $permission->getBit(),
                'iconCls' => 'null',
            );
        }

        return new JsonResponse(array('permissions' => $permissions));
    }
251799
public function run($request)
    {
        $this->request = $request;
        $args = $request->getVar('args');

        // The "cleanup" task has a different argument signature. Because it doesn't require the specification of a class.
        // This block normalizes that.
        if ($args[0] == "cleanup") {
            if (!isset($args[1])) {
                $args[1] = "__all__";
            }
            if ($args[1] != "__all__") {
                if (!class_exists($args[1]) || !is_subclass_of($args[1], "DataObject")) {
                    $this->showError("Please specify a valid DataObject descendant class.");
                }
            }

            return $this->cleanup($args[1]);
        } else {
            if (count($args) < 2) {
                $this->showError("Usage: MockDataTask <generate|populate|cleanup> <classname> [options]");
            }

            list($operation, $className) = $args;

            if (!class_exists($className) || !is_subclass_of($className, "DataObject")) {
                $this->showError("Please specify a valid DataObject descendant class.");
            }

            if (!in_array($operation, array('generate', 'populate', 'cleanup'))) {
                $this->showError("Please specify a valid operation (\"generate\", \"populate\", or \"cleanup\")");
            }


            $this->runBuilderCommand($operation, $className);
        }
    }