Handle the user request and return the JSON response (with pagination).

@param TableInterface $table
@param Request        $request

@return Response
320545
public function handleRequest(TableInterface $table, Request $request)
    {
        // execute query with filters
        $rows = $this->getRows($table, $request);

        // params for twig parts
        $twigParams = array(
            'table' => $table,
            'rows' => $rows,
        );

        $template = $this->twig->loadTemplate($table->getTemplate());

        $responseParams = array(
            'page' => $table->getPage(),
            'rowsPerPage' => $table->getRowsPerPage(),
            'totalRows' => $table->getTotalRows(),
            'filteredRows' => $table->getFilteredRows(),
            'lastPage' => $table->getLastPage(),
            'tableBody' => $template->renderBlock(
                'tableBody',
                array_merge($twigParams, array('tableRenderBody' => true), $table->getTemplateParams())
            ),
            //"tableFoot"=>$template->renderBlock("tableFoot", $twigParams),
            'tableStats' => $template->renderBlock(
                'tableStatsAjax',
                array_merge($twigParams, array('tableRenderStats' => true))
            ),
            'tablePagination' => $template->renderBlock(
                'tablePaginationAjax',
                array_merge($twigParams, array('tableRenderPagination' => true))
            ),
        );

        // encode response
        $response = new Response(json_encode($responseParams));

        return $response;
    }
97823
public function handle(ServerRequestInterface $request): ResponseInterface
    {
        $symfonyRequest = $this->httpFoundationFactory->createRequest($request);

        $symfonyResponse = $this->symfonyMiddleware->handle($symfonyRequest);

        return $this->httpMessageFactory->createResponse($symfonyResponse);
    }
1258478
public function processResourceRequestResponse(ResponseInterface $request)
    {
        $response = json_decode($request->getBody()->getContents());

        if (Response::HTTP_OK !== $request->getStatusCode() && Response::HTTP_CREATED !== $request->getStatusCode()) {
            return ExceptionHandler::handle(get_class($this), $response, $request->getStatusCode());
        }

        return (isset($response->data)) ? json_decode(json_encode($response->data), true) : json_decode(json_encode($response), true);
    }
388589
public function process(
        ServerRequestInterface $request,
        DelegateInterface $delegate
    ): JsonResponse {
        if (!$this->isAllowed->__invoke($request, 'sites', 'admin')) {
            return new JsonResponse(['error' => 'unauthorized'], 401);
        }

        $sectionName = $request->getAttribute('sectionName');

        try {
            $settings = $this->getSection->__invoke(
                $this->currentSite,
                $sectionName
            );
        } catch (InvalidSectionNameException $e) {
            return new JsonResponse(['error' => 'invalid section name'], 400);
        }

        if ($settings === null) {
            return new JsonResponse(['error' => 'settings not found'], 404);
        }

        return new JsonResponse($settings);
    }
1159471
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        $response = $handler->handle($request);
        $code = $response->getStatusCode();
        $allowedCodes = array_keys($this->renderer) + array_keys($this->defaultErrors);
        if (in_array($code, $allowedCodes)) {
            if (!$response->getBody()->getSize()) {
                $format = FormatNegotiator::getPreferredFormat($request);

                if (isset($this->renderer[$code])) {
                    $content = $this->renderer[$code]($format);
                } else {
                    $content = $this->defaultRenderer($code, $format);
                }

                if (is_array($content)) {
                    $content = json_encode($content);
                }

                $body = $this->streamFactory->createStream($content);

                $response = $response->withBody($body);
                $response = $response->withStatus($code);

                if ($format === 'json') {
                    $response = $response->withHeader('content-type', 'application/json');
                } else {
                    $response = $response->withHeader('content-type', 'text/html; charset=utf-8');
                }
            }
        }

        return $response;
    }
