Prechádzať zdrojové kódy

Merge pull request #2584 from HadesArchitect/master

Fixed method existanse check
Thomas 10 rokov pred
rodič
commit
4d4e8e7ca7

+ 2 - 2
Controller/CRUDController.php

@@ -559,8 +559,8 @@ class CRUDController extends Controller
 
         // execute the action, batchActionXxxxx
         $finalAction = sprintf('batchAction%s', ucfirst($camelizedAction));
-        if (!method_exists($this, $finalAction)) {
-            throw new \RuntimeException(sprintf('A `%s::%s` method must be created', get_class($this), $finalAction));
+        if (!is_callable(array($this, $finalAction))) {
+            throw new \RuntimeException(sprintf('A `%s::%s` method must be callable', get_class($this), $finalAction));
         }
 
         $query = $datagrid->getQuery();

+ 1 - 1
Tests/Controller/CRUDControllerTest.php

@@ -2663,7 +2663,7 @@ class CRUDControllerTest extends \PHPUnit_Framework_TestCase
 
     public function testBatchActionMethodNotExist()
     {
-        $this->setExpectedException('RuntimeException', 'A `Sonata\AdminBundle\Controller\CRUDController::batchActionFoo` method must be created');
+        $this->setExpectedException('RuntimeException', 'A `Sonata\AdminBundle\Controller\CRUDController::batchActionFoo` method must be callable');
 
         $batchActions = array('foo'=>array('label'=>'Foo Bar', 'ask_confirmation' => false));