فهرست منبع

Use the new getRestMethod() in the CrudController

Thomas Rabaix 12 سال پیش
والد
کامیت
0b60fa5f70
1فایلهای تغییر یافته به همراه8 افزوده شده و 7 حذف شده
  1. 8 7
      Controller/CRUDController.php

+ 8 - 7
Controller/CRUDController.php

@@ -64,15 +64,16 @@ class CRUDController extends Controller
     /**
      * Returns the correct RESTful verb, given either by the request itself or
      * via the "_method" parameter.
-     * 
-     * @return string HTTP method, either 
+     *
+     * @return string HTTP method, either
      */
     protected function getRestMethod()
     {
         $request = $this->getRequest();
-        if(Request::getHttpMethodParameterOverride() || !$request->request->has('_method')) {
-            return $request->getMethod(); 
+        if (Request::getHttpMethodParameterOverride() || !$request->request->has('_method')) {
+            return $request->getMethod();
         }
+
         return $request->request->get('_method');
     }
 
@@ -288,7 +289,7 @@ class CRUDController extends Controller
         $form = $this->admin->getForm();
         $form->setData($object);
 
-        if ($this->get('request')->getMethod() == 'POST') {
+        if ($this->getRestMethod() == 'POST') {
             $form->bind($this->get('request'));
 
             $isFormValid = $form->isValid();
@@ -373,7 +374,7 @@ class CRUDController extends Controller
      */
     public function batchAction()
     {
-        if ($this->get('request')->getMethod() != 'POST') {
+        if ($this->getRestMethod() != 'POST') {
             throw new \RuntimeException('invalid request type, POST expected');
         }
 
@@ -477,7 +478,7 @@ class CRUDController extends Controller
         $form = $this->admin->getForm();
         $form->setData($object);
 
-        if ($this->get('request')->getMethod() == 'POST') {
+        if ($this->getRestMethod()== 'POST') {
             $form->bind($this->get('request'));
 
             $isFormValid = $form->isValid();