1104085
public function handle(ServerRequestInterface $request): ResponseInterface
    {
        $this->request = $request;
        $response = (new HttpFactory())->createResponse();
        $response = $response->withHeader('Content-Type', 'text/html');
        $pathInfo = RequestHelper::getPathInfo($request);

        try {
            $controller = $this->resolveController($pathInfo);
            $mixed = $this->executeAction($controller);
        } catch (\Throwable $t) {
            // handle errors with built-in error controller
            $controller = new ErrorController($this->view, $request, 'error/error');
            $controller->setError($t);
            $mixed = $this->executeAction($controller);
            $response = $response->withStatus($t->getCode());
        }

        if (is_array($mixed)) {
            $response = $response->withHeader('Content-Type', 'application/json');
            $response->getBody()->write(json_encode($mixed));
        } elseif (is_string($mixed)) {
            $response->getBody()->write($mixed);
        } else {
            throw new \Exception('Unsupported content type');
        }

        return $response;
    }
289208
public function exportAsCsv(TableInterface $table, Request $request)
    {
        // execute query with filters, without pagination, only scalar results
        $rows = $this->getRows($table, $request, false, false);

        $buffer = '';
        // first line: keys
        if (count($rows) > 0) {
            foreach ($table->getColumns() as $column) {
                $buffer .= $column->getName().';';
            }
            $buffer .= "\n";
        }

        foreach ($rows as $row) {
            foreach ($table->getColumns() as $column) {
                $buffer .= $column->getExportValue($row, $rows).';';
            }
            $buffer .= "\n";
        }

        return $buffer;
    }
1316945
private function query(RequestInterface $request)
    {
        return $this->client->send($request, array_merge(
            [RequestOptions::HTTP_ERRORS => false],
            $this->clientOptions
        ));
    }
1282571
public function handle(RequestInterface $request)
    {
        $index = 0;

        while ($this->canSetNextCore($index)) {
            $this->middlewares[$index]->setNextCore($this->middlewares[$index + 1]);
            ++$index;
        }

        return $this->middlewares[0]->handle($request);
    }
338544
public function handle(
        ServerRequestInterface $request, ResponseInterface $response
    )
    {
        $path = array_key_exists(self::QUERY_PARAM, $request->getQueryParams())
            ? $request->getQueryParams()[self::QUERY_PARAM]
            : '';
        $uri = Uri::create($request->getUri());
        $queryString = ltrim(
            str_replace(
                self::QUERY_PARAM."={$path}",
                '',
                $uri->getQuery()
            ),
            '&'
        );
        $uri = $uri->withPath(str_replace('//', '/', "/$path"))
            ->withQuery($queryString);
        /** @var ServerRequestInterface $request */
        $request = $request->withUri($uri);
        return $this->executeNext($request, $response);
    }
18234
public function visitTable(TableInterface $table)
    {
        $template = 'table/base.twig';

        $filters = [];
        for ($thisFilter = $table->getFilter(); $thisFilter !== null; $thisFilter = $thisFilter->getNextFilter()) {
            $filters[] = $thisFilter;
        }

        return $this
            ->loadTemplate($template)
            ->render(
                [
                    "id" => $table->getId(),
                    "classes" => $table->getClasses(),
                    "data" => $table->getData(),
                    "rows" => $table->getRows(),
                    "filters" => $filters,
                ]
            );
    }
517429
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        return $this->execute([$request, $handler]);
    }
1300755
public function handle(ServerRequestInterface $request): ResponseInterface
    {
        $storageless = $request->getAttribute(SessionMiddleware::SESSION_ATTRIBUTE);

        $session = new Session($storageless);

        $request = $request->withAttribute(SessionInterface::class, $session);

        return $this->handler->handle($request);
    }
1371067
public function request(RequestInterface $request)
    {
        $uri = $request->getUri()
            ->withPath('')
            ->withQuery('')
            ->withFragment('');

        $uri = $uri . $request->getRequestTarget();

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

        return $this->doRequest($request);
    }
261021
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        $response = $handler->handle($request);
        $response = $this->responseView($request, $response);

        return $response;
    }
1058794
public function handle(ServerRequestInterface $request): ResponseInterface
        {
            if (!isset($this->middleware[$this->index])) {
                return $this->response;
            }
    
            $middleware = $this->middleware[$this->index];
            return $middleware->process($request, $this->next());
        }
353341
public function handle(ServerRequestInterface $request): ResponseInterface
    {
        if (false === $this->booted) {
            $this->boot();
        }

        try {
            return $this->pipe->handle($request);
        } catch (Exception $e) {
            $this->getContainer()->get('logger')->error($e);
        }
    }