@param DirectionRequestInterface $request

@return DirectionResponse
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;
    }
373691
public function run(RequestInterface $request) : ResponseInterface
    {
        $stack = array_reverse($this->stack);
        $handler = $this->resolve($stack, 0);
        return $handler->handle($request);
    }
71225
private function _dispatchRequest($request)
	{
		// track the number of requests across instances
		self::$requestCount++;
		$timestart = microtime(true);

		$response = self::transport()->send($request);

		// pass the response through the filter chain
		foreach($this->_filters as $filter)
		{
			$response = $filter->response($response);
		}

		$httpCode = $response->getStatus()->getCode();
		$location = $response->getHeaders()->value('Location');
		$body = $response->getBody();

		// track the time taken across instances
		self::$requestTime += microtime(true) - $timestart;

		// process a redirect if needed
		if($httpCode < 400 && $location)
		{
			return $this->_redirect($location);
		}
		else
		{
			$this->_redirects = 0;
		}

		// translate error code to a typed exception
		if($httpCode == 500)
		{
			throw new Error\InternalServerError($body);
		}
		elseif($httpCode == 400)
		{
			throw new Error\BadRequest($body);
		}
		elseif($httpCode == 401)
		{
			throw new Error\Unauthorized($body);
		}
		elseif($httpCode == 404)
		{
			throw new Error\NotFound($body);
		}
		else if($httpCode >= 300)
		{
			throw new Error($body,$httpCode);
		}

		return $response;
	}
629798
public function moveAction(Request $request)
    {
        if (!$request->isXmlHttpRequest()) {
            throw new NotFoundHttpException();
        }

        $folder = $this->findFolderById($request->attributes->get('id'));

        $result = [];
        $mode = $request->request->get('mode');

        if (!in_array($mode, array('before', 'after', 'over'))) {
            $result = array(
                'error'   => true,
                'message' => 'Unexpected creation mode.',
            );
        } else {
            $reference = $this->findFolderById($request->request->get('reference'));

            if ($mode === 'before') {
                $this->getFolderRepository()->persistAsPrevSiblingOf($folder, $reference);
            } elseif ($mode === 'after') {
                $this->getFolderRepository()->persistAsNextSiblingOf($folder, $reference);
            } elseif ($mode === 'over') {
                $this->getFolderRepository()->persistAsLastChildOf($folder, $reference);
            }
            $this->getEntityManager()->flush();
        }

        $response = new Response(json_encode($result, JSON_FORCE_OBJECT));
        $response->headers->add(array('Content-Type' => 'application/json'));
        return $response;
    }
1009634
public function wizard(ServerRequestInterface $request): ResponseInterface
    {
        $continue = $request->getQueryParams()['continue'] ?? '';

        $title = I18N::translate('Upgrade wizard');

        if ($continue === '1') {
            return $this->viewResponse('admin/upgrade/steps', [
                'steps' => $this->wizardSteps(),
                'title' => $title,
            ]);
        }

        return $this->viewResponse('admin/upgrade/wizard', [
            'current_version' => Webtrees::VERSION,
            'latest_version'  => $this->upgrade_service->latestVersion(),
            'title'           => $title,
        ]);
    }
1089221
public function receive(DispatcherRequestInterface $request)
    {
        //Set the headers
        $headers = array();
        foreach ($_SERVER as $key => $value)
        {
            if ($value && strpos($key, 'HTTP_') === 0)
            {
                // Cookies are handled using the $_COOKIE superglobal
                if (strpos($key, 'HTTP_COOKIE') === 0) {
                    continue;
                }

                $headers[substr($key, 5)] = $value;
            }
            elseif ($value && strpos($key, 'CONTENT_') === 0)
            {
                $name = substr($key, 8); // Content-
                $name = 'Content-' . (($name == 'MD5') ? $name : ucfirst(strtolower($name)));

                $headers[$name] = $value;
            }
        }

        $request->getHeaders()->add($headers);
    }
805805
public function postAdminAction(ServerRequestInterface $request): ResponseInterface
    {
        $this->setPreference('body', $request->get('body', ''));
        $this->setPreference('head', $request->get('head', ''));

        $message = I18N::translate('The preferences for the module “%s” have been updated.', $this->title());
        FlashMessages::addMessage($message, 'success');

        return redirect($this->getConfigLink());
    }
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);
        }
    }
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)));
    }
318357
public function dispatch(ServerRequestInterface $request)
    {
        $this->finalize();

        $dispatcher = new GroupCountBasedDispatcher($this->getData());
        $uri = '/'.ltrim($request->getUri()->getPath(), '/');

        return $dispatcher->dispatch($request->getMethod(), $uri);
    }
