mirror of
https://github.com/colymba/GridFieldBulkEditingTools.git
synced 2024-10-22 11:05:57 +02:00
7221897f27
* Basic SS4 compat: Implemented namespacing, updated some Image manipulations, readmes, composer configuration * Add bootstrap form styles to the bulk manager * API Rename classes to be less confusing with the namespaces
54 lines
1.2 KiB
PHP
54 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace Colymba\BulkManager\BulkAction;
|
|
|
|
use Colymba\BulkManager\BulkAction\Handler;
|
|
use SilverStripe\Core\Convert;
|
|
use SilverStripe\Control\HTTPRequest;
|
|
use SilverStripe\Control\HTTPResponse;
|
|
|
|
/**
|
|
* Bulk action handler for unlinking records.
|
|
*
|
|
* @author colymba
|
|
*/
|
|
class UnlinkHandler extends Handler
|
|
{
|
|
/**
|
|
* RequestHandler allowed actions.
|
|
*
|
|
* @var array
|
|
*/
|
|
private static $allowed_actions = array('unLink');
|
|
|
|
/**
|
|
* RequestHandler url => action map.
|
|
*
|
|
* @var array
|
|
*/
|
|
private static $url_handlers = array(
|
|
'unLink' => 'unLink',
|
|
);
|
|
|
|
/**
|
|
* Unlink the selected records passed from the unlink bulk action.
|
|
*
|
|
* @param HTTPRequest $request
|
|
*
|
|
* @return HTTPResponse List of affected records ID
|
|
*/
|
|
public function unLink(HTTPRequest $request)
|
|
{
|
|
$ids = $this->getRecordIDList();
|
|
$this->gridField->list->removeMany($ids);
|
|
|
|
$response = new HTTPResponse(Convert::raw2json(array(
|
|
'done' => true,
|
|
'records' => $ids,
|
|
)));
|
|
$response->addHeader('Content-Type', 'text/json');
|
|
|
|
return $response;
|
|
}
|
|
}
|