Store the request context for a given request.

@param \Psr\Http\Message\ServerRequestInterface $request The request instance.
@return void
@throws \InvalidArgumentException When parameter is an incorrect type.
543344
public static function setRequestContext(ServerRequestInterface $request)
    {
        $uri = $request->getUri();
        static::$_requestContext = [
            '_base' => $request->getAttribute('base'),
            '_port' => $uri->getPort(),
            '_scheme' => $uri->getScheme(),
            '_host' => $uri->getHost(),
        ];
    }
764260
protected function overviewAction(ServerRequestInterface $request)
    {
        $this->getButtons();
        $demand = Demand::createFromRequest($request);
        $redirectRepository = GeneralUtility::makeInstance(RedirectRepository::class, $demand);
        $count = $redirectRepository->countRedirectsByByDemand();

        $this->view->assignMultiple([
            'redirects' => $redirectRepository->findRedirectsByDemand(),
            'hosts' => $redirectRepository->findHostsOfRedirects(),
            'statusCodes' => $redirectRepository->findStatusCodesOfRedirects(),
            'demand' => $demand,
            'defaultUrl' => GeneralUtility::makeInstance(UrlService::class)->getDefaultUrl(),
            'showHitCounter' => GeneralUtility::makeInstance(Features::class)->isFeatureEnabled('redirects.hitCount'),
            'pagination' => $this->preparePagination($demand, $count),
        ]);
    }
865754
private function get(ServerRequestInterface $request)
    {
        $middleware = current($this->middleware);
        next($this->middleware);

        if ($middleware === false) {
            return $middleware;
        }

        if (is_array($middleware)) {
            $conditions = $middleware;
            $middleware = array_pop($conditions);

            foreach ($conditions as $condition) {
                if ($condition === true) {
                    continue;
                }

                if ($condition === false) {
                    return $this->get($request);
                }

                if (is_string($condition)) {
                    $condition = new Matchers\Path($condition);
                } elseif (!is_callable($condition)) {
                    throw new InvalidArgumentException('Invalid matcher. Must be a boolean, string or a callable');
                }

                if (!$condition($request)) {
                    return $this->get($request);
                }
            }
        }

        if (is_string($middleware)) {
            if ($this->container === null) {
                throw new InvalidArgumentException(sprintf('No valid middleware provided (%s)', $middleware));
            }

            $middleware = $this->container->get($middleware);
        }

        if ($middleware instanceof Closure) {
            return self::createMiddlewareFromClosure($middleware);
        }

        if ($middleware instanceof MiddlewareInterface) {
            return $middleware;
        }

        throw new InvalidArgumentException(sprintf('No valid middleware provided (%s)', is_object($middleware) ? get_class($middleware) : gettype($middleware)));
    }
1256533
public function dispatch(ServerRequestInterface $request) : array
    {
        $uri = $request->getUri()->getPath();
        if (! $uri || $uri[0] !== '/') {
            $uri = '/' . $uri;
        }

        return $this->createDispatcher()->dispatch(
            $request->getMethod(),
            $uri
        );
    }
744087
public function modify(ServerRequestInterface $request) : ServerRequestInterface
    {
        /** @var ServerRequestModifierInterface $modifier */
        foreach ($this->collection as $modifier) {
            $request = $modifier->modify($request);
        }

        return $request;
    }
1126054
public function store(Request $request)
    {
        $data = $request->all();
        return $this->processor->store($this, $data);
    }
1158094
public static function setRequest(RequestInterface $request)
    {
        $fd = self::getFdByCoId();

        self::$connections[$fd][self::REQUEST_KEY] = $request;
    }
1287849
public function store(SettingRequest $request)
    {
        $this->setting->setFromRequest($request->request->all());

        flash(trans('core::messages.resource.resource saved', ['name' => trans('setting::setting.title.settings')]));

        return redirect()->back();
    }
1372926
public function store(Request $request)
    {
        $type = $request->get('type');

        return $this->manager()->{$type}()->store($request->all());
    }
