Processes the current request and returns an instance of CallbackResult.

@return bool|Response\CallbackResult
@throws RestException
173387
public function processRequest()
    {
        try {
            $router = new Router($this->api, $this->class, $this->normalize, $this->cacheInstance);

            // check if url is set via the initRest method
            if (!empty(self::$url)) {
                $router->setUrl(self::$url);
            }

            // check if the method vas set via initRest method
            if (!empty(self::$method)) {
                $router->setHttpMethod(self::$method);
            }

            return $router->processRequest();
        } catch (\Exception $e) {
            $exception = new RestException('Unable to process request for class "' . $this->class . '". ' . $e->getMessage());
            $exception->setRequestedClass($this->class);
            throw $exception;
        }
    }
1350061
public function request()
    {
        $data = $this->prepareData();

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $this->apiHost . '/api');
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

        $result = curl_exec($ch);
        $this->checkResult($result);

        return $result;
    }
275979
public function handle()
    {
        // get information about the REST-request
        $this->get();

        if ($this->requestMethod === 'GET' && $this->typo3Cache->hasCacheEntry($this->url, $_GET)) {
            return $this->handleRequestByTypo3Cache();
        }

        // if no cache exist: restler should handle the request
        if (Defaults::$useVendorMIMEVersioning) {
            $this->responseFormat = $this->negotiateResponseFormat();
        }
        $this->route();
        $this->negotiate();
        $this->preAuthFilter();
        $this->authenticate();
        $this->postAuthFilter();
        $this->validate();
        $this->preCall();
        $this->call();
        $this->compose();
        $this->postCall();

        if ($this->responseFormat instanceof JsonFormat) {
            // return stdClass-object (instead of an array)
            return $this->getRestApiJsonFormat()->decode($this->responseData);
        }
        return $this->responseFormat->decode($this->responseData);
    }
64193
public function run() {

        foreach ( $this->requests as $request ) {

            if ( isset($request['ERROR_CODE']) && isset($request['ERROR_MESSAGE']) ) {

                $this->logger->warning("Invalid request ".$request['ID']);

                $result = self::packJsonError($request['ERROR_CODE'], $request['ERROR_MESSAGE'], $request['ID']);

                if ( !is_null($result) ) $this->results[] = $result;

            } else {

                try {

                    $this->logger->debug("Serving request ".$request['METHOD']."(".$request['ID'].")");

                    $response = $this->runSingleRequest($request['METHOD'], $request['PARAMETERS']);

                    $result = self::packJsonSuccess($response, $request['ID']);

                } catch (RpcException $re) {

                    $this->logger->warning("Error handling request ".$request['ID'].": ".$re->getMessage());

                    $result = self::packJsonError($re->getCode(), $re->getMessage(), $request['ID']);

                } catch (Exception $e) {

                    $this->logger->error($e->getMessage());

                    throw $e;

                }

                if ( !is_null($result) ) $this->results[] = $result;

            }


        }

        if ( empty($this->results) ) {

            return null;

        } else if ( $this->is_batch_request ) {

            return $this->results;

        } else {

            return $this->results[0];

        }

    }
1142462
public function process()
    {
        $reader = new AnnotationReader();

        $paths = array();
        /* @var Route $route */
        foreach ($this->routeCollection->getIterator() as $route) {
            $routeMethod = $this->getReflectionMethodForRoute($route);
            if($routeMethod === null) continue;

            /** @var Swagger $swaggerAnnotation */
            $swaggerAnnotation = $reader->getMethodAnnotation($routeMethod, Swagger::class);
            if ($swaggerAnnotation === null || $swaggerAnnotation->showInDocs === false) continue;

            $path = explode('.', $route->getPath())[0];
            if (!isset($paths[$path])) $paths[$path] = array();

            // Prepare the data for the route.
            $allAnnotations = $reader->getMethodAnnotations($routeMethod);
            $routeData = array(
                "operationId" => $this->getOperationId($swaggerAnnotation, $this->extractControllerDefaultFromRoute($route)),
                "summary" => $swaggerAnnotation->description,
                "produces" => $swaggerAnnotation->produces,
                "consumes" => $swaggerAnnotation->consumes,
                "responses" => $this->createResponsesForRoute($allAnnotations),
                "parameters" => $this->createParametersForRoute($route, $allAnnotations),
            );

            if ($swaggerAnnotation->tags !== null) {
                $routeData["tags"] = $swaggerAnnotation->tags;
            }


            // Set the data for each method. Needed for when a route can handle multiple methods.
            foreach ($route->getMethods() as $method) {
                $paths[$path][strtolower($method)] = $routeData;
            }
        }

        return $paths;
    }
100564
public function execute()
    {
        try {
            // @ prepare hook
            $this->prepareExecute();

            // @ before event
            $this->triggerEvent('onControllerBeforeExecute', [
                'controller' => $this
            ]);

            // Prepare the last middleware, the last middleware is the real logic of this controller self.
            $chain = $this->getMiddlewareChain()->setEndMiddleware(function () {
                return $this->container->call([$this, 'doExecute'], [], $this);
            });

            // Do execute, run middlewares.
            $result = $chain->execute(new ControllerData(get_object_vars($this)));

            // @ post hook
            $result = $this->postExecute($result);

            // @ post event
            $this->triggerEvent('onControllerAfterExecute', [
                'controller' => $this,
                'result' => &$result,
            ]);
        } catch (ValidateFailException $e) {
            return $this->processFailure($e);
        } catch (\Exception $e) {
            // You can do some error handling in processFailure(), for example: rollback the transaction.
            $result = $this->processFailure($e);

            if (!$this->app->get('system.debug')) {
                return $result;
            }

            throw $e;
        } catch (\Throwable $t) {
            // You can do some error handling in processFailure(), for example: rollback the transaction.
            $this->processFailure(new \ErrorException(
                $t->getMessage(),
                $t->getCode(),
                E_ERROR,
                $t->getFile(),
                $t->getLine(),
                $t
            ));

            throw $t;
        }

        if ($result === false) {
            // You can do some error handling in processFailure(), for example: rollback the transaction.
            return $this->processFailure(new \Exception('Unknown Error'));
        }

        // Now we return result to package that it will handle response.
        return $this->processSuccess($result);
    }
