public function validateRequestContentType(Request $request, Application $app)
    {
        // Define the "form" format so we can use it for validation
        $request->setFormat("form", array("application/x-www-form-urlencoded", "multipart/form-data"));

        $format = $request->getContentType();
        if (strlen($request->getContent()) > 0 && !in_array($format, $app["conneg.requestFormats"])) {
            // The request has a body but it is not a supported media type
            throw new UnsupportedMediaTypeHttpException();
        }
    }
public function validateRequestContentType(Request $request, Application $app)
    {
        // Define the "form" format so we can use it for validation
        $request->setFormat("form", array("application/x-www-form-urlencoded", "multipart/form-data"));

        $format = $request->getContentType();
        if (strlen($request->getContent()) > 0 && !in_array($format, $app["conneg.requestFormats"])) {
            // The request has a body but it is not a supported media type
            throw new UnsupportedMediaTypeHttpException();
        }
    }
public function validateRequestContentType ( Request $ request , Application $ app ) { // Define the "form" format so we can use it for validation $ request -> setFormat ( "form" , array ( "application/x-www-form-urlencoded" , "multipart/form-data" ) ) ; $ format = $ request -> getContentType ( ) ; if ( strlen ( $ request -> getContent ( ) ) > 0 && ! in_array ( $ format , $ app [ "conneg.requestFormats" ] ) ) { // The request has a body but it is not a supported media type throw new UnsupportedMediaTypeHttpException ( ) ; } }
This before middleware validates that the request body is in a format
that the application understands.

@param Request $request
@throws UnsupportedMediaTypeHttpException
This before middleware validates that the request body is in a format that the application understands .