1 | <?php |
||
2 | |||
3 | namespace Dynamic\Elements\FileList\Elements; |
||
4 | |||
5 | use Colymba\BulkUpload\BulkUploader; |
||
0 ignored issues
–
show
|
|||
6 | use DNADesign\Elemental\Models\BaseElement; |
||
7 | use Dynamic\Elements\FileList\Model\FileListObject; |
||
8 | use SilverStripe\Forms\FieldList; |
||
9 | use SilverStripe\Forms\GridField\GridFieldAddExistingAutocompleter; |
||
10 | use SilverStripe\Forms\GridField\GridFieldDeleteAction; |
||
11 | use SilverStripe\ORM\FieldType\DBField; |
||
12 | use Symbiote\GridFieldExtensions\GridFieldOrderableRows; |
||
13 | |||
14 | class ElementFileList extends BaseElement |
||
15 | { |
||
16 | /** |
||
17 | * @var string |
||
18 | */ |
||
19 | private static $icon = 'font-icon-block-file-list'; |
||
20 | |||
21 | /** |
||
22 | * @var string |
||
23 | */ |
||
24 | private static $singular_name = 'File List Element'; |
||
25 | |||
26 | /** |
||
27 | * @var string |
||
28 | */ |
||
29 | private static $plural_name = 'File List Elements'; |
||
30 | |||
31 | /** |
||
32 | * @var string |
||
33 | */ |
||
34 | private static $table_name = 'ElementFileList'; |
||
35 | |||
36 | /** |
||
37 | * @var array |
||
38 | */ |
||
39 | private static $has_many = [ |
||
40 | 'Files' => FileListObject::class, |
||
41 | ]; |
||
42 | |||
43 | /** |
||
44 | * @var array |
||
45 | */ |
||
46 | private static $owns = [ |
||
47 | 'Files', |
||
48 | ]; |
||
49 | |||
50 | /** |
||
51 | * @var bool |
||
52 | */ |
||
53 | private static $inline_editable = false; |
||
54 | |||
55 | /** |
||
56 | * @return FieldList |
||
57 | */ |
||
58 | public function getCMSFields() |
||
59 | { |
||
60 | $this->beforeUpdateCMSFields(function (FieldList $fields) { |
||
61 | if ($this->ID) { |
||
62 | $field = $fields->dataFieldByName('Files'); |
||
63 | $fields->removeByName('Files'); |
||
64 | |||
65 | $config = $field->getConfig(); |
||
66 | $config |
||
67 | ->addComponents([ |
||
68 | new GridFieldOrderableRows('SortOrder') |
||
69 | ]) |
||
70 | ->removeComponentsByType([ |
||
71 | GridFieldAddExistingAutocompleter::class, |
||
72 | GridFieldDeleteAction::class |
||
73 | ]); |
||
74 | if (class_exists(BulkUploader::class)) { |
||
75 | $config->addComponents([ |
||
76 | new BulkUploader() |
||
77 | ]); |
||
78 | $config->getComponentByType(BulkUploader::class) |
||
79 | ->setUfSetup('setFolderName', 'Uploads/FileList'); |
||
80 | } |
||
81 | $fields->addFieldToTab('Root.Main', $field); |
||
82 | } |
||
83 | }); |
||
84 | |||
85 | return parent::getCMSFields(); |
||
86 | } |
||
87 | |||
88 | /** |
||
89 | * @return DBHTMLText |
||
0 ignored issues
–
show
The type
Dynamic\Elements\FileList\Elements\DBHTMLText was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths
Loading history...
|
|||
90 | */ |
||
91 | public function getSummary() |
||
92 | { |
||
93 | if ($this->Files()->count() == 1) { |
||
94 | $label = ' file'; |
||
95 | } else { |
||
96 | $label = ' files'; |
||
97 | } |
||
98 | return DBField::create_field('HTMLText', $this->Files()->count() . $label)->Summary(20); |
||
99 | } |
||
100 | |||
101 | /** |
||
102 | * @return array |
||
103 | */ |
||
104 | protected function provideBlockSchema() |
||
105 | { |
||
106 | $blockSchema = parent::provideBlockSchema(); |
||
107 | $blockSchema['content'] = $this->getSummary(); |
||
108 | return $blockSchema; |
||
109 | } |
||
110 | |||
111 | /** |
||
112 | * @return string |
||
113 | */ |
||
114 | public function getType() |
||
115 | { |
||
116 | return _t(__CLASS__.'.BlockType', 'File List'); |
||
117 | } |
||
118 | } |
||
119 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths