Explorar o código

Merge pull request #3548 from core23/batchactions-extension

Modify batch actions in admin extension
Oskar Stark %!s(int64=9) %!d(string=hai) anos
pai
achega
3397c965ff
Modificáronse 3 ficheiros con 26 adicións e 0 borrados
  1. 7 0
      Admin/Admin.php
  2. 8 0
      Admin/AdminExtension.php
  3. 11 0
      Admin/AdminExtensionInterface.php

+ 7 - 0
Admin/Admin.php

@@ -1225,6 +1225,13 @@ abstract class Admin implements AdminInterface, DomainObjectInterface
             );
         }
 
+        foreach ($this->getExtensions() as $extension) {
+            // TODO: remove method check in next major release
+            if (method_exists($extension, 'configureBatchActions')) {
+                $actions = $extension->configureBatchActions($this, $actions);
+            }
+        }
+
         return $actions;
     }
 

+ 8 - 0
Admin/AdminExtension.php

@@ -123,6 +123,14 @@ abstract class AdminExtension implements AdminExtensionInterface
         return array();
     }
 
+    /**
+     * {@inheritdoc}
+     */
+    public function configureBatchActions(AdminInterface $admin, array $actions)
+    {
+        return $actions;
+    }
+
     /**
      * {@inheritdoc}
      */

+ 11 - 0
Admin/AdminExtensionInterface.php

@@ -124,6 +124,17 @@ interface AdminExtensionInterface
     // TODO: Uncomment in next major release
     // public function getAccessMapping(AdminInterface $admin);
 
+    /**
+     * Returns the list of batch actions.
+     *
+     * @param AdminInterface $admin
+     * @param array          $actions
+     *
+     * @return array
+     */
+    // TODO: Uncomment in next major release
+    // public function configureBatchActions(AdminInterface $admin, array $actions);
+
     /**
      * @param AdminInterface $admin
      * @param mixed          $object