@param \swoole_http_request $swooleRequest

@return array
196443
private function transformHeader(\swoole_http_request $swooleRequest)
    {
        $headers = array();
        foreach ($swooleRequest->header as $name => $value) {
            $headers[ strtr(ucwords(strtr($name, array('-' => ' '))), array(' ' => '-')) ] = $value;
        }

        return $headers;
    }
1126436
public function toArray($request)
    {
        return [
            'code'       => $this->code,
            'i18n'       => $this->i18n,
            'is_enabled' => (bool) $this->is_enabled,
            'is_default' => (bool) $this->is_default,
        ];
    }
75725
private function transformUri(\swoole_http_request $swooleRequest)
    {
        //Scheme
        if (isset($swooleRequest->header['x-forwarded-proto'])) {
            $scheme = $swooleRequest->header['x-forwarded-proto'];
        } elseif (isset($swooleRequest->server['https']) && 'off' !== $swooleRequest->server['https']) {
            $scheme = 'https';
        } else {
            $scheme = 'http';
        }

        //Host
        if (isset($swooleRequest->header['x-forwarded-host'])) {
            $hostAndPort = $swooleRequest->header['x-forwarded-host'];
        } elseif (isset($swooleRequest->header['host'])) {
            $hostAndPort = $swooleRequest->header['host'];
        } else {
            $hostAndPort = 'localhost';
        }

        //requestUri
        if (isset($swooleRequest->server['request_uri'])) {
            $path = $swooleRequest->server['request_uri'];
        } else {
            $path = '/';
        }

        $uri = $scheme.'://'.$hostAndPort.$path;
        if (isset($swooleRequest->server['query_string'])) {
            $uri .= '?'.$swooleRequest->server['query_string'];
        }

        return $uri;
    }
307722
public function getCalledListeners(/* Request $request = null */)
    {
        if (null === $this->callStack) {
            return [];
        }

        $hash = 1 <= \func_num_args() && null !== ($request = \func_get_arg(0)) ? spl_object_hash($request) : null;
        $called = [];
        foreach ($this->callStack as $listener) {
            list($eventName, $requestHash) = $this->callStack->getInfo();
            if (null === $hash || $hash === $requestHash) {
                $called[] = $listener->getInfo($eventName);
            }
        }

        return $called;
    }
739465
private function getEcommerceItemsFromRequest(Request $request)
    {
        $items = $request->getParam('ec_items');

        if (empty($items)) {
            Common::printDebug("There are no Ecommerce items in the request");
            // we still record an Ecommerce order without any item in it
            return array();
        }

        if (!is_array($items)) {
            Common::printDebug("Error while json_decode the Ecommerce items = " . var_export($items, true));
            return false;
        }

        $items = Common::unsanitizeInputValues($items);

        $cleanedItems = $this->getCleanedEcommerceItems($items);
        return $cleanedItems;
    }
1076515
private function transformServerParams(\swoole_http_request $swooleRequest)
    {
        $serverParams = array_change_key_case($swooleRequest->server, \CASE_UPPER);

        foreach ($swooleRequest->header as $name => $value) {
            $serverParams['HTTP_'.strtoupper($name)] = $value;
        }

        return $serverParams;
    }
12143
public function process(\SS_HTTPRequest $request)
    {
        if ($identifier = $request->param('ID')) {
            if ($this->currencyService->setActiveCurrency(new Identifier($identifier))) {
                return [
                    'Success' => true
                ];
            }
        }

        return [
            'Success' => false
        ];
    }
