-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix for "delete" action not working with Sf2.2 #1184
Conversation
@@ -211,7 +211,8 @@ public function deleteAction($id) | |||
throw new AccessDeniedException(); | |||
} | |||
|
|||
if ($this->getRequest()->getMethod() == 'DELETE') { | |||
$request = $this->getRequest(); | |||
if ($request->getMethod() == 'DELETE' || $request->getHttpMethodParameterOverride() == false && $request->getMethod() == 'POST') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you create a method getHttpMethod()
which return the correct REST Verb ?
@mweimerskirch ping |
@rande: Sorry, had a project launch this morning. I'll work on the patch this afternoon. |
@rande: Here you go. Is this the implementation you meant? |
*/ | ||
protected function getHttpMethod() { | ||
$request = $this->getRequest(); | ||
if($request->getHttpMethodParameterOverride()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is a static method
I removed the else and collapsed it into the first if + changed the method call to static |
* | ||
* @return string HTTP method, either | ||
*/ | ||
protected function getHttpMethod() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you rename it getRestMethod() ? sorry I didn't spot it at first
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and put a new line before the {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@mweimerskirch are you sure about the PUT/POST action too ? do need to change the code ? |
No, I'm not sure :-( |
good to know ;) There is no issue with form ? |
I'm probably not using all the field types and I also applied this for my project: sonata-project/SonataDoctrineORMAdminBundle#167 (only the first commit). |
Related patch: symfony/symfony#7202 (unfortunately pulled only into master and not into 2.2) |
How about checking for both DELETE and POST? Btw. for using POST I would recommend adding an CSRF token (configurable) for better security. |
Fix for "delete" action not working with Sf2.2
This is an alternative to #1157 and #1176