GridFieldBulkEditingTools/bulkManager/code/GridFieldBulkActionUnlinkHandler.php

45 lines
961 B
PHP
Raw Normal View History

<?php
/**
2014-05-04 16:12:05 +02:00
* Bulk action handler for unlinking records.
*
* @author colymba
* @package GridFieldBulkEditingTools
2014-05-04 16:12:05 +02:00
* @subpackage BulkManager
*/
class GridFieldBulkActionUnLinkHandler extends GridFieldBulkActionHandler
{
/**
2014-05-11 12:32:21 +02:00
* RequestHandler allowed actions
* @var array
*/
private static $allowed_actions = array('unLink');
2014-05-11 12:32:21 +02:00
/**
2014-05-11 12:32:21 +02:00
* RequestHandler url => action map
* @var array
*/
private static $url_handlers = array(
'unLink' => 'unLink'
);
2014-05-11 12:32:21 +02:00
/**
* Unlink the selected records passed from the unlink bulk action
*
* @param SS_HTTPRequest $request
* @return SS_HTTPResponse List of affected records ID
*/
public function unLink(SS_HTTPRequest $request)
{
$ids = $this->getRecordIDList();
$this->gridField->list->removeMany($ids);
$response = new SS_HTTPResponse(Convert::raw2json(array(
'done' => true,
'records' => $ids
)));
$response->addHeader('Content-Type', 'text/json');
return $response;
}
}