private function convertRequest(BrowserKitRequest $request)
    {
        $environment = Environment::mock($request->getServer());
        $uri = Uri::createFromString($request->getUri());
        $headers = Headers::createFromEnvironment($environment);
        $cookies = Cookies::parseHeader($headers->get('Cookie', []));

        $container = $this->app->getContainer();

        /* @var $slimRequest ServerRequestInterface */
        $slimRequest = $container->get('request');

        $slimRequest = $slimRequest->withMethod($request->getMethod())
          ->withUri($uri)
          ->withUploadedFiles($this->convertFiles($request->getFiles()))
          ->withCookieParams($cookies);

        foreach ($headers->keys() as $key) {
            $slimRequest = $slimRequest->withHeader($key, $headers->get($key));
        }

        if ($request->getContent() !== null) {
            $body = new RequestBody();
            $body->write($request->getContent());
            $slimRequest = $slimRequest
                ->withBody($body);
        }

        $parsed = [];
        if ($request->getMethod() !== 'GET') {
            $parsed = $request->getParameters();
        }

        // make sure we do not overwrite a request with a parsed body
        if (!$slimRequest->getParsedBody()) {
            $slimRequest = $slimRequest
                ->withParsedBody($parsed);
        }

        return $slimRequest;
    }
private function convertRequest(BrowserKitRequest $request)
    {
        $environment = Environment::mock($request->getServer());
        $uri = Uri::createFromString($request->getUri());
        $headers = Headers::createFromEnvironment($environment);
        $cookies = Cookies::parseHeader($headers->get('Cookie', []));

        $container = $this->app->getContainer();

        /* @var $slimRequest ServerRequestInterface */
        $slimRequest = $container->get('request');

        $slimRequest = $slimRequest->withMethod($request->getMethod())
          ->withUri($uri)
          ->withUploadedFiles($this->convertFiles($request->getFiles()))
          ->withCookieParams($cookies);

        foreach ($headers->keys() as $key) {
            $slimRequest = $slimRequest->withHeader($key, $headers->get($key));
        }

        if ($request->getContent() !== null) {
            $body = new RequestBody();
            $body->write($request->getContent());
            $slimRequest = $slimRequest
                ->withBody($body);
        }

        $parsed = [];
        if ($request->getMethod() !== 'GET') {
            $parsed = $request->getParameters();
        }

        // make sure we do not overwrite a request with a parsed body
        if (!$slimRequest->getParsedBody()) {
            $slimRequest = $slimRequest
                ->withParsedBody($parsed);
        }

        return $slimRequest;
    }
private function convertRequest ( BrowserKitRequest $ request ) { $ environment = Environment :: mock ( $ request -> getServer ( ) ) ; $ uri = Uri :: createFromString ( $ request -> getUri ( ) ) ; $ headers = Headers :: createFromEnvironment ( $ environment ) ; $ cookies = Cookies :: parseHeader ( $ headers -> get ( 'Cookie' , [ ] ) ) ; $ container = $ this -> app -> getContainer ( ) ; /* @var $slimRequest ServerRequestInterface */ $ slimRequest = $ container -> get ( 'request' ) ; $ slimRequest = $ slimRequest -> withMethod ( $ request -> getMethod ( ) ) -> withUri ( $ uri ) -> withUploadedFiles ( $ this -> convertFiles ( $ request -> getFiles ( ) ) ) -> withCookieParams ( $ cookies ) ; foreach ( $ headers -> keys ( ) as $ key ) { $ slimRequest = $ slimRequest -> withHeader ( $ key , $ headers -> get ( $ key ) ) ; } if ( $ request -> getContent ( ) !== null ) { $ body = new RequestBody ( ) ; $ body -> write ( $ request -> getContent ( ) ) ; $ slimRequest = $ slimRequest -> withBody ( $ body ) ; } $ parsed = [ ] ; if ( $ request -> getMethod ( ) !== 'GET' ) { $ parsed = $ request -> getParameters ( ) ; } // make sure we do not overwrite a request with a parsed body if ( ! $ slimRequest -> getParsedBody ( ) ) { $ slimRequest = $ slimRequest -> withParsedBody ( $ parsed ) ; } return $ slimRequest ; }
Convert to PSR-7's ServerRequestInterface.

@param BrowserKitRequest $request
@return ServerRequestInterface
Convert to PSR - 7 s ServerRequestInterface .