瀏覽代碼

Deprecate AbstractAdmin::getBatchActions method override (#3865)

Sullivan SENECHAL 9 年之前
父節點
當前提交
822481ff4a
共有 2 個文件被更改,包括 15 次插入0 次删除
  1. 9 0
      Controller/CRUDController.php
  2. 6 0
      UPGRADE-3.x.md

+ 9 - 0
Controller/CRUDController.php

@@ -368,6 +368,15 @@ class CRUDController extends Controller
             unset($data['_sonata_csrf_token']);
         }
 
+        // NEXT_MAJOR: Remove reflection check.
+        $reflector = new \ReflectionMethod($this->admin, 'getBatchActions');
+        if ($reflector->getDeclaringClass()->getName() === get_class($this->admin)) {
+            @trigger_error('Override Sonata\AdminBundle\Admin\AbstractAdmin::getBatchActions method'
+                .' is deprecated since version 3.x.'
+                .' Use Sonata\AdminBundle\Admin\AbstractAdmin::configureBatchActions instead.'
+                .' The method will be final in 4.0.', E_USER_DEPRECATED
+            );
+        }
         $batchActions = $this->admin->getBatchActions();
         if (!array_key_exists($action, $batchActions)) {
             throw new \RuntimeException(sprintf('The `%s` batch action is not defined', $action));

+ 6 - 0
UPGRADE-3.x.md

@@ -1,6 +1,12 @@
 UPGRADE 3.x
 ===========
 
+## Deprecated override of AbstractAdmin::getBatchActions
+
+Since `AbstractAdmin::configureBatchActions` is present, you should not override `AbstractAdmin::getBatchActions`.
+
+This method will be final in 4.0.
+
 UPGRADE FROM 3.0 to 3.1
 =======================