471524
public function process()
    {
        // Your controller name
        $this->controller = Inflector::classify($this->argument('name')).'Controller';

        // By default we will generate basic controller, if resource set then we will generate
        // REST-ful Resource controller
        $this->setControllerType();

        try {
            $this->makeController();
        } catch (\Exception $e) {
            throw $e;
        }

        $this->info('Controller '.$this->controller.' Generated Successfully By Cygnite Cli.');
    }
646054
public function call() {
        $request = $this->createRequest();
        $response = $this->api->execute($request, $this);
        $this->response = $response;

        if ($this->shouldResponseBeProcessed($response)) {
            $instance = $this->api->instantiateResult($response, $this);

            return $instance;
        }
        return $response;
    }
737003
public function execute() {
        $request = $this->getRequest();
        if ($request->isAjax()) {
            return $this->resultJsonFactory->create()->setData([
                'payment_token' => $this->paymentTokenService->getToken()
            ]);
        }
    }
105973
public function start()
    {
        $this->beforeStart();

        // Begin output buffering and begin building the HTTP response
        $this->isBuffering = true;
        ob_start();

        $this->response = new Response();
        $this->context->registerInstance($this->response);

        try {
            // Dispatch the request to the router
            if (!$this->filters->trigger(Filters::BEFORE_ROUTE, $this->context)) {
                return $this->response;
            }

            $routingResult = $this->router->route($this->request);

            if ($routingResult != null) {
                $this->context->registerInstance($routingResult);
                $this->response->setResponseCode(ResponseCode::HTTP_OK);

                $returnValue = $this->dispatch($routingResult);

                // If a Response object was returned by the target code, use that object from now on
                if ($returnValue instanceof Response) {
                    if ($this->isBuffering) {
                        ob_clean();
                    }

                    $this->response = $returnValue;
                }
            } else {
                $anyOptionsAvailable = $this->router->getOptions($this->request);

                if (!$anyOptionsAvailable) {
                    // No options at all for this route, this is a true 404
                    $this->prepareNotFoundResponse();
                } else if ($this->request->getMethod() == RequestMethod::OPTIONS) {
                    // Options available, no custom OPTIONS handler, generate an OPTIONS ("Allow") response.
                    $this->prepareOptionsResponse();
                } else {
                    // There are options, but no match, this is a 405
                    $this->prepareNotAllowedResponse();
                }
            }

            $this->filters->trigger(Filters::AFTER_ROUTE, $this->context);
        } catch (\Exception $ex) {
            $this->prepareErrorResponse($ex);
        } finally {
            $this->sendResponse();
        }

        return $this->response;
    }
551929
final public function invoker()
    {
        $beforeCallEvent = $this->dispatchEvent(
            self::EVENT_BEFORE_CALL_METHOD,
            $this,
            ['request' => $this->getRequest()]
        );

        if ($beforeCallEvent->getResult() instanceof Response) {
            return $beforeCallEvent->getResult();
        }

        $response = call_user_func_array($this, func_get_args());

        $this->dispatchEvent(
            self::EVENT_AFTER_CALL_METHOD,
            $this,
            ['request' => $this->getRequest(), 'response' => $response]
        );

        return $response;
    }
543151
public function me()
    {
        $path = self::ME_PATH;

        $response = $this->execute($path, HttpVerb::GET, null);

        $result = null;
        if ($response->getCode() == 200) {
            $responseArray = $this->decodeData($response);
            $result        = $responseArray;
        } else {
            $this->handleError($response);
        }

        return $result;
    }
793161
public function run()
	{
		$query = $this->buildQuery();

		// Execute the query.
		$rawResults = $this->searcher->getClient()->search($query);

		// Pass response to the class that will do something with it.
		$resultParser = $this->getResultParser();
		$resultParser->setRawResults($rawResults);

		return $resultParser;
	}
241030
public function run()
    {
        if (is_null($this->compiledResult)) {
            $this->compiledResult = \preg_replace_callback(static::$rxp_token, array($this, 'formatCallback'), $this->format);
        }

        return $this->compiledResult;
    }
618224
public function process()
	{
		// Get this request's data.
		$this->parseRequest();

		// Perform logic.
		$this->execute();

		// Parse the result of our business logic.
		$this->parseResult();

		// Build the Response utilizing status, type, body, etc.
		$this->buildResponse();

		// Finally, return the Response.
		return $this->respond();
	}
899053
protected function getResult()
    {
        while ($this->result instanceof Promise && null !== $this->result->result)
        {
            $this->result = $this->result->result;
        }

        return $this->result;
    }
851514
protected function process()
    {
        // Uses the response object by default
        $this->result = $this->getRequest()->getResponse();

        $contentType = $this->result->getContentType();

        if (stripos($contentType, 'xml') === false) {
            throw new \Exception('The Response is not in a valid XML Content Type.');
        }

        $body = trim($this->result->getBody(true));
        $this->result = new EncodingResponse($body);

        $this->handleResponseErrors($this->result);
    }