mirror of
https://github.com/silverstripe/silverstripe-comments
synced 2024-10-22 11:05:49 +02:00
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.
This commit is contained in:
parent
9ff1db403e
commit
74afde6d9b
@ -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('Changes applied');
|
||||||
'done' => true,
|
|
||||||
'records' => $ids,
|
|
||||||
]));
|
|
||||||
|
|
||||||
$response->addHeader('Content-Type', 'application/json');
|
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user