From 3e0cae0cc96e80123bfaad42588edd1c06aaf81e Mon Sep 17 00:00:00 2001 From: Robbie Averill Date: Tue, 3 Apr 2018 12:21:47 +1200 Subject: [PATCH] API Reintroduce abstract handler (previously removed in 192ddbb) and deprecate for future removal --- .../CommentsGridFieldBulkAction/Handler.php | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 src/Admin/CommentsGridFieldBulkAction/Handler.php diff --git a/src/Admin/CommentsGridFieldBulkAction/Handler.php b/src/Admin/CommentsGridFieldBulkAction/Handler.php new file mode 100644 index 0000000..d47be6b --- /dev/null +++ b/src/Admin/CommentsGridFieldBulkAction/Handler.php @@ -0,0 +1,72 @@ + 'spam', + 'approve' => 'approve', + ); + + /** + * @param HTTPRequest $request + * @return HTTPResponse + */ + public function spam(HTTPRequest $request) + { + $ids = array(); + + foreach ($this->getRecords() as $record) { + array_push($ids, $record->ID); + $record->markSpam(); + } + + $response = new HTTPResponse(Convert::raw2json(array( + 'done' => true, + 'records' => $ids + ))); + + $response->addHeader('Content-Type', 'text/json'); + + return $response; + } + + /** + * @param HTTPRequest $request + * @return HTTPResponse + */ + public function approve(HTTPRequest $request) + { + $ids = array(); + + foreach ($this->getRecords() as $record) { + array_push($ids, $record->ID); + $record->markApproved(); + } + + $response = new HTTPResponse(Convert::raw2json(array( + 'done' => true, + 'records' => $ids + ))); + + $response->addHeader('Content-Type', 'text/json'); + + return $response; + } +}