1350960
public function route(ServerRequestInterface $request)
    {

        /** @var Route[] $routes */
        $routes = array_reverse($this->routes);
        foreach ($routes as $route) {

            $path = $request->getUri()->getPath();
            $baseUri = $this->getOption('baseUri', '');

            $len = strlen($baseUri);
            if ($len > 0) {

                if (strncmp($baseUri, $path, $len) !== 0)
                    continue;

                $path = substr($path, $len);
            }

            if (empty($path))
                $path = '/';

            $vars = null;
            if (!in_array($request->getMethod(), $route->getMethods())
                || ($vars = $route->match($path)) === false)
                continue;

            $subRequest = $request;
            foreach ($vars as $key => $value)
                $subRequest = $subRequest->withAttribute($key, $value);

            $this->app->prepend(function($request, $response, $next) use ($route, $subRequest) {

                $handler = $this->app->prepareMiddleware($route->getHandler());
                return $handler($subRequest, $response, $next);
            });
        }

        return $this;
    }
253648
public function handle(ServerRequestInterface $request):ResponseInterface {
		$path = $request->getUri()->getPath();
// TODO: Abstract response type needed.
		$response = new PageResponse();

		try {
			$templateDirectory = implode(DIRECTORY_SEPARATOR, [
				$this->router->getBaseViewLogicPath(),
				"_component",
			]);
			$viewAssembly = $this->router->getViewAssembly($path);
			$view = $this->getView(
				$response->getBody(),
				(string)$viewAssembly,
				$templateDirectory,
				$path,
				$request->getHeaderLine("accept")
			);
		}
		catch(BasenameNotFoundException $exception) {
// TODO: Handle view not found.
			die("The requested view is not found!!!");
		}

		LogicFactory::setView($view);
		$baseLogicDirectory = $this->router->getBaseViewLogicPath();

		$logicAssembly = $this->router->getLogicAssembly($path);

		$logicObjects = $this->createLogicObjects(
			$logicAssembly,
			$baseLogicDirectory,
			$request->getUri()
		);

		$this->dispatchLogicObjects($logicObjects);
		$this->injectCsrf($view);
		$view->stream();

		return $response;
	}
99616
public function dispatch(SymfonyRequest $request)
    {
        if (! is_null($route = $this->findRoute($request))) {
            list($callback, $parameters) = $route;

            array_unshift($parameters, $request);

            return call_user_func_array($callback, $parameters);
        }
    }
613775
public function doRequest($request, $location, $action, $version, $one_way)
  {
    return $this->__doRequest($request, $location, $action, $version, $one_way);
  }
1221026
public function handle(ServerRequestInterface $request): ResponseInterface{
        $routing        = $this->getRouteCollector()
            ->router($request->getUri()->getHost(), $request->getMethod())
            ->search($request->getUri()->getPath())
        ;
        $handlerBuilder = $kernel->getRequestHandlerBuilder();

        if($routing->found){
            $method = $routing->data["action"]["method"];
            $object = $kernel->getContainer()->getInstance(
                $routing->data["action"]["class"]
            );
            $action = [$object, $method];

            if($object instanceof Bundle\MiddlewareRegisterInterface){
                $object->middlewareRegister($handlerBuilder);
            }
        }else{
            $action = function(){
                throw new \Fratily\Http\Message\Status\NotFound();
            };
        }

        return $handlerBuilder
            ->append(
                new Controller\ActionMiddleware($this->getContainer())
            )
            ->create(
                $kernel->getContainer()->has("kernel.responseFactory")
                    ? $kernel->getContainer()->get("kernel.responseFactory")
                    : new \Fratily\Http\Message\ResponseFactory()
            )
            ->handle(
                $request
                    ->withAttribute("action", $action)
                    ->withAttribute("routing", $routing)
                    ->withAttribute("kernel", $kernel)
                    ->withAttribute(
                        "environment",
                        $kernel->getConfig()->getEnvironment()
                    )
                    ->withAttribute(
                        "debug",
                        $kernel->getConfig()->isDebug()
                    )
            )
        ;
    }
788097
protected function doTransaction($request)
    {
        $response = $this->sendRequest('POST', '', $request);

        if (200 !== $response->statusCode) {
            throw new GatewayException(
                sprintf(
                    'Unexpected HTTP status code [%s]',
                    $response->statusCode
                )
            );
        }

        return $response->rawResponse;
    }
660679
public function apply($query, $column, $direction = 'asc')
    {
        $direction = $direction === 'desc' ? 'desc' : 'asc';

        $modelTable = $query->getModel()->getTable();
        $modelKey   = $query->getModel()->getKeyName();

        $query->orderBy("{$modelTable}.{$modelKey}", $direction);

        return $query;
    }