These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | /** |
||
4 | * @package comments |
||
5 | */ |
||
6 | class CommentsGridFieldBulkAction extends GridFieldBulkActionHandler { |
||
7 | |||
8 | } |
||
9 | |||
10 | /** |
||
11 | * A {@link GridFieldBulkActionHandler} for bulk marking comments as spam |
||
12 | * |
||
13 | * @package comments |
||
14 | */ |
||
15 | class CommentsGridFieldBulkAction_Handlers extends CommentsGridFieldBulkAction { |
||
16 | |||
17 | private static $allowed_actions = array( |
||
0 ignored issues
–
show
Comprehensibility
introduced
by
Loading history...
|
|||
18 | 'spam', |
||
19 | 'approve', |
||
20 | ); |
||
21 | |||
22 | private static $url_handlers = array( |
||
0 ignored issues
–
show
|
|||
23 | 'spam' => 'spam', |
||
24 | 'approve' => 'approve', |
||
25 | ); |
||
26 | |||
27 | |||
28 | View Code Duplication | public function spam(SS_HTTPRequest $request) { |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
|
|||
29 | $ids = array(); |
||
30 | |||
31 | foreach($this->getRecords() as $record) { |
||
32 | array_push($ids, $record->ID); |
||
33 | $record->markSpam(); |
||
34 | } |
||
35 | |||
36 | $response = new SS_HTTPResponse(Convert::raw2json(array( |
||
37 | 'done' => true, |
||
38 | 'records' => $ids |
||
39 | ))); |
||
40 | |||
41 | $response->addHeader('Content-Type', 'text/json'); |
||
42 | |||
43 | return $response; |
||
44 | } |
||
45 | |||
46 | |||
47 | View Code Duplication | public function approve(SS_HTTPRequest $request) { |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
|
|||
48 | $ids = array(); |
||
49 | |||
50 | foreach($this->getRecords() as $record) { |
||
51 | array_push($ids, $record->ID); |
||
52 | $record->markApproved(); |
||
53 | } |
||
54 | |||
55 | $response = new SS_HTTPResponse(Convert::raw2json(array( |
||
56 | 'done' => true, |
||
57 | 'records' => $ids |
||
58 | ))); |
||
59 | |||
60 | $response->addHeader('Content-Type', 'text/json'); |
||
61 | |||
62 | return $response; |
||
63 | } |
||
64 | } |