1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace LeKoala\FilePond; |
4
|
|
|
|
5
|
|
|
use SilverStripe\Assets\File; |
6
|
|
|
use SilverStripe\ORM\DataObject; |
7
|
|
|
use SilverStripe\ORM\DataExtension; |
8
|
|
|
use SilverStripe\AssetAdmin\Controller\AssetAdmin; |
|
|
|
|
9
|
|
|
|
10
|
|
|
class FilePondFileExtension extends DataExtension |
11
|
|
|
{ |
12
|
|
|
private static $db = [ |
|
|
|
|
13
|
|
|
// This helps tracking state of files uploaded through ajax uploaders |
14
|
|
|
"IsTemporary" => "Boolean", |
15
|
|
|
]; |
16
|
|
|
private static $has_one = [ |
|
|
|
|
17
|
|
|
// Record is already used by versioned extensions |
18
|
|
|
// ChangeSetItem already uses Object convention so we use the same |
19
|
|
|
"Object" => DataObject::class, |
20
|
|
|
]; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Get a list of files for the given DataObject |
24
|
|
|
* |
25
|
|
|
* This is just a convenience method, not a public api |
26
|
|
|
* |
27
|
|
|
* @param DataObject $record |
28
|
|
|
* @return DataList|File[] |
29
|
|
|
*/ |
30
|
|
|
public static function getObjectFiles(DataObject $record) |
31
|
|
|
{ |
32
|
|
|
return File::get()->filter([ |
|
|
|
|
33
|
|
|
'ObjectID' => $record->ID, |
34
|
|
|
'ObjectClass' => get_class($record), |
35
|
|
|
])->exclude('IsTemporary', 1); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Called by Upload::loadIntoFile |
40
|
|
|
* @return void |
41
|
|
|
*/ |
42
|
|
|
public function onAfterUpload() |
43
|
|
|
{ |
44
|
|
|
if (File::config()->enable_auto_thumbnail) { |
45
|
|
|
AssetAdmin::create()->generateThumbnails($this->owner); |
46
|
|
|
} |
47
|
|
|
} |
48
|
|
|
} |
49
|
|
|
|
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