Browse Source

Method_exists replaced with is_callable

Alexander Volochnev 10 years ago
parent
commit
212494cf15
2 changed files with 3 additions and 3 deletions
  1. 2 2
      Controller/CRUDController.php
  2. 1 1
      Tests/Controller/CRUDControllerTest.php

+ 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([$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));