action for routing all requests directly to the third party API

@param Request $request request

@return \Psr\Http\Message\ResponseInterface|Response
978359
public function proxyAction(Request $request)
    {
        $api = $this->decideApiAndEndpoint($request->getUri());
        $this->registerProxySources($api['apiName']);
        $this->apiLoader->addOptions($api);

        $url = new Uri($this->apiLoader->getEndpoint($api['endpoint'], true));

        if ($url->getScheme() === null) {
            $url = $url->withScheme($request->getScheme());
        }

        $response = null;
        try {
            $newRequest = Request::create(
                (string) $url,
                $request->getMethod(),
                [],
                [],
                [],
                [],
                $request->getContent(false)
            );
            $newRequest->headers->add($request->headers->all());
            $newRequest->query->add($request->query->all());

            $newRequest = $this->transformationHandler->transformRequest(
                $api['apiName'],
                $api['endpoint'],
                $request,
                $newRequest
            );

            $psrRequest = $this->psrHttpFactory->createRequest($newRequest);

            $psrRequestUri = $psrRequest->getUri();
            $psrRequestUriPort = $url->getPort();
            if (is_numeric($psrRequestUriPort) || is_null($psrRequestUriPort)) {
                $psrRequestUri = $psrRequestUri->withPort($psrRequestUriPort);
            }

            $psrRequest = $psrRequest->withUri($psrRequestUri);

            $psrResponse = $this->proxy->forward($psrRequest)->to($this->getHostWithScheme($url));
            $response = $this->httpFoundationFactory->createResponse($psrResponse);
            $this->cleanResponseHeaders($response->headers);
            $this->transformationHandler->transformResponse(
                $api['apiName'],
                $api['endpoint'],
                $response,
                clone $response
            );
        } catch (ClientException $e) {
            $response = (new HttpFoundationFactory())->createResponse($e->getResponse());
        } catch (ServerException $serverException) {
            $response = (new HttpFoundationFactory())->createResponse($serverException->getResponse());
        } catch (TransformationException $e) {
            $message = json_encode(
                ['code' => 404, 'message' => 'HTTP 404 Not found']
            );

            throw new NotFoundHttpException($message, $e);
        } catch (RequestException $e) {
            $message = json_encode(
                ['code' => 404, 'message' => 'HTTP 404 Not found']
            );

            throw new NotFoundHttpException($message, $e);
        }

        return $response;
    }
347723
public function allAction(Request $request)
    {
        $model = $this->getModel();

        $content = $this->restUtils->serialize($model->findAll($request));

        $response = $this->getResponse()
            ->setStatusCode(Response::HTTP_OK)
            ->setContent($content);

        return $response;
    }
1181851
public function indexAction(Request $request)
    {
        /** @var HttpErrorRepository $errorRepository */
        $errorRepository = $this->getDoctrine()->getManager()->getRepository('VictoireSeoBundle:HttpError');

        // Fetch errors

        $routes = $errorRepository->getRouteErrors();
        $routesResults = $routes->getQuery()->getResult();

        $files = $errorRepository->getFileErrors();
        $filesResults = $files->getQuery()->getResult();

        // Build forms

        $forms = [];
        $errors = array_merge($routesResults, $filesResults);

        /** @var Error404 $error */
        foreach ($errors as $error) {
            $redirection = new ErrorRedirection();
            $redirection->setError($error);
            $forms[$error->getId()] = $this->getError404RedirectionForm($redirection)->createView();
        }

        // Return datas

        return new Response($this->renderView('@VictoireSeo/Error404/index.html.twig', [
            'routes' => $routesResults,
            'files'  => $filesResults,
            'forms'  => $forms,
        ]));
    }
1341979
protected function handle($request)
    {
        $this->authorize($request, $this->repository()->getClassName());

        $qb = $this->repository()->sourceQueryBuilder($request);
        $this->applyPagination($request, $qb);
        $this->applyFilter($request, $qb);

        return $this->response()->resource($request, $this->prepareCollection($request, $qb));
    }
654434
public function toResponse($request)
    {
        return tap(response()->json(
            $this->wrap(
                $this->resource->resolve($request),
                array_merge_recursive(
                    $this->paginationInformation($request),
                    $this->resource->with($request),
                    $this->resource->additional
                )
            ),
            $this->calculateStatus()
        ), function ($response) use ($request) {
            $response->original = $this->resource->resource->pluck('resource');

            $this->resource->withResponse($request, $response);
        });
    }
424130
public function handleRequest($request)
    {
        list ($route, $params) = $request->resolve();
        $this->requestedRoute = $route;
        $result = $this->runAction($route, $params);
        if ($result instanceof Response) {
            return $result;
        } else {
            $response = $this->getResponse();
            $response->exitStatus = $result;

            return $response;
        }
    }
875365
public function handle(Request $request)
    {
        try {
            $restRequest = new RestRequest($this->config, $request->getMethod(), $request->getUri(), $request->getContent());
            $restResponse = $this->adapter->processRequest($restRequest);
        } catch (\Exception $e) {
            if (true === $this->debugEnabled()) {
                throw $e;
            }
            $restResponse = $this->adapter->handleException($e);
        }
        return new Response($restResponse->getContent(), $restResponse->getStatus(), $restResponse->getHeaders());
    }
