From a306ba448b17f16364e3fb0cdb1ee795d48a427f Mon Sep 17 00:00:00 2001 From: Mellisa Hankins Date: Thu, 11 Jul 2013 16:01:53 +1000 Subject: [PATCH] FEATURE: Added ability to change the request class Similar to GridFieldDetailForm --- code/GridFieldBulkManager.php | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/code/GridFieldBulkManager.php b/code/GridFieldBulkManager.php index 44a2ef7..be5fb7c 100644 --- a/code/GridFieldBulkManager.php +++ b/code/GridFieldBulkManager.php @@ -28,6 +28,11 @@ class GridFieldBulkManager implements GridField_HTMLProvider, GridField_ColumnPr * These cannot be removed from the blacklist */ protected $forbiddenFieldsClasses = array( 'GridField', 'UploadField' ); + + /** + * @var String + */ + protected $bulkEditRequestClass; public function __construct($editableFields = null) @@ -220,8 +225,30 @@ class GridFieldBulkManager implements GridField_HTMLProvider, GridField_ColumnPr public function handlebulkEdit($gridField, $request) { $controller = $gridField->getForm()->Controller(); - $handler = new GridFieldBulkManager_Request($gridField, $this, $controller); + $class = $this->getBulkEditRequestClass(); + $handler = Object::create($class, $gridField, $this, $controller); return $handler->handleRequest($request, DataModel::inst()); } + + /** + * @param String + */ + public function setBulkEditRequestClass($class) { + $this->bulkEditRequestClass = $class; + return $this; + } + + /** + * @return String + */ + public function getBulkEditRequestClass() { + if($this->bulkEditRequestClass) { + return $this->bulkEditRequestClass; + } else if(ClassInfo::exists(get_class($this) . "_ItemRequest")) { + return get_class($this) . "_ItemRequest"; + } else { + return 'GridFieldBulkManager_Request'; + } + } } \ No newline at end of file