protected function getRequestData(Request $request, $inflection = 'camelize')
    {
        switch ($request->headers->get('content-type')) {

            case 'application/json':
                if (!($data = @json_decode($request->getContent(), true))
                    && ($error = json_last_error()) != JSON_ERROR_NONE
                ) {
                    throw new HttpException(400, sprintf(
                        'Invalid submitted json data, error %s : %s',
                        $error,
                        json_last_error_msg()
                    ));
                }

                break;
            default:
                $data = array_replace_recursive(
                    $request->request->all(),
                    $request->files->all()
                );
                break;
        }

        // data camel case normalization
        return $inflection && $this->container->has('majora.inflector')?
            $this->container->get('majora.inflector')->normalize($data, $inflection) :
            $data
        ;
    }
protected function getRequestData(Request $request, $inflection = 'camelize')
    {
        switch ($request->headers->get('content-type')) {

            case 'application/json':
                if (!($data = @json_decode($request->getContent(), true))
                    && ($error = json_last_error()) != JSON_ERROR_NONE
                ) {
                    throw new HttpException(400, sprintf(
                        'Invalid submitted json data, error %s : %s',
                        $error,
                        json_last_error_msg()
                    ));
                }

                break;
            default:
                $data = array_replace_recursive(
                    $request->request->all(),
                    $request->files->all()
                );
                break;
        }

        // data camel case normalization
        return $inflection && $this->container->has('majora.inflector')?
            $this->container->get('majora.inflector')->normalize($data, $inflection) :
            $data
        ;
    }
protected function getRequestData ( Request $ request , $ inflection = 'camelize' ) { switch ( $ request -> headers -> get ( 'content-type' ) ) { case 'application/json' : if ( ! ( $ data = @ json_decode ( $ request -> getContent ( ) , true ) ) && ( $ error = json_last_error ( ) ) != JSON_ERROR_NONE ) { throw new HttpException ( 400 , sprintf ( 'Invalid submitted json data, error %s : %s' , $ error , json_last_error_msg ( ) ) ) ; } break ; default : $ data = array_replace_recursive ( $ request -> request -> all ( ) , $ request -> files -> all ( ) ) ; break ; } // data camel case normalization return $ inflection && $ this -> container -> has ( 'majora.inflector' ) ? $ this -> container -> get ( 'majora.inflector' ) -> normalize ( $ data , $ inflection ) : $ data ; }
Retrieve given request data depending on its content type.

@param Request $request
@param string  $inflection optional inflector to tuse on parameter keys

@return array

@throws HttpException if JSON content-type and invalid JSON data
Retrieve given request data depending on its content type .