502390
protected function processGroups(ServerRequestInterface $request) : void
    {
        $activePath = $request->getUri()->getPath();

        foreach ($this->groups as $key => $group) {
            // we want to determine if we are technically in a group even if the
            // route is not matched so exceptions are handled correctly
            if (strncmp($activePath, $group->getPrefix(), strlen($group->getPrefix())) === 0
                && ! is_null($group->getStrategy())
            ) {
                $this->setStrategy($group->getStrategy());
            }

            unset($this->groups[$key]);
            $group();
        }
    }
557757
public function handle(ServerRequestInterface $request)
    {
        if (null !== ($ssid = input()->get('ssid')) && services()->has('user')) {
            if (services()->get('user')->validate($ssid)) {
                set_cookie('ssid', $ssid);

                echo services()->get('user')->getIframeScript();
                exit(EXIT_SUCCESS);
            }
        }
    }
154492
private function input(ServerRequestInterface $request): array
    {
        if (! is_null($this->parser)) {

            $input = ($this->parser)($request);

            if (is_array($input)) {

                return $input;

            }

            throw new InputTypeException($input);

        }

        return array_merge(
            $request->getAttributes(),
            $request->getQueryParams(),
            $request->getParsedBody(),
            $request->getUploadedFiles()
        );
    }
719795
public function handle(ServerRequestInterface $request)
    {
        // Try to get from cache
        $cacheKey = 'o2output_' . underscore(server_request()->getUri()->getSegments()->getString());

        $cacheHandle = cache()->getItemPool('default');

        if (cache()->hasItemPool('output')) {
            $cacheHandle = cache()->getItemPool('output');
        }

        if ($cacheHandle instanceof \Psr\Cache\CacheItemPoolInterface) {
            if ($cacheHandle->hasItem($cacheKey)) {
                output()
                    ->setContentType('text/html')
                    ->send($cacheHandle->getItem($cacheKey)->get());
            }
        }
    }
1207049
public function preferencesSave(ServerRequestInterface $request): ResponseInterface
    {
        $INDEX_DIRECTORY = $request->get('INDEX_DIRECTORY');
        if (substr($INDEX_DIRECTORY, -1) !== '/') {
            $INDEX_DIRECTORY .= '/';
        }
        if (File::mkdir($INDEX_DIRECTORY)) {
            Site::setPreference('INDEX_DIRECTORY', $INDEX_DIRECTORY);
        } else {
            FlashMessages::addMessage(I18N::translate('The folder %s does not exist, and it could not be created.', e($INDEX_DIRECTORY)), 'danger');
        }

        Site::setPreference('THEME_DIR', $request->get('THEME_DIR'));
        Site::setPreference('ALLOW_CHANGE_GEDCOM', (string) (bool) $request->get('ALLOW_CHANGE_GEDCOM'));
        Site::setPreference('TIMEZONE', $request->get('TIMEZONE'));

        FlashMessages::addMessage(I18N::translate('The website preferences have been updated.'), 'success');
        $url = route('admin-control-panel');

        return redirect($url);
    }
23732
public function getOptions(ServerRequestInterface $request): void
    {
        parent::getOptions($request);

        $this->surname = $request->get('surname', 'replace');
    }
35590
protected function setDataFromRequest(RequestInterface $request)
    {
        $keys = $this->validDataFromRequest();
        $data = $request->getParams($keys);

        if (isset($data['obj_type'])) {
            $this->objType = $data['obj_type'];
        }

        if (isset($data['obj_id'])) {
            $this->objId = $data['obj_id'];
        }

        if (isset($data['property'])) {
            $this->propertyIdent = $data['property'];
        }

        return $this;
    }
959031
private function withDecryptedCookies(ServerRequestInterface $request): ServerRequestInterface
    {
        $cookies = $request->getCookieParams();

        $decrypted = [];
        foreach ($cookies as $name => $value) {
            $decrypted[$name] = in_array($name, $this->bypassed) ? $value : $this->decrypt($value);
        }

        return $request->withCookieParams($decrypted);
    }