211225
public function run(Request $request) {
    // process the requested action
    ObjectFactory::getInstance('actionMapper')->processAction($request, $this->response);
    return $this->response;
  }
1145697
public function send(Request $request): Response
    {
        $this->serialInterface->send($request->encode());
        return $this->receiveResponse($request->getTimeout());
    }
74123
public function markAllAsReadAction(Request $request): Response
    {
        $configuration = $this->requestConfigurationFactory->create($this->metadata, $request);
        $this->isGrantedOr403($configuration, ResourceActions::UPDATE);

        $this->messageManager->markAllAsRead($this->getUser());

        if (!$configuration->isHtmlRequest()) {
            return $this->viewHandler->handle($configuration, View::create(null, Response::HTTP_NO_CONTENT));
        }

        $this->flashHelper->addSuccessFlash($configuration, ResourceActions::UPDATE);

        return $this->redirectHandler->redirectToIndex($configuration);
    }
559072
protected function sendRequestThroughRouter($request)
    {
        $this->app->bootApplication($request);
        $this->pipeline = new Pipeline($this->container);

        return $this->pipeline
            ->send($request)
            ->through($this->parseMiddlewareToPipelines($this->getMiddleware()), 'handle')
            ->then($this->dispatchToRouter())
            ->run();
    }
965849
public function indexDataAction(Request $request)
        {

            $aRemoteApps = RemoteAppQuery::create()->find();
            $sResult     = $this->renderView('SlashworksAppBundle:RemoteApp:data.json.twig', array(
                'entities' => $aRemoteApps,
            ));

            $response = new Response($sResult);
            $response->headers->set('Content-Type', 'application/json');

            return $response;

        }
249953
private function handle(Request $request) : Response
    {
        $router = $this->getInstance(Router::class);

        if ($router->match($request->getPathInfo(), $request->getMethod())) { // A match has been found
            /** @var Route $match */
            $match = $router->getMatch();

            // Check if the handler is a closure or not
            $handler = $match->getHandler();

            if (is_object($handler) && $handler instanceof \Closure) {
                try {
                    $content = $this->resolveClosure($handler);
                } catch (\Exception $e) {
                    if (DEVELOPMENT) {
                        showPlainError('Something went wrong while resolving a closure, details below:', false);
                        pr($e);
                        exit;
                    }

                    return $this->respond(500);
                }
            } else {
                $controller = substr($handler, 0, stripos($handler, '.'));
                $method = substr($handler, (stripos($handler, '.') + 1));

                try {
                    $instance = $this->getInstance($controller);
                    if (method_exists($instance, 'setCrispySystem')) {
                        $instance->setCrispySystem($this);
                    }
                    $content = $this->resolveMethod($instance, $method, $match->getParameters());
                } catch (\Exception $e) {
                    if (DEVELOPMENT) {
                        showPlainError('Something went wrong while resolving a controller, details below:', false);
                        pr($e);
                        exit;
                    }

                    return $this->respond(500);
                }
            }

            return $this->respond(200, $content);
        }

        // No match found
        return $this->respond(404);
    }
493942
public function dispatch($request = null)
    {
        $this->boot();

        list($method, $pathInfo) = $this->parseIncomingRequest($request);

        try {
            return $this->sendThroughPipeline($this->middleware, function () use ($method, $pathInfo) {
                if (isset($this->router->getRoutes()[$method.$pathInfo])) {
                    return $this->handleFoundRoute([true, $this->router->getRoutes()[$method.$pathInfo]['action'], []]);
                }

                return $this->handleDispatcherResponse(
                    $this->createDispatcher()->dispatch($method, $pathInfo)
                );
            });
        } catch (Throwable $e) {
            return $this->prepareResponse($this->sendExceptionToHandler($e));
        }
    }
779020
public function route(DirectionRequestInterface $request)
    {
        $httpRequest = $this->createRequest($request);
        $httpResponse = $this->getClient()->sendRequest($httpRequest);

        $response = $this->deserialize(
            $httpResponse,
            DirectionResponse::class,
            (new Context())->setNamingStrategy(new SnakeCaseNamingStrategy())
        );

        $response->setRequest($request);

        return $response;
    }
11158
protected function send(Request $request)
    {
        try {
            $response = $this->client->send($request);
        } catch (ClientException $e) {
            $response = $e->getResponse();
        } catch (ServerException $e) {
            $response = $e->getResponse();
        }

        return $response;
    }
1013706
public function dispatch(Request $request) {

        $uri = $request->uri();
        $method = $request->method();

        if (in_array($uri, self::$routes)) {
            if (self::$methods[$uri] == $method || self::$methods[$uri] == 'ANY') {
                if (is_object(self::$callbacks[$uri])) {
                     call_user_func(self::$callbacks[$uri]);
                } else {
                    $s = explode('@', self::$callbacks[$uri]);
                    call_user_func(array((new $s[0]), $s[1]));
                }
            }
        } else {
            header($_SERVER['SERVER_PROTOCOL']." 404 Not Found");
            echo '404';
        }
    }