Skip to content

Instantly share code, notes, and snippets.

@gomasaba
Created October 4, 2011 16:54
Show Gist options
  • Save gomasaba/1262163 to your computer and use it in GitHub Desktop.
Save gomasaba/1262163 to your computer and use it in GitHub Desktop.
cake2で独自のエラーテンプレートを作りたいときのメモ
class ExampleException extends CakeException {
/**
 * Constructor
 *
 * @param string $message If no message is given 'Not Found' will be the message
 * @param string $code Status code, defaults to 404
 */
	public function __construct($message = null, $code = 404) {
		if (empty($message)) {
			$message = 'Access Deneied';
		}
		Configure::write('Exception.renderer', 'ExampleRenderer');
		parent::__construct($message, $code);
	}
}

class ExampleRenderer extends ExceptionRenderer {
	
	public function Example(){
		$this->_outputMessage('example');
	}

}

Errors/example.ctp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment