@param ServerRequestInterface $request

@return ResponseInterface
160993
public function updateBlocks(ServerRequestInterface $request): ResponseInterface
    {
        $modules = $this->module_service->findByInterface(ModuleBlockInterface::class, true);

        $this->updateStatus($modules, $request);
        $this->updateAccessLevel($modules, ModuleBlockInterface::class, $request);

        return redirect(route('blocks'));
    }
902862
public function updateThemes(ServerRequestInterface $request): ResponseInterface
    {
        $modules = $this->module_service->findByInterface(ModuleThemeInterface::class, true);

        $this->updateStatus($modules, $request);

        return redirect(route('themes'));
    }
939406
protected function generate404(ServerRequestInterface $request): ResponseInterface
    {
        if ($this->default404 !== null) {
            if (\is_callable($this->default404)) {
                return \call_user_func_array($this->default404, [$request, [$this, 'handle']]);
            } elseif ($this->default404 instanceof MiddlewareInterface) {
                return $this->default404->process($request, $this);
            } elseif (\is_string($this->default404)) {
                $default404Instance = (new $this->default404());
                if (\method_exists($default404Instance, 'process')) {
                    return $default404Instance->process($request, $this);
                }
            }

            throw new RouterException('The default404 is invalid');
        }
        throw new RouterException('No route found to dispatch');
    }
1174050
public function updateReports(ServerRequestInterface $request): ResponseInterface
    {
        $modules = $this->module_service->findByInterface(ModuleReportInterface::class, true);

        $this->updateStatus($modules, $request);
        $this->updateAccessLevel($modules, ModuleReportInterface::class, $request);

        return redirect(route('reports'));
    }
982709
public function process(ServerRequestInterface $request)
    {
        $middleware = $this->getMiddleware();
        ++$this->index;

        //When all saved middleware were called
        if (null === $middleware) {
            return $this->response;
        }
        if ($middleware instanceof MiddlewareInterface) {
            return $middleware->process($request, $this);
        }
    }
1113074
public function handleRequest(ServerRequestInterface $request)
    {
        $requestBody = (array) $request->getParsedBody();

        // Set debug mode
        $this->debugMode = isset($requestBody['custom_debug']) && (strtolower($requestBody['custom_debug']) == 'true');

        // Set return URL if available
        if (isset($requestBody['launch_presentation_return_url'])) {
            $this->returnUrl = $requestBody['launch_presentation_return_url'];
        } else if (isset($requestBody['content_item_return_url'])) {
            $this->returnUrl = $requestBody['content_item_return_url'];
        }

        // Perform action
        if ($this->authenticate($request)) {
            $this->doCallback($requestBody);
        }

        $this->result();
    }
93745
public function respond(ServerRequest $request)
    {
        try
        {
            $response = $this->request($request)
                ->finalize()
                ->getResponse();
        }
        catch(\Exception $e)
        {
            if($failRoute = $this->failRoute)
            {
                $response = $this->execute($failRoute, array('exception' => $e, 'request' => $request), $request)
                    ->finalize()
                    ->getResponse();

                $this->failRoute = null;
            }
            else if($this->map->hasFailRoute())
            {
                $response = $this->execute($this->map->getFailRoute(), array('exception' => $e, 'request' => $request), $request)
                    ->finalize()
                    ->getResponse();
            }
            else
            {
                $message = '<pre><h2>['.get_class($e).'] '.$e->getMessage().'</h2>'.PHP_EOL;
                $message .= $e->getTraceAsString();

                $response = Response::createEmptyResponse()
                    ->setStatus(404)
                    ->setBody($message);
            }
        }

        return $response;
    }
1293086
public function handle(ServerRequestInterface $request): ResponseInterface
    {
        if (!isset($this->middlewaresInPipe[$this->currentMiddlewareInPipeIndex])) {
            return $this->generate404($request);
        }

        $middleware = $this->getMiddlewareInPipe();
        if (\is_callable($middleware)) {
            return \call_user_func_array($middleware, [$request, [$this, 'handle']]);
        } elseif ($middleware instanceof MiddlewareInterface) {
            return $middleware->process($request, $this);
        } elseif (\is_string($middleware)) {
            $middlewareInstance = (new $middleware());
            if (\method_exists($middlewareInstance, 'process')) {
                return $middlewareInstance->process($request, $this);
            }
        } elseif ($middleware instanceof self) {
            if ($middleware->findRouteRequest($request)) {
                return $middleware->dispatch($request);
            }

            return $this->handle($request);
        }
        throw new RouterException(\sprintf('Middleware is invalid: %s', \gettype($middleware)));
    }
327096
public function handle(ServerRequestInterface $request): ResponseInterface
    {
        if (empty($this->handler)) {
            throw new HttpException("Unable to run HttpCore, no handler is set.");
        }

        return $this->pipeline->withHandler($this->handler)->handle($request);
    }
