Created an exception to error 405 (Method Not Allowed) and changed the delete action in bake to use it.

This commit is contained in:
Juan Basso 2010-10-30 23:13:54 -02:00
parent 4eed660a62
commit e380b76e16
2 changed files with 21 additions and 1 deletions

View file

@ -116,7 +116,7 @@
public function <?php echo $admin; ?>delete($id = null) {
if (!$this->request->is('post')) {
throw new ForbiddenException();
throw new MethodNotAllowedException();
}
if (!$id) {
<?php if ($wannaUseSession): ?>

View file

@ -99,6 +99,26 @@ class NotFoundException extends RuntimeException {
}
}
/**
* Represents an HTTP 405 error.
*
* @package cake.libs
*/
class MethodNotAllowedException extends RuntimeException {
/**
* Constructor
*
* @param string $message If no message is given 'Method Not Allowed' will be the message
* @param string $code Status code, defaults to 401
*/
public function __construct($message = null, $code = 405) {
if (empty($message)) {
$message = 'Method Not Allowed';
}
parent::__construct($message, $code);
}
}
/**
* Represents an HTTP 500 error.
*