208902
private function getMapProviderData(ServerRequestInterface $request): ?array
    {
        if (self::$map_providers === null) {
            $providersFile        = Webtrees::MODULES_DIR . 'openstreetmap/providers/providers.xml';
            self::$map_selections = [
                'provider' => $this->getPreference('provider', 'openstreetmap'),
                'style'    => $this->getPreference('provider_style', 'mapnik'),
            ];

            try {
                $xml = simplexml_load_string(file_get_contents($providersFile));
                // need to convert xml structure into arrays & strings
                foreach ($xml as $provider) {
                    $style_keys = array_map(
                        static function (string $item): string {
                            return preg_replace('/[^a-z\d]/i', '', strtolower($item));
                        },
                        (array) $provider->styles
                    );

                    $key = preg_replace('/[^a-z\d]/i', '', strtolower((string) $provider->name));

                    self::$map_providers[$key] = [
                        'name'   => (string) $provider->name,
                        'styles' => array_combine($style_keys, (array) $provider->styles),
                    ];
                }
            } catch (Exception $ex) {
                // Default provider is OpenStreetMap
                self::$map_selections = [
                    'provider' => 'openstreetmap',
                    'style'    => 'mapnik',
                ];
                self::$map_providers  = [
                    'openstreetmap' => [
                        'name'   => 'OpenStreetMap',
                        'styles' => ['mapnik' => 'Mapnik'],
                    ],
                ];
            }
        }

        //Ugly!!!
        switch ($request->get('action')) {
            case 'BaseData':
                $varName = (self::$map_selections['style'] === '') ? '' : self::$map_providers[self::$map_selections['provider']]['styles'][self::$map_selections['style']];
                $payload = [
                    'selectedProvIndex' => self::$map_selections['provider'],
                    'selectedProvName'  => self::$map_providers[self::$map_selections['provider']]['name'],
                    'selectedStyleName' => $varName,
                ];
                break;
            case 'ProviderStyles':
                $provider = $request->get('provider', 'openstreetmap');
                $payload  = self::$map_providers[$provider]['styles'];
                break;
            case 'AdminConfig':
                $providers = [];
                foreach (self::$map_providers as $key => $provider) {
                    $providers[$key] = $provider['name'];
                }
                $payload = [
                    'providers'     => $providers,
                    'selectedProv'  => self::$map_selections['provider'],
                    'styles'        => self::$map_providers[self::$map_selections['provider']]['styles'],
                    'selectedStyle' => self::$map_selections['style'],
                ];
                break;
            default:
                $payload = null;
        }

        return $payload;
    }
1310485
public function getRequestDataKeys()
    {
        if ($this->getType() !== self::TYPE_REQUEST) {
            return array();
        }

        if (array_key_exists('php://input', $this->mockedData)) {
            $data = $this->mockedData['php://input'];
        }
        else {
            $data = file_get_contents("php://input");
        }

        return array(
            \SwaggerValidator\Common\FactorySwagger::LOCATION_BODY  => (bool) (strlen($data) > 0),
            \SwaggerValidator\Common\FactorySwagger::LOCATION_FORM  => $this->getRequestFormDataKey(),
            \SwaggerValidator\Common\FactorySwagger::LOCATION_QUERY => $this->getRequestQueryKey(),
        );
    }
296421
public function runEvent(Request $request)
    {
        $scheduling = new Scheduling();

        try {
            $output = $scheduling->runTask($request->get('id'));

            return [
                'status'    => true,
                'message'   => 'success',
                'data'      => $output,
            ];
        } catch (\Exception $e) {
            return [
                'status'    => false,
                'message'   => 'failed',
                'data'      => $e->getMessage(),
            ];
        }
    }
414083
protected function gatherRouteMiddleware($request)
    {
        if (! is_null($route = $request->route())) {
            return $this->router->gatherRouteMiddleware($route);
        }

        return array();
    }
1162189
public function search(HTTPRequest $request)
    {
        // Detect Ajax:
        
        if (!$request->isAjax()) {
            return;
        }
        
        // Initialise:
        
        $data = ['results' => []];
        
        // Create Data List:
        
        $list = $this->getList();
        
        // Filter Data List:
        
        if ($term = $request->getVar('term')) {
            $list = $list->filterAny($this->getSearchFilters($term))->exclude($this->getExclude());
        }
        
        // Sort Data List:
        
        if ($sort = $this->getSortBy()) {
            $list = $list->sort($sort);
        }
        
        // Limit Data List:
        
        if ($limit = $this->getLimit()) {
            $list = $list->limit($limit);
        }
        
        // Define Results:
        
        foreach ($list as $record) {
            $data['results'][] = $this->getResultData($record);
        }
        
        // Answer JSON Response:
        
        return $this->respond($data);
    }