1252094
public function onRequest(ServerRequestInterface $request)
    {
        if ($this->isPopulateServer()) {
            $this->prepareEnvironment($request);
        }

        $remoteIp = $request->getHeaderLine('X-PHP-PM-Remote-IP');
        $remotePort = $request->getHeaderLine('X-PHP-PM-Remote-Port');

        $request = $request->withoutHeader('X-PHP-PM-Remote-IP');
        $request = $request->withoutHeader('X-PHP-PM-Remote-Port');

        $request = $request->withAttribute('remote_address', $remoteIp);
        $request = $request->withAttribute('remote_port', $remotePort);

        $logTime = date('d/M/Y:H:i:s O');

        $catchLog = function ($e) {
            console_log((string) $e);
            return new Response(500);
        };

        try {
            $response = $this->handleRequest($request);
        } catch (\Throwable $t) {
            $response = $catchLog($t);
        }

        $promise = new Promise(function ($resolve) use ($response) {
            return $resolve($response);
        });

        $promise = $promise->then(function (ResponseInterface $response) use ($request, $logTime, $remoteIp) {
            if ($this->isLogging()) {
                $this->logResponse($request, $response, $logTime, $remoteIp);
            }
            return $response;
        });

        return $promise;
    }
288123
public function update(ServerRequestInterface $request): ResponseInterface
    {
        $modules = $this->module_service->all(true);

        foreach ($modules as $module) {
            $new_status = (bool) ($request->getParsedBody()['status-' . $module->name()] ?? false);
            $old_status = $module->isEnabled();

            if ($new_status !== $old_status) {
                DB::table('module')
                    ->where('module_name', '=', $module->name())
                    ->update(['status' => $new_status ? 'enabled' : 'disabled']);

                if ($new_status) {
                    FlashMessages::addMessage(I18N::translate('The module “%s” has been enabled.', $module->title()), 'success');
                } else {
                    FlashMessages::addMessage(I18N::translate('The module “%s” has been disabled.', $module->title()), 'success');
                }
            }
        }

        return redirect(route('modules'));
    }
1012360
public function handle(ServerRequestInterface $request): ResponseInterface
    {
        if(isset($this->middlewares[$this->index]))
        {
            $middleware = $this->middlewares[$this->index];
            if($middleware instanceof RequestHandlerInterface)
            {
                $requestHandler = $middleware;
            }
            else
            {
                $requestHandler = RequestContext::getServerBean($middleware);
            }
        }
        else
        {
            return RequestContext::get('response');
        }
        return $requestHandler->process($request, $this->next());
    }
744087
public function modify(ServerRequestInterface $request) : ServerRequestInterface
    {
        /** @var ServerRequestModifierInterface $modifier */
        foreach ($this->collection as $modifier) {
            $request = $modifier->modify($request);
        }

        return $request;
    }
426552
public function handleRequest(ServerRequestInterface $request)
    {
        try {
            $this->add('request', $request);

            return $this->get('dispatcher')->dispatch($request);
        } catch (Exception $exception) {
            return $this->handleException($exception);
        } catch (Throwable $exception) {
            $exception = new FatalThrowableError($exception);

            return $this->handleException($exception);
        }
    }
437413
public function handle(ServerRequestInterface $request): ResponseInterface
    {
        $middleware = array_shift($this->middleware);

        // Use default callable if there is no middleware.
        if ($middleware === null) {
            return \call_user_func($this->handler, $request);
        }

        if ($middleware instanceof MiddlewareInterface) {
            return $middleware->process($request, clone $this);
        }

        if (null === $this->container || !$this->container->has($middleware)) {
            throw new InvalidArgumentException(
                sprintf('The middleware is not a valid %s and is not passed in the Container', MiddlewareInterface::class),
                $middleware
            );
        }

        array_unshift($this->middleware, $this->container->get($middleware));

        return $this->handle($request);
    }
53043
public function handle(ServerRequestInterface $request): ResponseInterface
    {
        try {
            $route = $this->matchRoute($request);
        } catch (RouteException $e) {
            throw new RouterException("Invalid route definition", $e->getCode(), $e);
        }

        if (empty($route)) {
            throw new RouteNotFoundException($request->getUri());
        }

        return $this->container->get(ScopeInterface::class)->runScope(
            [RouteInterface::class => $route],
            function () use ($route, $request) {
                return $route->handle($request);
            }
        );
    }
228430
public function updateLanguages(ServerRequestInterface $request): ResponseInterface
    {
        $modules = $this->module_service->findByInterface(ModuleLanguageInterface::class, true);

        $this->updateStatus($modules, $request);

        return redirect(route('languages'));
    }