mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Created an exception to error 405 (Method Not Allowed) and changed the delete action in bake to use it.
This commit is contained in:
parent
4eed660a62
commit
e380b76e16
2 changed files with 21 additions and 1 deletions
|
@ -116,7 +116,7 @@
|
||||||
|
|
||||||
public function <?php echo $admin; ?>delete($id = null) {
|
public function <?php echo $admin; ?>delete($id = null) {
|
||||||
if (!$this->request->is('post')) {
|
if (!$this->request->is('post')) {
|
||||||
throw new ForbiddenException();
|
throw new MethodNotAllowedException();
|
||||||
}
|
}
|
||||||
if (!$id) {
|
if (!$id) {
|
||||||
<?php if ($wannaUseSession): ?>
|
<?php if ($wannaUseSession): ?>
|
||||||
|
|
|
@ -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.
|
* Represents an HTTP 500 error.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue