| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace Dynamic\DynamicBlocks\Model; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use Dynamic\DynamicBlocks\Block\PhotoGalleryBlock; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use SilverStripe\Assets\Image; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use SilverStripe\ORM\DataObject; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | class PhotoGalleryBlockImage extends DataObject | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |      * @var string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |     private static $singular_name = 'Gallery Image'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |      * @var string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |     private static $plural_name = 'Gallery Images'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |      * @var array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |     private static $db = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |         'Title' => 'Varchar(255)', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |         'Content' => 'HTMLText', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |         'SortOrder' => 'Int', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |     ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |      * @var array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |     private static $has_one = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |         'PhotoGallery' => PhotoGalleryBlock::class, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |         'Image' => Image::class, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |     ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |      * @var array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |     private static $summary_fields = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |         'Image.CMSThumbnail' => 'Image', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |         'Title' => 'Title', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |     ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |      * @var array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |     private static $searchable_fields = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |         'Title', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |         'Content', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |     ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |      * @return \SilverStripe\Forms\FieldList | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |     public function getCMSFields() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 | 1 |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |         $fields = parent::getCMSFields(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 | 1 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |         $fields->removeByName(array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 | 1 |  |             'SortOrder', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 | 1 |  |             'PhotoGalleryID', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 | 1 |  |         )); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 | 1 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |         $image = $fields->dataFieldByName('Image') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 | 1 |  |         //    ->setFolderName('Uploads/Blocks/PhotoGallery/') | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 | 1 |  |         ; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |         $fields->insertBefore($image, 'Content'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 | 1 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |         return $fields; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |      * @param null $member | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |      * @return bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 | 1 |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |     public function canCreate($member = null, $context = []) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 | 1 |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |         return true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |      * @param null $member | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |      * @return bool | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 88 | 1 |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 89 |  |  |     public function canView($member = null, $context = []) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 90 | 1 |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 91 |  |  |         return true; | 
            
                                                                        
                            
            
                                    
            
            
                | 92 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |      * @param null $member | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |      * @return bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 | 1 |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |     public function canEdit($member = null, $context = []) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 | 1 |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |         return true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |      * @param null $member | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |      * @return bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 | 1 |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |     public function canDelete($member = null, $context = []) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 | 1 |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |         return true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 113 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 114 |  |  |  | 
            
                        
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.