0
정의에서 XML 오류를 렌더링 : 나는 XML 형식으로 렌더링하는 사용자 지정 오류 렌더러를 만드는거야 Using a custom renderer with Exception.renderer to handle application exceptionsCakePHP는 여기에 정보를 바탕으로 Exception.renderer
.
public function render() {
if (isset($this->controller->request->params['xml'])) {
$this->controller->viewClass = "MyXml";
$error = array(
'app' => array(
'error' => 'An unexpected error has occured.'
)
);
$this->controller->set('error', $error);
$this->controller->set('_serialize', 'error');
}
}
그러나 아무것도 반환됩니다 :
다음은 응용 프로그램/lib 디렉토리/오류/AppExceptionRenderer의 렌더링 함수에 대한 샘플 코드입니다. if
조건 내에서 일부 에코를 수행했음을 보여줍니다.
ViewClass가 AppExceptionRenderer :: render() 단계에서 초기화되지 않았기 때문에 그렇습니까?
오류가 없었습니다.
"MyXml"viewClass도 일반 컨트롤러에서도 완벽하게 작동합니다.