We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | |
12 | 12 | final class RegisterUploadEvents |
13 | 13 | { |
14 | - public function __construct(private readonly CrudField|CrudColumn $crudObject, private readonly array $uploadDefinition) |
|
14 | + public function __construct(private readonly CrudField | CrudColumn $crudObject, private readonly array $uploadDefinition) |
|
15 | 15 | { |
16 | 16 | } |
17 | 17 | |
@@ -34,13 +34,13 @@ discard block |
||
34 | 34 | |
35 | 35 | $crudObjectType = is_a($crudObject, CrudField::class) ? 'field' : (is_a($crudObject, CrudColumn::class) ? 'column' : null); |
36 | 36 | |
37 | - if (! $crudObjectType) { |
|
37 | + if (!$crudObjectType) { |
|
38 | 38 | abort(500, 'Upload handlers only work for CrudField and CrudColumn classes.'); |
39 | 39 | } |
40 | 40 | |
41 | 41 | $attributes['crudObjectType'] = $crudObjectType; |
42 | 42 | |
43 | - if (! isset($attributes['subfields'])) { |
|
43 | + if (!isset($attributes['subfields'])) { |
|
44 | 44 | $uploaderType = $instance->getUploader($attributes, $uploadDefinition); |
45 | 45 | $instance->setupModelEvents($attributes['entryClass'], $uploaderType); |
46 | 46 | self::setupUploadConfigsInCrudObject($crudObject, $uploaderType); |
@@ -59,14 +59,14 @@ discard block |
||
59 | 59 | * @param UploaderInterface|RepeatableUploaderInterface $uploader |
60 | 60 | * @return void |
61 | 61 | */ |
62 | - private function setupModelEvents(string $model, UploaderInterface|RepeatableUploaderInterface $uploader): void |
|
62 | + private function setupModelEvents(string $model, UploaderInterface | RepeatableUploaderInterface $uploader): void |
|
63 | 63 | { |
64 | 64 | if (app('UploadStore')->isUploadHandled($uploader->getName())) { |
65 | 65 | return; |
66 | 66 | } |
67 | 67 | |
68 | 68 | if ($uploader->getCrudObjectType() === 'field') { |
69 | - $model::saving(function ($entry) use ($uploader) { |
|
69 | + $model::saving(function($entry) use ($uploader) { |
|
70 | 70 | $updatedCountKey = 'uploaded_'.$uploader->getName().'_count'; |
71 | 71 | |
72 | 72 | CRUD::set($updatedCountKey, CRUD::get($updatedCountKey) ?? 0); |
@@ -77,18 +77,18 @@ discard block |
||
77 | 77 | }); |
78 | 78 | } |
79 | 79 | |
80 | - $model::retrieved(function ($entry) use ($uploader) { |
|
80 | + $model::retrieved(function($entry) use ($uploader) { |
|
81 | 81 | $entry = $uploader->retrieveUploadedFile($entry); |
82 | 82 | }); |
83 | 83 | |
84 | - $model::deleting(function ($entry) use ($uploader) { |
|
84 | + $model::deleting(function($entry) use ($uploader) { |
|
85 | 85 | if (is_a($uploader, RepeatableUploaderInterface::class)) { |
86 | 86 | $uploader->deleteUploadedFile($entry); |
87 | 87 | |
88 | 88 | return; |
89 | 89 | } |
90 | 90 | if ($uploader->deleteWhenEntryIsDeleted) { |
91 | - if (! in_array(SoftDeletes::class, class_uses_recursive($entry), true)) { |
|
91 | + if (!in_array(SoftDeletes::class, class_uses_recursive($entry), true)) { |
|
92 | 92 | $uploader->deleteUploadedFile($entry); |
93 | 93 | } else { |
94 | 94 | if ($entry->forceDeleting === true) { |
@@ -121,8 +121,7 @@ discard block |
||
121 | 121 | $subfielduploadDefinition = $subfield['withUploads'] ?? $subfield['withMedia']; |
122 | 122 | |
123 | 123 | $subfielduploadDefinition = is_array($subfielduploadDefinition) ? |
124 | - array_merge($uploadDefinition, $subfielduploadDefinition) : |
|
125 | - $uploadDefinition; |
|
124 | + array_merge($uploadDefinition, $subfielduploadDefinition) : $uploadDefinition; |
|
126 | 125 | |
127 | 126 | $uploaderType = $this->getUploader($subfield, $subfielduploadDefinition); |
128 | 127 | |
@@ -131,7 +130,7 @@ discard block |
||
131 | 130 | } |
132 | 131 | |
133 | 132 | foreach ($repeatableDefinitions as $model => $uploaderTypes) { |
134 | - $repeatableDefinition = app('UploadStore')->getUploadFor('repeatable', $uploadDefinition['uploaders'] ?? null)::for($crudObject)->uploads(...$uploaderTypes); |
|
133 | + $repeatableDefinition = app('UploadStore')->getUploadFor('repeatable', $uploadDefinition['uploaders'] ?? null)::for ($crudObject)->uploads(...$uploaderTypes); |
|
135 | 134 | $this->setupModelEvents($model, $repeatableDefinition); |
136 | 135 | } |
137 | 136 | } |
@@ -153,11 +152,11 @@ discard block |
||
153 | 152 | private function getUploader(array $crudObject, array $uploadDefinition) |
154 | 153 | { |
155 | 154 | if (isset($uploadDefinition['uploaderType'])) { |
156 | - return $uploadDefinition['uploaderType']::for($crudObject, $uploadDefinition); |
|
155 | + return $uploadDefinition['uploaderType']::for ($crudObject, $uploadDefinition); |
|
157 | 156 | } |
158 | 157 | $uploaders = $uploadDefinition['uploaders'] ?? null; |
159 | 158 | if (app('UploadStore')->hasUploadFor($crudObject['type'], $uploaders)) { |
160 | - return app('UploadStore')->getUploadFor($crudObject['type'], $uploaders)::for($crudObject, $uploadDefinition); |
|
159 | + return app('UploadStore')->getUploadFor($crudObject['type'], $uploaders)::for ($crudObject, $uploadDefinition); |
|
161 | 160 | } |
162 | 161 | |
163 | 162 | throw new Exception('Undefined upload type for '.$crudObject['crudObjectType'].' type: '.$crudObject['type']); |
@@ -170,7 +169,7 @@ discard block |
||
170 | 169 | * @param UploaderInterface $uploader |
171 | 170 | * @return void |
172 | 171 | */ |
173 | - private static function setupUploadConfigsInCrudObject(CrudField|CrudColumn $crudObject, UploaderInterface $uploader) |
|
172 | + private static function setupUploadConfigsInCrudObject(CrudField | CrudColumn $crudObject, UploaderInterface $uploader) |
|
174 | 173 | { |
175 | 174 | $crudObject->upload(true)->disk($uploader->disk)->prefix($uploader->path); |
176 | 175 | } |
@@ -131,7 +131,9 @@ |
||
131 | 131 | } |
132 | 132 | |
133 | 133 | foreach ($repeatableDefinitions as $model => $uploaderTypes) { |
134 | - $repeatableDefinition = app('UploadStore')->getUploadFor('repeatable', $uploadDefinition['uploaders'] ?? null)::for($crudObject)->uploads(...$uploaderTypes); |
|
134 | + $repeatableDefinition = app('UploadStore')->getUploadFor('repeatable', $uploadDefinition['uploaders'] ?? null)::for($crudObject) { |
|
135 | + ->uploads(...$uploaderTypes); |
|
136 | + } |
|
135 | 137 | $this->setupModelEvents($model, $repeatableDefinition); |
136 | 138 | } |
137 | 139 | } |