| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace SilverStripe\Comments\Admin; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use Colymba\BulkManager\BulkManager; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use SilverStripe\Comments\Admin\CommentsGridFieldBulkAction\ApproveHandler; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use SilverStripe\Comments\Admin\CommentsGridFieldBulkAction\SpamHandler; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use SilverStripe\Core\Convert; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use SilverStripe\Forms\GridField\GridFieldConfig_RecordEditor; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | use SilverStripe\Forms\GridField\GridFieldDataColumns; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | class CommentsGridFieldConfig extends GridFieldConfig_RecordEditor | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 13 |  |  | { | 
            
                                                        
            
                                    
            
            
                | 14 |  |  |     public function __construct($itemsPerPage = 25) | 
            
                                                        
            
                                    
            
            
                | 15 |  |  |     { | 
            
                                                        
            
                                    
            
            
                | 16 |  |  |         parent::__construct($itemsPerPage); | 
            
                                                        
            
                                    
            
            
                | 17 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 18 |  |  |         // $this->addComponent(new GridFieldExportButton()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                        
            
                                    
            
            
                | 19 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 20 |  |  |         $this->addComponent(new CommentsGridFieldAction()); | 
            
                                                        
            
                                    
            
            
                | 21 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 22 |  |  |         // Format column | 
            
                                                        
            
                                    
            
            
                | 23 |  |  |         $columns = $this->getComponentByType(GridFieldDataColumns::class); | 
            
                                                        
            
                                    
            
            
                | 24 |  |  |         $columns->setFieldFormatting(array( | 
            
                                                        
            
                                    
            
            
                | 25 |  |  |             'ParentTitle' => function ($value, &$item) { | 
            
                                                        
            
                                    
            
            
                | 26 |  |  |                 return sprintf( | 
            
                                                        
            
                                    
            
            
                | 27 |  |  |                     '<a href="%s" class="cms-panel-link external-link action" target="_blank">%s</a>', | 
            
                                                        
            
                                    
            
            
                | 28 |  |  |                     Convert::raw2att($item->Link()), | 
            
                                                        
            
                                    
            
            
                | 29 |  |  |                     $item->obj('ParentTitle')->forTemplate() | 
            
                                                        
            
                                    
            
            
                | 30 |  |  |                 ); | 
            
                                                        
            
                                    
            
            
                | 31 |  |  |             } | 
            
                                                        
            
                                    
            
            
                | 32 |  |  |         )); | 
            
                                                        
            
                                    
            
            
                | 33 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 34 |  |  |         // Add bulk option | 
            
                                                        
            
                                    
            
            
                | 35 |  |  |         $manager = new BulkManager(null, false); | 
            
                                                        
            
                                    
            
            
                | 36 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 37 |  |  |         $spamAction = SpamHandler::create()->setLabel(_t(__CLASS__ . '.SPAM', 'Spam')); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                        
            
                                    
            
            
                | 38 |  |  |         $approveAction = ApproveHandler::create()->setLabel(_t(__CLASS__ . '.APPROVE', 'Approve')); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                        
            
                                    
            
            
                | 39 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 40 |  |  |         $manager | 
            
                                                        
            
                                    
            
            
                | 41 |  |  |             ->addBulkAction($spamAction) | 
            
                                                        
            
                                    
            
            
                | 42 |  |  |             ->addBulkAction($approveAction); | 
            
                                                        
            
                                    
            
            
                | 43 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 44 |  |  |         $this->addComponent($manager); | 
            
                                                        
            
                                    
            
            
                | 45 |  |  |     } | 
            
                                                        
            
                                    
            
            
                | 46 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 47 |  |  |  | 
            
                        
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.