public static function toCake(PsrRequest $request)
    {
        $post = $request->getParsedBody();
        $headers = [];
        foreach ($request->getHeaders() as $k => $value) {
            $name = sprintf('HTTP_%s', strtoupper(str_replace('-', '_', $k)));
            $headers[$name] = implode(',', $value);
        }
        $server = $headers + $request->getServerParams();

        $files = static::getFiles($request);
        if (!empty($files)) {
            $post = Hash::merge($post, $files);
        }

        $input = $request->getBody()->getContents();
        $input = $input === '' ? null : $input;

        return new ServerRequest([
            'query' => $request->getQueryParams(),
            'post' => $post,
            'cookies' => $request->getCookieParams(),
            'environment' => $server,
            'params' => static::getParams($request),
            'url' => $request->getUri()->getPath(),
            'base' => $request->getAttribute('base', ''),
            'webroot' => $request->getAttribute('webroot', '/'),
            'session' => $request->getAttribute('session', null),
            'input' => $input,
        ]);
    }
public static function toCake(PsrRequest $request)
    {
        $post = $request->getParsedBody();
        $headers = [];
        foreach ($request->getHeaders() as $k => $value) {
            $name = sprintf('HTTP_%s', strtoupper(str_replace('-', '_', $k)));
            $headers[$name] = implode(',', $value);
        }
        $server = $headers + $request->getServerParams();

        $files = static::getFiles($request);
        if (!empty($files)) {
            $post = Hash::merge($post, $files);
        }

        $input = $request->getBody()->getContents();
        $input = $input === '' ? null : $input;

        return new ServerRequest([
            'query' => $request->getQueryParams(),
            'post' => $post,
            'cookies' => $request->getCookieParams(),
            'environment' => $server,
            'params' => static::getParams($request),
            'url' => $request->getUri()->getPath(),
            'base' => $request->getAttribute('base', ''),
            'webroot' => $request->getAttribute('webroot', '/'),
            'session' => $request->getAttribute('session', null),
            'input' => $input,
        ]);
    }
public static function toCake ( PsrRequest $ request ) { $ post = $ request -> getParsedBody ( ) ; $ headers = [ ] ; foreach ( $ request -> getHeaders ( ) as $ k => $ value ) { $ name = sprintf ( 'HTTP_%s' , strtoupper ( str_replace ( '-' , '_' , $ k ) ) ) ; $ headers [ $ name ] = implode ( ',' , $ value ) ; } $ server = $ headers + $ request -> getServerParams ( ) ; $ files = static :: getFiles ( $ request ) ; if ( ! empty ( $ files ) ) { $ post = Hash :: merge ( $ post , $ files ) ; } $ input = $ request -> getBody ( ) -> getContents ( ) ; $ input = $ input === '' ? null : $ input ; return new ServerRequest ( [ 'query' => $ request -> getQueryParams ( ) , 'post' => $ post , 'cookies' => $ request -> getCookieParams ( ) , 'environment' => $ server , 'params' => static :: getParams ( $ request ) , 'url' => $ request -> getUri ( ) -> getPath ( ) , 'base' => $ request -> getAttribute ( 'base' , '' ) , 'webroot' => $ request -> getAttribute ( 'webroot' , '/' ) , 'session' => $ request -> getAttribute ( 'session' , null ) , 'input' => $ input , ] ) ; }
Transform a PSR7 request into a CakePHP one.

@param \Psr\Http\Message\ServerRequestInterface $request The PSR7 request.
@return \Cake\Http\ServerRequest The transformed request.
Transform a PSR7 request into a CakePHP one .