protected function returnValidationFailure(common_report_Report $report, $withMessage=true)
    {
        $data = ['data' => []];
        /** @var common_report_Report $error */
        foreach ($report->getErrors() as $error) {
            $data['data'][$error->getData()] = $error->getMessage();
        }

        if ($withMessage) {
            $data['success'] = false;
            $data['errorCode'] = 400;
            $data['errorMsg'] = 'Some fields are invalid';
            $data['version'] = TAO_VERSION;
        }

        $this->returnJson($data, 400);
        exit(0);
    }
protected function returnValidationFailure(common_report_Report $report, $withMessage=true)
    {
        $data = ['data' => []];
        /** @var common_report_Report $error */
        foreach ($report->getErrors() as $error) {
            $data['data'][$error->getData()] = $error->getMessage();
        }

        if ($withMessage) {
            $data['success'] = false;
            $data['errorCode'] = 400;
            $data['errorMsg'] = 'Some fields are invalid';
            $data['version'] = TAO_VERSION;
        }

        $this->returnJson($data, 400);
        exit(0);
    }
protected function returnValidationFailure ( common_report_Report $ report , $ withMessage = true ) { $ data = [ 'data' => [ ] ] ; /** @var common_report_Report $error */ foreach ( $ report -> getErrors ( ) as $ error ) { $ data [ 'data' ] [ $ error -> getData ( ) ] = $ error -> getMessage ( ) ; } if ( $ withMessage ) { $ data [ 'success' ] = false ; $ data [ 'errorCode' ] = 400 ; $ data [ 'errorMsg' ] = 'Some fields are invalid' ; $ data [ 'version' ] = TAO_VERSION ; } $ this -> returnJson ( $ data , 400 ) ; exit ( 0 ) ; }
Transform a report to http response with 422 code and report error messages

@param common_report_Report $report
@param bool $withMessage
Transform a report to http response with 422 code and report error messages