We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
@@ -15,18 +15,18 @@ discard block |
||
15 | 15 | private string $crudObjectType; |
16 | 16 | |
17 | 17 | public function __construct( |
18 | - private readonly CrudField|CrudColumn $crudObject, |
|
18 | + private readonly CrudField | CrudColumn $crudObject, |
|
19 | 19 | private readonly array $uploaderConfiguration, |
20 | 20 | private readonly string $macro |
21 | 21 | ) { |
22 | 22 | $this->crudObjectType = is_a($crudObject, CrudField::class) ? 'field' : (is_a($crudObject, CrudColumn::class) ? 'column' : null); |
23 | 23 | |
24 | - if (! $this->crudObjectType) { |
|
24 | + if (!$this->crudObjectType) { |
|
25 | 25 | abort(500, 'Upload handlers only work for CrudField and CrudColumn classes.'); |
26 | 26 | } |
27 | 27 | } |
28 | 28 | |
29 | - public static function handle(CrudField|CrudColumn $crudObject, array $uploaderConfiguration, string $macro, ?array $subfield = null, ?bool $registerModelEvents = true): void |
|
29 | + public static function handle(CrudField | CrudColumn $crudObject, array $uploaderConfiguration, string $macro, ?array $subfield = null, ?bool $registerModelEvents = true): void |
|
30 | 30 | { |
31 | 31 | $instance = new self($crudObject, $uploaderConfiguration, $macro); |
32 | 32 | |
@@ -36,9 +36,9 @@ discard block |
||
36 | 36 | /******************************* |
37 | 37 | * Private methods - implementation |
38 | 38 | *******************************/ |
39 | - private function registerEvents(array|null $subfield = [], ?bool $registerModelEvents = true): void |
|
39 | + private function registerEvents(array | null $subfield = [], ?bool $registerModelEvents = true): void |
|
40 | 40 | { |
41 | - if (! empty($subfield)) { |
|
41 | + if (!empty($subfield)) { |
|
42 | 42 | $this->registerSubfieldEvent($subfield, $registerModelEvents); |
43 | 43 | |
44 | 44 | return; |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | $attributes = $this->crudObject->getAttributes(); |
48 | 48 | $model = $attributes['model'] ?? get_class($this->crudObject->crud()->getModel()); |
49 | 49 | /** @var UploaderInterface */ |
50 | - $uploader = UploaderLocator::for($attributes, $this->uploaderConfiguration, $this->crudObjectType, $this->macro); |
|
50 | + $uploader = UploaderLocator::for ($attributes, $this->uploaderConfiguration, $this->crudObjectType, $this->macro); |
|
51 | 51 | |
52 | 52 | if (isset($attributes['relation_type']) && $attributes['entity'] !== false) { |
53 | 53 | $uploader = $uploader->relationship(true); |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | private function registerSubfieldEvent(array $subfield, bool $registerModelEvents = true): void |
61 | 61 | { |
62 | 62 | /** @var UploaderInterface */ |
63 | - $uploader = UploaderLocator::for($subfield, $this->uploaderConfiguration, $this->crudObjectType, $this->macro); |
|
63 | + $uploader = UploaderLocator::for ($subfield, $this->uploaderConfiguration, $this->crudObjectType, $this->macro); |
|
64 | 64 | $crudObject = $this->crudObject->getAttributes(); |
65 | 65 | $uploader = $uploader->repeats($crudObject['name']); |
66 | 66 | |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | } |
85 | 85 | |
86 | 86 | $subfields = collect($this->crudObject->getAttributes()['subfields']); |
87 | - $subfields = $subfields->map(function ($item) use ($subfield, $uploader) { |
|
87 | + $subfields = $subfields->map(function($item) use ($subfield, $uploader) { |
|
88 | 88 | if ($item['name'] === $subfield['name']) { |
89 | 89 | $item['upload'] = true; |
90 | 90 | $item['disk'] = $uploader->getDisk(); |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | } |
115 | 115 | |
116 | 116 | if ($this->crudObjectType === 'field') { |
117 | - $model::saving(function ($entry) use ($uploader) { |
|
117 | + $model::saving(function($entry) use ($uploader) { |
|
118 | 118 | $updatedCountKey = 'uploaded_'.($uploader->getRepeatableContainerName() ?? $uploader->getName()).'_count'; |
119 | 119 | |
120 | 120 | CRUD::set($updatedCountKey, CRUD::get($updatedCountKey) ?? 0); |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | // is not called in pivot models when loading the relations. |
134 | 134 | $retrieveModel = $this->getModelForRetrieveEvent($model, $uploader); |
135 | 135 | |
136 | - $retrieveModel::retrieved(function ($entry) use ($uploader) { |
|
136 | + $retrieveModel::retrieved(function($entry) use ($uploader) { |
|
137 | 137 | if ($entry->translationEnabled()) { |
138 | 138 | $locale = request('_locale', \App::getLocale()); |
139 | 139 | if (in_array($locale, array_keys($entry->getAvailableLocales()))) { |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | }); |
145 | 145 | } |
146 | 146 | |
147 | - $model::deleting(function ($entry) use ($uploader) { |
|
147 | + $model::deleting(function($entry) use ($uploader) { |
|
148 | 148 | $uploader->deleteUploadedFiles($entry); |
149 | 149 | }); |
150 | 150 | |
@@ -166,13 +166,13 @@ discard block |
||
166 | 166 | $customUploader = isset($uploaderConfiguration['uploader']) && class_exists($uploaderConfiguration['uploader']); |
167 | 167 | |
168 | 168 | if ($customUploader) { |
169 | - return $uploaderConfiguration['uploader']::for($crudObject, $uploaderConfiguration); |
|
169 | + return $uploaderConfiguration['uploader']::for ($crudObject, $uploaderConfiguration); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | $uploader = app('UploadersRepository')->hasUploadFor($crudObject['type'], $this->macro); |
173 | 173 | |
174 | 174 | if ($uploader) { |
175 | - return app('UploadersRepository')->getUploadFor($crudObject['type'], $this->macro)::for($crudObject, $uploaderConfiguration); |
|
175 | + return app('UploadersRepository')->getUploadFor($crudObject['type'], $this->macro)::for ($crudObject, $uploaderConfiguration); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | throw new Exception('Undefined upload type for '.$this->crudObjectType.' type: '.$crudObject['type']); |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | |
189 | 189 | private function getSubfieldModel(array $subfield, UploaderInterface $uploader) |
190 | 190 | { |
191 | - if (! $uploader->isRelationship()) { |
|
191 | + if (!$uploader->isRelationship()) { |
|
192 | 192 | return $subfield['baseModel'] ?? get_class(app('crud')->getModel()); |
193 | 193 | } |
194 | 194 | |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | |
202 | 202 | private function getModelForRetrieveEvent(string $model, UploaderInterface $uploader) |
203 | 203 | { |
204 | - if (! $uploader->isRelationship()) { |
|
204 | + if (!$uploader->isRelationship()) { |
|
205 | 205 | return $model; |
206 | 206 | } |
207 | 207 |
@@ -6,14 +6,14 @@ |
||
6 | 6 | |
7 | 7 | final class UploaderLocator |
8 | 8 | { |
9 | - public static function for(array $crudObject, array $uploaderConfiguration, string $crudObjectType, string $macro): UploaderInterface |
|
9 | + public static function for (array $crudObject, array $uploaderConfiguration, string $crudObjectType, string $macro): UploaderInterface |
|
10 | 10 | { |
11 | 11 | if (isset($uploaderConfiguration['uploader']) && class_exists($uploaderConfiguration['uploader'])) { |
12 | - return $uploaderConfiguration['uploader']::for($crudObject, $uploaderConfiguration); |
|
12 | + return $uploaderConfiguration['uploader']::for ($crudObject, $uploaderConfiguration); |
|
13 | 13 | } |
14 | 14 | |
15 | 15 | if (app('UploadersRepository')->hasUploadFor($crudObject['type'], $macro)) { |
16 | - return app('UploadersRepository')->getUploadFor($crudObject['type'], $macro)::for($crudObject, $uploaderConfiguration); |
|
16 | + return app('UploadersRepository')->getUploadFor($crudObject['type'], $macro)::for ($crudObject, $uploaderConfiguration); |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | throw new Exception('Undefined upload type for '.$crudObjectType.' type: '.$crudObject['type']); |