private function buildResponse(Event $event)
    {
        $request = $event->getData()['request'];
        $response = $event->getData()['response'];

        if ('xml' === Configure::read('ApiRequest.responseType')) {
            $response->withType('xml');
        } else {
            $response->withType('json');
        }

        $response->cors($request)
                ->allowOrigin(Configure::read('ApiRequest.cors.origin'))
                ->allowMethods(Configure::read('ApiRequest.cors.allowedMethods'))
                ->allowHeaders(Configure::read('ApiRequest.cors.allowedHeaders'))
                ->allowCredentials()
                ->maxAge(Configure::read('ApiRequest.cors.maxAge'))
                ->build();

        return true;
    }
private function buildResponse(Event $event)
    {
        $request = $event->getData()['request'];
        $response = $event->getData()['response'];

        if ('xml' === Configure::read('ApiRequest.responseType')) {
            $response->withType('xml');
        } else {
            $response->withType('json');
        }

        $response->cors($request)
                ->allowOrigin(Configure::read('ApiRequest.cors.origin'))
                ->allowMethods(Configure::read('ApiRequest.cors.allowedMethods'))
                ->allowHeaders(Configure::read('ApiRequest.cors.allowedHeaders'))
                ->allowCredentials()
                ->maxAge(Configure::read('ApiRequest.cors.maxAge'))
                ->build();

        return true;
    }
private function buildResponse ( Event $ event ) { $ request = $ event -> getData ( ) [ 'request' ] ; $ response = $ event -> getData ( ) [ 'response' ] ; if ( 'xml' === Configure :: read ( 'ApiRequest.responseType' ) ) { $ response -> withType ( 'xml' ) ; } else { $ response -> withType ( 'json' ) ; } $ response -> cors ( $ request ) -> allowOrigin ( Configure :: read ( 'ApiRequest.cors.origin' ) ) -> allowMethods ( Configure :: read ( 'ApiRequest.cors.allowedMethods' ) ) -> allowHeaders ( Configure :: read ( 'ApiRequest.cors.allowedHeaders' ) ) -> allowCredentials ( ) -> maxAge ( Configure :: read ( 'ApiRequest.cors.maxAge' ) ) -> build ( ) ; return true ; }
Prepares the response object with content type and cors headers.

@param Event $event The event object either beforeDispatch or afterDispatch

@return bool true
Prepares the response object with content type and cors headers .