private function format()
    {
        $request_uri = sprintf('%s %s', $this->request->getMethod(), $this->request->getBasePath().$this->request->getPathInfo());

        $ret = [
            'meta' => [
                'api_version'   => $this->getVersion(),
                'request'       => $request_uri,
                'response_time' => $this->responseTime,
                'http_code'     => $this->code,
                'error_type'    => $this->errorType,
                'error_message' => $this->errorMessage,
                'error_details' => $this->errorDetails,
                'charset'       => 'UTF-8',
            ],
            'response'          => $this->data,
        ];

        switch ($this->responseType) {
            case self::FORMAT_JSON:
            default:
                return new JsonResponse($ret);
            case self::FORMAT_YAML:
                if ($ret['response'] instanceof \stdClass) {
                    $ret['response'] = [];
                }

                $dumper = new Dumper();

                return new Response($dumper->dump($ret, 8));
            case self::FORMAT_JSONP:
                $response = new JsonResponse($ret);
                $response->setCallback(trim($this->request->get('callback')));

                return $response;
                break;
        }
    }
private function format()
    {
        $request_uri = sprintf('%s %s', $this->request->getMethod(), $this->request->getBasePath().$this->request->getPathInfo());

        $ret = [
            'meta' => [
                'api_version'   => $this->getVersion(),
                'request'       => $request_uri,
                'response_time' => $this->responseTime,
                'http_code'     => $this->code,
                'error_type'    => $this->errorType,
                'error_message' => $this->errorMessage,
                'error_details' => $this->errorDetails,
                'charset'       => 'UTF-8',
            ],
            'response'          => $this->data,
        ];

        switch ($this->responseType) {
            case self::FORMAT_JSON:
            default:
                return new JsonResponse($ret);
            case self::FORMAT_YAML:
                if ($ret['response'] instanceof \stdClass) {
                    $ret['response'] = [];
                }

                $dumper = new Dumper();

                return new Response($dumper->dump($ret, 8));
            case self::FORMAT_JSONP:
                $response = new JsonResponse($ret);
                $response->setCallback(trim($this->request->get('callback')));

                return $response;
                break;
        }
    }
private function format ( ) { $ request_uri = sprintf ( '%s %s' , $ this -> request -> getMethod ( ) , $ this -> request -> getBasePath ( ) . $ this -> request -> getPathInfo ( ) ) ; $ ret = [ 'meta' => [ 'api_version' => $ this -> getVersion ( ) , 'request' => $ request_uri , 'response_time' => $ this -> responseTime , 'http_code' => $ this -> code , 'error_type' => $ this -> errorType , 'error_message' => $ this -> errorMessage , 'error_details' => $ this -> errorDetails , 'charset' => 'UTF-8' , ] , 'response' => $ this -> data , ] ; switch ( $ this -> responseType ) { case self :: FORMAT_JSON : default : return new JsonResponse ( $ ret ) ; case self :: FORMAT_YAML : if ( $ ret [ 'response' ] instanceof \ stdClass ) { $ ret [ 'response' ] = [ ] ; } $ dumper = new Dumper ( ) ; return new Response ( $ dumper -> dump ( $ ret , 8 ) ) ; case self :: FORMAT_JSONP : $ response = new JsonResponse ( $ ret ) ; $ response -> setCallback ( trim ( $ this -> request -> get ( 'callback' ) ) ) ; return $ response ; break ; } }
Formats the data and return serialized string

@return Response
Formats the data and return serialized string