FEATURE: Added ability to change the request class

Similar to GridFieldDetailForm
This commit is contained in:
Mellisa Hankins 2013-07-11 16:01:53 +10:00
parent 66a43c890a
commit a306ba448b

View File

@ -29,6 +29,11 @@ class GridFieldBulkManager implements GridField_HTMLProvider, GridField_ColumnPr
*/ */
protected $forbiddenFieldsClasses = array( 'GridField', 'UploadField' ); protected $forbiddenFieldsClasses = array( 'GridField', 'UploadField' );
/**
* @var String
*/
protected $bulkEditRequestClass;
public function __construct($editableFields = null) public function __construct($editableFields = null)
{ {
@ -220,8 +225,30 @@ class GridFieldBulkManager implements GridField_HTMLProvider, GridField_ColumnPr
public function handlebulkEdit($gridField, $request) public function handlebulkEdit($gridField, $request)
{ {
$controller = $gridField->getForm()->Controller(); $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()); 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';
}
}
} }