mirror of
https://github.com/silverstripe/silverstripe-comments
synced 2024-10-22 11:05:49 +02:00
Merge pull request #280 from creative-commoners/pulls/master/improve-compat-with-bulk-editing-tools
Adjust the output of CommentHandler to use HTTPBulkToolsResponse
This commit is contained in:
commit
8b178b63ac
@ -14,7 +14,7 @@
|
|||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"silverstripe/framework": "^4.2",
|
"silverstripe/framework": "^4.2",
|
||||||
"colymba/gridfield-bulk-editing-tools": "^3.0"
|
"colymba/gridfield-bulk-editing-tools": "^3.0.0-beta4"
|
||||||
},
|
},
|
||||||
"suggest": {
|
"suggest": {
|
||||||
"ezyang/htmlpurifier": "Standards compliant HTML filter written in PHP",
|
"ezyang/htmlpurifier": "Standards compliant HTML filter written in PHP",
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
namespace SilverStripe\Comments\Admin\CommentsGridFieldBulkAction;
|
namespace SilverStripe\Comments\Admin\CommentsGridFieldBulkAction;
|
||||||
|
|
||||||
use Colymba\BulkManager\BulkAction\Handler;
|
use Colymba\BulkManager\BulkAction\Handler;
|
||||||
|
use Colymba\BulkTools\HTTPBulkToolsResponse;
|
||||||
use SilverStripe\Comments\Model\Comment;
|
use SilverStripe\Comments\Model\Comment;
|
||||||
use SilverStripe\Core\Convert;
|
use SilverStripe\Core\Convert;
|
||||||
use SilverStripe\Control\HTTPRequest;
|
use SilverStripe\Control\HTTPRequest;
|
||||||
@ -22,17 +23,19 @@ abstract class CommentHandler extends Handler
|
|||||||
{
|
{
|
||||||
$ids = [];
|
$ids = [];
|
||||||
|
|
||||||
|
$response = new HTTPBulkToolsResponse(
|
||||||
|
true,
|
||||||
|
$this->gridField,
|
||||||
|
200
|
||||||
|
);
|
||||||
|
|
||||||
foreach ($this->getRecords() as $comment) {
|
foreach ($this->getRecords() as $comment) {
|
||||||
array_push($ids, $comment->ID);
|
array_push($ids, $comment->ID);
|
||||||
$this->updateComment($comment);
|
$this->updateComment($comment);
|
||||||
|
$response->addSuccessRecord($comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
$response = new HTTPResponse(json_encode([
|
$response->setMessage(_t(__CLASS__ . '.CHANGES_APPLIED', 'Changes applied'));
|
||||||
'done' => true,
|
|
||||||
'records' => $ids,
|
|
||||||
]));
|
|
||||||
|
|
||||||
$response->addHeader('Content-Type', 'application/json');
|
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user