src/KapSecurity/Controller/OAuthController.php
protected function getOAuth2Request($params = null)
    {
        $zf2Request = $this->getRequest();
        $headers    = $zf2Request->getHeaders();

        // Marshal content type, so we can seed it into the $_SERVER array
        $contentType = '';
        if ($headers->has('Content-Type')) {
            $contentType = $headers->get('Content-Type')->getFieldValue();
        }

        // Get $_SERVER superglobal
        $server = array();
        if ($zf2Request instanceof PhpEnvironmentRequest) {
            $server = $zf2Request->getServer()->toArray();
        } elseif (!empty($_SERVER)) {
            $server = $_SERVER;
        }
        $server['REQUEST_METHOD'] = $zf2Request->getMethod();

        // Seed headers with HTTP auth information
        $headers = $headers->toArray();
        if (isset($server['PHP_AUTH_USER'])) {
            $headers['PHP_AUTH_USER'] = $server['PHP_AUTH_USER'];
        }
        if (isset($server['PHP_AUTH_PW'])) {
            $headers['PHP_AUTH_PW'] = $server['PHP_AUTH_PW'];
        }

        // Ensure the bodyParams are passed as an array
        $bodyParams = $this->bodyParams() ?: array();

        return new OAuth2Request(
            $params ? $params : $zf2Request->getQuery()->toArray(),
            $this->bodyParams(),
            array(), // attributes
            array(), // cookies
            array(), // files
            $server,
            $zf2Request->getContent(),
            $headers
        );
    }
protected function getOAuth2Request($params = null)
    {
        $zf2Request = $this->getRequest();
        $headers    = $zf2Request->getHeaders();

        // Marshal content type, so we can seed it into the $_SERVER array
        $contentType = '';
        if ($headers->has('Content-Type')) {
            $contentType = $headers->get('Content-Type')->getFieldValue();
        }

        // Get $_SERVER superglobal
        $server = array();
        if ($zf2Request instanceof PhpEnvironmentRequest) {
            $server = $zf2Request->getServer()->toArray();
        } elseif (!empty($_SERVER)) {
            $server = $_SERVER;
        }
        $server['REQUEST_METHOD'] = $zf2Request->getMethod();

        // Seed headers with HTTP auth information
        $headers = $headers->toArray();
        if (isset($server['PHP_AUTH_USER'])) {
            $headers['PHP_AUTH_USER'] = $server['PHP_AUTH_USER'];
        }
        if (isset($server['PHP_AUTH_PW'])) {
            $headers['PHP_AUTH_PW'] = $server['PHP_AUTH_PW'];
        }

        // Ensure the bodyParams are passed as an array
        $bodyParams = $this->bodyParams() ?: array();

        return new OAuth2Request(
            $params ? $params : $zf2Request->getQuery()->toArray(),
            $this->bodyParams(),
            array(), // attributes
            array(), // cookies
            array(), // files
            $server,
            $zf2Request->getContent(),
            $headers
        );
    }
protected function getOAuth2Request ( $ params = null ) { $ zf2Request = $ this -> getRequest ( ) ; $ headers = $ zf2Request -> getHeaders ( ) ; // Marshal content type, so we can seed it into the $_SERVER array $ contentType = '' ; if ( $ headers -> has ( 'Content-Type' ) ) { $ contentType = $ headers -> get ( 'Content-Type' ) -> getFieldValue ( ) ; } // Get $_SERVER superglobal $ server = array ( ) ; if ( $ zf2Request instanceof PhpEnvironmentRequest ) { $ server = $ zf2Request -> getServer ( ) -> toArray ( ) ; } elseif ( ! empty ( $ _SERVER ) ) { $ server = $ _SERVER ; } $ server [ 'REQUEST_METHOD' ] = $ zf2Request -> getMethod ( ) ; // Seed headers with HTTP auth information $ headers = $ headers -> toArray ( ) ; if ( isset ( $ server [ 'PHP_AUTH_USER' ] ) ) { $ headers [ 'PHP_AUTH_USER' ] = $ server [ 'PHP_AUTH_USER' ] ; } if ( isset ( $ server [ 'PHP_AUTH_PW' ] ) ) { $ headers [ 'PHP_AUTH_PW' ] = $ server [ 'PHP_AUTH_PW' ] ; } // Ensure the bodyParams are passed as an array $ bodyParams = $ this -> bodyParams ( ) ? : array ( ) ; return new OAuth2Request ( $ params ? $ params : $ zf2Request -> getQuery ( ) -> toArray ( ) , $ this -> bodyParams ( ) , array ( ) , // attributes array ( ) , // cookies array ( ) , // files $ server , $ zf2Request -> getContent ( ) , $ headers ) ; }
Create an OAuth2 request based on the ZF2 request object

Marshals:

- query string
- body parameters, via content negotiation
- "server", specifically the request method and content type
- raw content
- headers

This ensures that JSON requests providing credentials for OAuth2
verification/validation can be processed.

@return OAuth2Request
Create an OAuth2 request based on the ZF2 request object