We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | */ |
| 35 | 35 | public function markAsHandled(string $objectName): void |
| 36 | 36 | { |
| 37 | - if (! in_array($objectName, $this->handledUploaders)) { |
|
| 37 | + if (!in_array($objectName, $this->handledUploaders)) { |
|
| 38 | 38 | $this->handledUploaders[] = $objectName; |
| 39 | 39 | } |
| 40 | 40 | } |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | */ |
| 61 | 61 | public function getUploadFor(string $objectType, string $group): string |
| 62 | 62 | { |
| 63 | - if (! $this->hasUploadFor($objectType, $group)) { |
|
| 63 | + if (!$this->hasUploadFor($objectType, $group)) { |
|
| 64 | 64 | throw new \Exception('There is no uploader defined for the given field type.'); |
| 65 | 65 | } |
| 66 | 66 | |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | { |
| 75 | 75 | // ensure all uploaders implement the UploaderInterface |
| 76 | 76 | foreach ($uploaders as $uploader) { |
| 77 | - if (! is_a($uploader, UploaderInterface::class, true)) { |
|
| 77 | + if (!is_a($uploader, UploaderInterface::class, true)) { |
|
| 78 | 78 | throw new \Exception('The uploader class must implement the UploaderInterface.'); |
| 79 | 79 | } |
| 80 | 80 | } |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | */ |
| 95 | 95 | public function registerRepeatableUploader(string $uploadName, UploaderInterface $uploader): void |
| 96 | 96 | { |
| 97 | - if (! array_key_exists($uploadName, $this->repeatableUploaders) || ! in_array($uploader, $this->repeatableUploaders[$uploadName])) { |
|
| 97 | + if (!array_key_exists($uploadName, $this->repeatableUploaders) || !in_array($uploader, $this->repeatableUploaders[$uploadName])) { |
|
| 98 | 98 | $this->repeatableUploaders[$uploadName][] = $uploader; |
| 99 | 99 | } |
| 100 | 100 | } |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | */ |
| 129 | 129 | public function getRegisteredUploadNames(string $uploadName): array |
| 130 | 130 | { |
| 131 | - return array_map(function ($uploader) { |
|
| 131 | + return array_map(function($uploader) { |
|
| 132 | 132 | return $uploader->getName(); |
| 133 | 133 | }, $this->getRepeatableUploadersFor($uploadName)); |
| 134 | 134 | } |
@@ -159,11 +159,11 @@ discard block |
||
| 159 | 159 | |
| 160 | 160 | $uploaders = $this->getRepeatableUploadersFor($repeatableContainerName); |
| 161 | 161 | |
| 162 | - $uploader = Arr::first($uploaders, function ($uploader) use ($requestInputName) { |
|
| 162 | + $uploader = Arr::first($uploaders, function($uploader) use ($requestInputName) { |
|
| 163 | 163 | return $uploader->getName() === $requestInputName; |
| 164 | 164 | }); |
| 165 | 165 | |
| 166 | - if (! $uploader) { |
|
| 166 | + if (!$uploader) { |
|
| 167 | 167 | abort(500, 'Could not find the field in the repeatable uploaders.'); |
| 168 | 168 | } |
| 169 | 169 | |
@@ -174,16 +174,16 @@ discard block |
||
| 174 | 174 | abort(500, 'Could not find the field in the CRUD fields.'); |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | - if (! $uploaderMacro = $this->getUploadCrudObjectMacroType($crudObject)) { |
|
| 177 | + if (!$uploaderMacro = $this->getUploadCrudObjectMacroType($crudObject)) { |
|
| 178 | 178 | abort(500, 'There is no uploader defined for the given field type.'); |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | - if (! $this->isValidUploadField($crudObject, $uploaderMacro)) { |
|
| 181 | + if (!$this->isValidUploadField($crudObject, $uploaderMacro)) { |
|
| 182 | 182 | abort(500, 'Invalid field for upload.'); |
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | $uploaderConfiguration = $crudObject[$uploaderMacro] ?? []; |
| 186 | - $uploaderConfiguration = ! is_array($uploaderConfiguration) ? [] : $uploaderConfiguration; |
|
| 186 | + $uploaderConfiguration = !is_array($uploaderConfiguration) ? [] : $uploaderConfiguration; |
|
| 187 | 187 | $uploaderClass = $this->getUploadFor($crudObject['type'], $uploaderMacro); |
| 188 | 188 | |
| 189 | 189 | return new $uploaderClass(['name' => $requestInputName], $uploaderConfiguration); |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | /** |
| 193 | 193 | * Get the upload field macro type for the given object. |
| 194 | 194 | */ |
| 195 | - private function getUploadCrudObjectMacroType(array $crudObject): string|null |
|
| 195 | + private function getUploadCrudObjectMacroType(array $crudObject): string | null |
|
| 196 | 196 | { |
| 197 | 197 | return isset($crudObject['withFiles']) ? 'withFiles' : (isset($crudObject['withMedia']) ? 'withMedia' : null); |
| 198 | 198 | } |
@@ -201,11 +201,11 @@ discard block |
||
| 201 | 201 | { |
| 202 | 202 | if (Str::contains($crudObject['name'], '#')) { |
| 203 | 203 | $container = Str::before($crudObject['name'], '#'); |
| 204 | - $field = array_filter(CRUD::fields()[$container]['subfields'] ?? [], function ($item) use ($crudObject, $uploaderMacro) { |
|
| 204 | + $field = array_filter(CRUD::fields()[$container]['subfields'] ?? [], function($item) use ($crudObject, $uploaderMacro) { |
|
| 205 | 205 | return $item['name'] === $crudObject['name'] && in_array($item['type'], $this->getAjaxUploadTypes($uploaderMacro)); |
| 206 | 206 | }); |
| 207 | 207 | |
| 208 | - return ! empty($field); |
|
| 208 | + return !empty($field); |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | return in_array($crudObject['type'], $this->getAjaxUploadTypes($uploaderMacro)); |
@@ -14,18 +14,18 @@ discard block |
||
| 14 | 14 | private string $crudObjectType; |
| 15 | 15 | |
| 16 | 16 | public function __construct( |
| 17 | - private readonly CrudField|CrudColumn $crudObject, |
|
| 17 | + private readonly CrudField | CrudColumn $crudObject, |
|
| 18 | 18 | private readonly array $uploaderConfiguration, |
| 19 | 19 | private readonly string $macro |
| 20 | 20 | ) { |
| 21 | 21 | $this->crudObjectType = is_a($crudObject, CrudField::class) ? 'field' : (is_a($crudObject, CrudColumn::class) ? 'column' : null); |
| 22 | 22 | |
| 23 | - if (! $this->crudObjectType) { |
|
| 23 | + if (!$this->crudObjectType) { |
|
| 24 | 24 | abort(500, 'Upload handlers only work for CrudField and CrudColumn classes.'); |
| 25 | 25 | } |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | - public static function handle(CrudField|CrudColumn $crudObject, array $uploaderConfiguration, string $macro, ?array $subfield = null, ?bool $registerModelEvents = true): void |
|
| 28 | + public static function handle(CrudField | CrudColumn $crudObject, array $uploaderConfiguration, string $macro, ?array $subfield = null, ?bool $registerModelEvents = true): void |
|
| 29 | 29 | { |
| 30 | 30 | $instance = new self($crudObject, $uploaderConfiguration, $macro); |
| 31 | 31 | |
@@ -35,9 +35,9 @@ discard block |
||
| 35 | 35 | /******************************* |
| 36 | 36 | * Private methods - implementation |
| 37 | 37 | *******************************/ |
| 38 | - private function registerEvents(array|null $subfield = [], ?bool $registerModelEvents = true): void |
|
| 38 | + private function registerEvents(array | null $subfield = [], ?bool $registerModelEvents = true): void |
|
| 39 | 39 | { |
| 40 | - if (! empty($subfield)) { |
|
| 40 | + if (!empty($subfield)) { |
|
| 41 | 41 | $this->registerSubfieldEvent($subfield, $registerModelEvents); |
| 42 | 42 | |
| 43 | 43 | return; |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | $subfields = collect($this->crudObject->getAttributes()['subfields']); |
| 85 | - $subfields = $subfields->map(function ($item) use ($subfield, $uploader) { |
|
| 85 | + $subfields = $subfields->map(function($item) use ($subfield, $uploader) { |
|
| 86 | 86 | if ($item['name'] === $subfield['name']) { |
| 87 | 87 | $item['upload'] = true; |
| 88 | 88 | $item['disk'] = $uploader->getDisk(); |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | if ($this->crudObjectType === 'field') { |
| 115 | - $model::saving(function ($entry) use ($uploader) { |
|
| 115 | + $model::saving(function($entry) use ($uploader) { |
|
| 116 | 116 | $entry = $uploader->storeUploadedFiles($entry); |
| 117 | 117 | }); |
| 118 | 118 | } |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | // is not called in pivot models when loading the relations. |
| 126 | 126 | $retrieveModel = $this->getModelForRetrieveEvent($model, $uploader); |
| 127 | 127 | |
| 128 | - $retrieveModel::retrieved(function ($entry) use ($uploader) { |
|
| 128 | + $retrieveModel::retrieved(function($entry) use ($uploader) { |
|
| 129 | 129 | if ($entry->translationEnabled()) { |
| 130 | 130 | $locale = request('_locale', app()->getLocale()); |
| 131 | 131 | if (in_array($locale, array_keys($entry->getAvailableLocales()))) { |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | }); |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | - $model::deleting(function ($entry) use ($uploader) { |
|
| 139 | + $model::deleting(function($entry) use ($uploader) { |
|
| 140 | 140 | $uploader->deleteUploadedFiles($entry); |
| 141 | 141 | }); |
| 142 | 142 | |
@@ -157,18 +157,18 @@ discard block |
||
| 157 | 157 | { |
| 158 | 158 | $hasCustomUploader = isset($uploaderConfiguration['uploader']); |
| 159 | 159 | |
| 160 | - if ($hasCustomUploader && ! is_a($uploaderConfiguration['uploader'], UploaderInterface::class, true)) { |
|
| 160 | + if ($hasCustomUploader && !is_a($uploaderConfiguration['uploader'], UploaderInterface::class, true)) { |
|
| 161 | 161 | throw new Exception('Invalid uploader class provided for '.$this->crudObjectType.' type: '.$crudObject['type']); |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | if ($hasCustomUploader) { |
| 165 | - return $uploaderConfiguration['uploader']::for($crudObject, $uploaderConfiguration); |
|
| 165 | + return $uploaderConfiguration['uploader']::for ($crudObject, $uploaderConfiguration); |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | $uploader = app('UploadersRepository')->hasUploadFor($crudObject['type'], $this->macro); |
| 169 | 169 | |
| 170 | 170 | if ($uploader) { |
| 171 | - return app('UploadersRepository')->getUploadFor($crudObject['type'], $this->macro)::for($crudObject, $uploaderConfiguration); |
|
| 171 | + return app('UploadersRepository')->getUploadFor($crudObject['type'], $this->macro)::for ($crudObject, $uploaderConfiguration); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | throw new Exception('Undefined upload type for '.$this->crudObjectType.' type: '.$crudObject['type']); |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | |
| 190 | 190 | private function getSubfieldModel(array $subfield, UploaderInterface $uploader) |
| 191 | 191 | { |
| 192 | - if (! $uploader->isRelationship()) { |
|
| 192 | + if (!$uploader->isRelationship()) { |
|
| 193 | 193 | return $subfield['baseModel'] ?? get_class(app('crud')->getModel()); |
| 194 | 194 | } |
| 195 | 195 | |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | |
| 203 | 203 | private function getModelForRetrieveEvent(string $model, UploaderInterface $uploader) |
| 204 | 204 | { |
| 205 | - if (! $uploader->isRelationship()) { |
|
| 205 | + if (!$uploader->isRelationship()) { |
|
| 206 | 206 | return $model; |
| 207 | 207 | } |
| 208 | 208 | |