1028197
public static function getBreadcrumbs(Request $request)
    {
        $httpPath = $request->segments();
        $menuItems = self::getMenuItems('url');

        $breadcrumbs = array_map(function ($key, $crumb) use ($httpPath, $menuItems) {
            $crumbPath = join('/', array_slice($httpPath, 0, $key + 1));
            $crumbLink = '/' . $crumbPath;

            if (in_array($crumbLink, $menuItems)) {
                return [
                    'link' => $crumbLink,
                    'text' => $menuItems[$crumbLink]->title,
                ];
            }

            return [
                'link' => $crumbLink,
                'text' => str_replace('-', ' ', $crumb),
            ];
        }, array_keys($httpPath), $httpPath);

        $path = '/' . $request->path();
        if (in_array($path, $menuItems)) {
            $crumbs[] = [
                'link' => $menuItems[$path]->url,
                'text' => $menuItems[$path]->title,
            ];

            $breadcrumbs = Breadcrumbs::getNavigationalBreadcrumbs($menuItems[$path]->parent_id, $crumbs);
        }

        array_unshift($breadcrumbs, [
            'link' => env('APP_URL'),
            'text' => 'Home',
        ]);

        return $breadcrumbs;
    }
963389
function parseCookie(Swoole\Request $request)
    {
        $request->cookie = self::parseParams($request->header['Cookie']);
    }
841574
private static function getUriFromGlobals(\Swoole\Http\Request $swooleRequest)
    {
        $server = $swooleRequest->server;
        $header = $swooleRequest->header;
        $uri = new Uri();
        $uri = $uri->withScheme(! empty($server['https']) && $server['https'] !== 'off' ? 'https' : 'http');

        $hasPort = false;
        if (isset($server['http_host'])) {
            $hostHeaderParts = explode(':', $server['http_host']);
            $uri = $uri->withHost($hostHeaderParts[0]);
            if (isset($hostHeaderParts[1])) {
                $hasPort = true;
                $uri = $uri->withPort($hostHeaderParts[1]);
            }
        } elseif (isset($server['server_name'])) {
            $uri = $uri->withHost($server['server_name']);
        } elseif (isset($server['server_addr'])) {
            $uri = $uri->withHost($server['server_addr']);
        } elseif (isset($header['host'])) {
            if (\strpos($header['host'], ':')) {
                $hasPort = true;
                list($host, $port) = explode(':', $header['host'], 2);

                if ($port !== '80') {
                    $uri = $uri->withPort($port);
                }
            } else {
                $host = $header['host'];
            }

            $uri = $uri->withHost($host);
        }

        if (! $hasPort && isset($server['server_port'])) {
            $uri = $uri->withPort($server['server_port']);
        }

        $hasQuery = false;
        if (isset($server['request_uri'])) {
            $requestUriParts = explode('?', $server['request_uri']);
            $uri = $uri->withPath($requestUriParts[0]);
            if (isset($requestUriParts[1])) {
                $hasQuery = true;
                $uri = $uri->withQuery($requestUriParts[1]);
            }
        }

        if (! $hasQuery && isset($server['query_string'])) {
            $uri = $uri->withQuery($server['query_string']);
        }

        return $uri;
    }
1353618
public static function loadFromSwooleRequest(\Swoole\Http\Request $swooleRequest)
    {
        $server = $swooleRequest->server;
        $method = $server['request_method'] ?? 'GET';
        $headers = $swooleRequest->header ?? [];
        $uri = self::getUriFromGlobals($swooleRequest);
        $body = new SwooleStream($swooleRequest->rawContent());
        $protocol = isset($server['server_protocol']) ? str_replace('HTTP/', '', $server['server_protocol']) : '1.1';
        $request = new static($method, $uri, $headers, $body, $protocol);
        $request->cookieParams = ($swooleRequest->cookie ?? []);
        $request->queryParams = ($swooleRequest->get ?? []);
        $request->serverParams = ($server ?? []);
        $request->parsedBody = ($swooleRequest->post ?? []);
        $request->uploadedFiles = self::normalizeFiles($swooleRequest->files ?? []);
        $request->swooleRequest = $swooleRequest;
        return $request;
    }
564062
protected function parseBody(ServerRequestInterface $request): array
    {
        $body = [];
        parse_str($request->getBody()->getContents(), $body);

        return $body;
    }