| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace SilverStripe\AssetAdmin\Forms; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use SilverStripe\Assets\File; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use SilverStripe\Assets\Folder; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use SilverStripe\Control\Controller; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use SilverStripe\Forms\FieldList; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use SilverStripe\Forms\FormAction; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | use SilverStripe\Forms\HiddenField; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | class FolderCreateFormFactory extends FolderFormFactory | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |     public function getRequiredContext() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |         return ['ParentID']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |     public function getFormFields(Controller $controller, $name, $context = []) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |         // Add status flag before extensions are triggered | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |         $this->beforeExtending('updateFormFields', function (FieldList $fields) use ($context) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |             $record = Folder::create(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |             $fields->insertAfter( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |                 'TitleHeader', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |                 PreviewImageField::create('PreviewImage') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |                     ->setSchemaState([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |                         'data' => [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |                             'mock' => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |                             'preview' => $record->PreviewLink(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |                             'category' => $record instanceof Folder ? 'folder' : $record->appCategory(), | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |                         ] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |                     ]) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |                     ->addExtraClass('editor__file-preview') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |                     ->addExtraClass('editor__file-preview--folder') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |             $fields->push(HiddenField::create('ParentID', null, $context['ParentID'])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |              | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |             $title = $fields->fieldByName('TitleHeader'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |             $titleNew = _t('AssetAdmin.NewFile', 'New {file}', [ 'file' => Folder::config()->singular_name ]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |             $title->setTitle($titleNew); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |         }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |         return parent::getFormFields($controller, $name, $context); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |      * @param File $record | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |      * @return FormAction | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |     protected function getSaveAction($record) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |         return FormAction::create('createfolder', _t('CMSMain.CREATE', 'Create')) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |             ->setIcon('plus-circled') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |             ->setSchemaData(['data' => ['buttonStyle' => 'primary']]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |      * @param File $record | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |      * @return null | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 61 |  |  |      */ | 
            
                                                        
            
                                    
            
            
                | 62 |  |  |     protected function getDeleteAction($record) | 
            
                                                        
            
                                    
            
            
                | 63 |  |  |     { | 
            
                                                        
            
                                    
            
            
                | 64 |  |  |         return null; | 
            
                                                        
            
                                    
            
            
                | 65 |  |  |     } | 
            
                                                        
            
                                    
            
            
                | 66 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 67 |  |  |  | 
            
                        
This error could be the result of:
1. Missing dependencies
PHP Analyzer uses your
composer.jsonfile (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects thecomposer.jsonto be in the root folder of your repository.Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the
requireorrequire-devsection?2. Missing use statement
PHP does not complain about undefined classes in
ìnstanceofchecks. For example, the following PHP code will work perfectly fine:If you have not tested against this specific condition, such errors might go unnoticed.