From 74afde6d9b7b18e941b138087038dd2011805661 Mon Sep 17 00:00:00 2001 From: Garion Herman Date: Fri, 22 Mar 2019 15:00:19 +1300 Subject: [PATCH] Adjust the output of CommentHandler to use HTTPBulkToolsResponse GridFieldBulkEditingTools has introduced a common output schema in the form of HTTPBulkToolsResponse. This commit adopts that API. --- .../CommentHandler.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/Admin/CommentsGridFieldBulkAction/CommentHandler.php b/src/Admin/CommentsGridFieldBulkAction/CommentHandler.php index f2e1739..2b60ac4 100644 --- a/src/Admin/CommentsGridFieldBulkAction/CommentHandler.php +++ b/src/Admin/CommentsGridFieldBulkAction/CommentHandler.php @@ -3,6 +3,7 @@ namespace SilverStripe\Comments\Admin\CommentsGridFieldBulkAction; use Colymba\BulkManager\BulkAction\Handler; +use Colymba\BulkTools\HTTPBulkToolsResponse; use SilverStripe\Comments\Model\Comment; use SilverStripe\Core\Convert; use SilverStripe\Control\HTTPRequest; @@ -22,17 +23,19 @@ abstract class CommentHandler extends Handler { $ids = []; + $response = new HTTPBulkToolsResponse( + true, + $this->gridField, + 200 + ); + foreach ($this->getRecords() as $comment) { array_push($ids, $comment->ID); $this->updateComment($comment); + $response->addSuccessRecord($comment); } - $response = new HTTPResponse(json_encode([ - 'done' => true, - 'records' => $ids, - ])); - - $response->addHeader('Content-Type', 'application/json'); + $response->setMessage('Changes applied'); return $response; }