We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
@@ -13,13 +13,13 @@ discard block |
||
| 13 | 13 | private string $crudObjectType; |
| 14 | 14 | |
| 15 | 15 | public function __construct( |
| 16 | - private readonly CrudField|CrudColumn $crudObject, |
|
| 16 | + private readonly CrudField | CrudColumn $crudObject, |
|
| 17 | 17 | private readonly array $uploaderConfiguration, |
| 18 | 18 | private readonly string $macro |
| 19 | 19 | ) { |
| 20 | 20 | $this->crudObjectType = is_a($crudObject, CrudField::class) ? 'field' : (is_a($crudObject, CrudColumn::class) ? 'column' : null); |
| 21 | 21 | |
| 22 | - if (! $this->crudObjectType) { |
|
| 22 | + if (!$this->crudObjectType) { |
|
| 23 | 23 | abort(500, 'Upload handlers only work for CrudField and CrudColumn classes.'); |
| 24 | 24 | } |
| 25 | 25 | } |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | if ($this->crudObjectType === 'field') { |
| 59 | - $model::saving(function ($entry) use ($uploader) { |
|
| 59 | + $model::saving(function($entry) use ($uploader) { |
|
| 60 | 60 | $updatedCountKey = 'uploaded_'.($uploader->getRepeatableContainerName() ?? $uploader->getName()).'_count'; |
| 61 | 61 | |
| 62 | 62 | CRUD::set($updatedCountKey, CRUD::get($updatedCountKey) ?? 0); |
@@ -69,11 +69,11 @@ discard block |
||
| 69 | 69 | }); |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - $model::retrieved(function ($entry) use ($uploader) { |
|
| 72 | + $model::retrieved(function($entry) use ($uploader) { |
|
| 73 | 73 | $entry = $uploader->retrieveUploadedFile($entry); |
| 74 | 74 | }); |
| 75 | 75 | |
| 76 | - $model::deleting(function ($entry) use ($uploader) { |
|
| 76 | + $model::deleting(function($entry) use ($uploader) { |
|
| 77 | 77 | $uploader->deleteUploadedFile($entry); |
| 78 | 78 | }); |
| 79 | 79 | |
@@ -86,9 +86,9 @@ discard block |
||
| 86 | 86 | * @param array|null $subfield |
| 87 | 87 | * @return void |
| 88 | 88 | */ |
| 89 | - public function registerEvents(array|null $subfield = []) |
|
| 89 | + public function registerEvents(array | null $subfield = []) |
|
| 90 | 90 | { |
| 91 | - if (! empty($subfield)) { |
|
| 91 | + if (!empty($subfield)) { |
|
| 92 | 92 | $this->registerSubfieldEvent($subfield); |
| 93 | 93 | return; |
| 94 | 94 | } |
@@ -134,12 +134,12 @@ discard block |
||
| 134 | 134 | |
| 135 | 135 | // for subfields, we only register one event so that we have access to the repeatable container name. |
| 136 | 136 | // all the uploaders for a given container are stored in the UploadersRepository. |
| 137 | - if (! app('UploadersRepository')->hasUploadersRegisteredFor($uploader->getRepeatableContainerName())) { |
|
| 137 | + if (!app('UploadersRepository')->hasUploadersRegisteredFor($uploader->getRepeatableContainerName())) { |
|
| 138 | 138 | $this->setupModelEvents($model, $uploader); |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | $subfields = collect($this->crudObject->getAttributes()['subfields']); |
| 142 | - $subfields = $subfields->map(function ($item) use ($subfield, $uploader) { |
|
| 142 | + $subfields = $subfields->map(function($item) use ($subfield, $uploader) { |
|
| 143 | 143 | if ($item['name'] === $subfield['name']) { |
| 144 | 144 | $item['upload'] = true; |
| 145 | 145 | $item['disk'] = $uploader->getDisk(); |
@@ -175,11 +175,11 @@ discard block |
||
| 175 | 175 | private function getUploader(array $crudObject, array $uploaderConfiguration) |
| 176 | 176 | { |
| 177 | 177 | if (isset($uploaderConfiguration['uploaderType'])) { |
| 178 | - return $uploaderConfiguration['uploaderType']::for($crudObject, $uploaderConfiguration); |
|
| 178 | + return $uploaderConfiguration['uploaderType']::for ($crudObject, $uploaderConfiguration); |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | if (app('UploadersRepository')->hasUploadFor($crudObject['type'], $this->macro)) { |
| 182 | - return app('UploadersRepository')->getUploadFor($crudObject['type'], $this->macro)::for($crudObject, $uploaderConfiguration); |
|
| 182 | + return app('UploadersRepository')->getUploadFor($crudObject['type'], $this->macro)::for ($crudObject, $uploaderConfiguration); |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | throw new Exception('Undefined upload type for '.$this->crudObjectType.' type: '.$crudObject['type']); |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | * @param mixed $value |
| 90 | 90 | * @return Model |
| 91 | 91 | */ |
| 92 | - private function uploadRelationshipFiles(Model $entry, mixed $value){ |
|
| 92 | + private function uploadRelationshipFiles(Model $entry, mixed $value) { |
|
| 93 | 93 | $modelCount = CRUD::get('uploaded_'.$this->repeatableContainerName.'_count'); |
| 94 | 94 | $value = $value->slice($modelCount, 1)->toArray(); |
| 95 | 95 | |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | foreach (app('UploadersRepository')->getRegisteredUploadersFor($this->repeatableContainerName) as $uploader) { |
| 115 | 115 | $uploadedValues = $uploader->uploadRepeatableFile($entry, $value->pluck($uploader->getName())->toArray()); |
| 116 | 116 | |
| 117 | - $value = $value->map(function ($item, $key) use ($uploadedValues, $uploader) { |
|
| 117 | + $value = $value->map(function($item, $key) use ($uploadedValues, $uploader) { |
|
| 118 | 118 | $item[$uploader->getName()] = $uploadedValues[$key] ?? null; |
| 119 | 119 | |
| 120 | 120 | return $item; |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | protected function getPreviousRepeatableValues(Model $entry) |
| 134 | 134 | { |
| 135 | 135 | $previousValues = json_decode($entry->getOriginal($this->repeatableContainerName), true); |
| 136 | - if (! empty($previousValues)) { |
|
| 136 | + if (!empty($previousValues)) { |
|
| 137 | 137 | $previousValues = array_column($previousValues, $this->getName()); |
| 138 | 138 | } |
| 139 | 139 | |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | { |
| 151 | 151 | $items = CRUD::getRequest()->input('_order_'.$this->repeatableContainerName) ?? []; |
| 152 | 152 | |
| 153 | - array_walk($items, function (&$key, $value) { |
|
| 153 | + array_walk($items, function(&$key, $value) { |
|
| 154 | 154 | $requestValue = $key[$this->getName()] ?? null; |
| 155 | 155 | $key = $this->isMultiple ? (is_string($requestValue) ? explode(',', $requestValue) : $requestValue) : $requestValue; |
| 156 | 156 | }); |
@@ -188,12 +188,12 @@ discard block |
||
| 188 | 188 | |
| 189 | 189 | $repeatableValues = collect($entry->{$this->getName()}); |
| 190 | 190 | foreach (app('UploadersRepository')->getRegisteredUploadersFor($this->repeatableContainerName) as $upload) { |
| 191 | - if (! $upload->shouldDeleteFiles()) { |
|
| 191 | + if (!$upload->shouldDeleteFiles()) { |
|
| 192 | 192 | continue; |
| 193 | 193 | } |
| 194 | 194 | $values = $repeatableValues->pluck($upload->getName())->toArray(); |
| 195 | 195 | foreach ($values as $value) { |
| 196 | - if (! $value) { |
|
| 196 | + if (!$value) { |
|
| 197 | 197 | continue; |
| 198 | 198 | } |
| 199 | 199 | if (is_array($value)) { |
@@ -29,11 +29,11 @@ discard block |
||
| 29 | 29 | { |
| 30 | 30 | $fileGeneratorClass = $fileNameGenerator ?? config('backpack.crud.file_name_generator'); |
| 31 | 31 | |
| 32 | - if (! class_exists($fileGeneratorClass)) { |
|
| 32 | + if (!class_exists($fileGeneratorClass)) { |
|
| 33 | 33 | throw new \Exception("The file name generator class [{$fileGeneratorClass}] does not exist."); |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - if(! class_implements($fileGeneratorClass, FileNameGeneratorInterface::class)) { |
|
| 36 | + if (!class_implements($fileGeneratorClass, FileNameGeneratorInterface::class)) { |
|
| 37 | 37 | throw new \Exception("The file name generator class [{$fileGeneratorClass}] must implement the [".FileNameGeneratorInterface::class."] interface."); |
| 38 | 38 | } |
| 39 | 39 | |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | * @return string |
| 48 | 48 | */ |
| 49 | 49 | public function getFileName($file) { |
| 50 | - if($this->fileName) { |
|
| 50 | + if ($this->fileName) { |
|
| 51 | 51 | return is_callable($this->fileName) ? ($this->fileName)($file, $this) : $this->fileName; |
| 52 | 52 | } |
| 53 | 53 | |
@@ -14,7 +14,7 @@ |
||
| 14 | 14 | $value = $value ?? CRUD::getRequest()->get($this->getName()); |
| 15 | 15 | $previousImage = $entry->getOriginal($this->getName()); |
| 16 | 16 | |
| 17 | - if (! $value && $previousImage) { |
|
| 17 | + if (!$value && $previousImage) { |
|
| 18 | 18 | Storage::disk($this->getDisk())->delete($previousImage); |
| 19 | 19 | |
| 20 | 20 | return null; |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | { |
| 185 | 185 | $value = $entry->{$this->name}; |
| 186 | 186 | |
| 187 | - if ($this->isMultiple && ! isset($entry->getCasts()[$this->name]) && is_string($value)) { |
|
| 187 | + if ($this->isMultiple && !isset($entry->getCasts()[$this->name]) && is_string($value)) { |
|
| 188 | 188 | $entry->{$this->name} = json_decode($value, true); |
| 189 | 189 | } else { |
| 190 | 190 | $entry->{$this->name} = Str::after($value, $this->path); |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | public function deleteUploadedFile(Model $entry) |
| 204 | 204 | { |
| 205 | 205 | if ($this->deleteWhenEntryIsDeleted) { |
| 206 | - if (! in_array(SoftDeletes::class, class_uses_recursive($entry), true)) { |
|
| 206 | + if (!in_array(SoftDeletes::class, class_uses_recursive($entry), true)) { |
|
| 207 | 207 | $this->performFileDeletion($entry); |
| 208 | 208 | return; |
| 209 | 209 | } |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | $values = $entry->{$this->name}; |
| 226 | 226 | |
| 227 | 227 | if ($this->isMultiple) { |
| 228 | - if (! isset($entry->getCasts()[$this->name]) && is_string($values)) { |
|
| 228 | + if (!isset($entry->getCasts()[$this->name]) && is_string($values)) { |
|
| 229 | 229 | $values = json_decode($values, true); |
| 230 | 230 | } |
| 231 | 231 | } else { |
@@ -246,7 +246,7 @@ discard block |
||
| 246 | 246 | */ |
| 247 | 247 | private function performFileDeletion($entry) |
| 248 | 248 | { |
| 249 | - if ($this->isRelationship || ! $this->isRepeatable) { |
|
| 249 | + if ($this->isRelationship || !$this->isRepeatable) { |
|
| 250 | 250 | $this->deleteFiles($entry); |
| 251 | 251 | return; |
| 252 | 252 | } |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | * @param array $definition |
| 262 | 262 | * @return self |
| 263 | 263 | */ |
| 264 | - public static function for(array $crudObject, array $definition) |
|
| 264 | + public static function for (array $crudObject, array $definition) |
|
| 265 | 265 | { |
| 266 | 266 | return new static($crudObject, $definition); |
| 267 | 267 | } |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | |
| 10 | 10 | class MultipleFiles extends Uploader |
| 11 | 11 | { |
| 12 | - public static function for(array $field, $configuration) |
|
| 12 | + public static function for (array $field, $configuration) |
|
| 13 | 13 | { |
| 14 | 14 | return (new self($field, $configuration))->multiple(); |
| 15 | 15 | } |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | |
| 23 | 23 | $previousFiles = $entry->getOriginal($this->getName()) ?? []; |
| 24 | 24 | |
| 25 | - if (! is_array($previousFiles) && is_string($previousFiles)) { |
|
| 25 | + if (!is_array($previousFiles) && is_string($previousFiles)) { |
|
| 26 | 26 | $previousFiles = json_decode($previousFiles, true); |
| 27 | 27 | } |
| 28 | 28 | |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | if (in_array($previousFile, $filesToDelete)) { |
| 32 | 32 | Storage::disk($this->getDisk())->delete($previousFile); |
| 33 | 33 | |
| 34 | - $previousFiles = Arr::where($previousFiles, function ($value, $key) use ($previousFile) { |
|
| 34 | + $previousFiles = Arr::where($previousFiles, function($value, $key) use ($previousFile) { |
|
| 35 | 35 | return $value != $previousFile; |
| 36 | 36 | }); |
| 37 | 37 | } |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | foreach ($previousFiles as $row => $file) { |
| 29 | - if ($file && ! isset($orderedFiles[$row])) { |
|
| 29 | + if ($file && !isset($orderedFiles[$row])) { |
|
| 30 | 30 | $orderedFiles[$row] = null; |
| 31 | 31 | Storage::disk($this->getDisk())->delete($file); |
| 32 | 32 | } |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | return $this->getPath().$fileName; |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - if (! $value && CrudPanelFacade::getRequest()->has($this->getName()) && $previousFile) { |
|
| 55 | + if (!$value && CrudPanelFacade::getRequest()->has($this->getName()) && $previousFile) { |
|
| 56 | 56 | Storage::disk($this->getDisk())->delete($previousFile); |
| 57 | 57 | |
| 58 | 58 | return null; |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | */ |
| 40 | 40 | public function markAsHandled(string $objectName) |
| 41 | 41 | { |
| 42 | - if (! in_array($objectName, $this->handledUploaders)) { |
|
| 42 | + if (!in_array($objectName, $this->handledUploaders)) { |
|
| 43 | 43 | $this->handledUploaders[] = $objectName; |
| 44 | 44 | } |
| 45 | 45 | } |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | */ |
| 112 | 112 | public function registerUploader(string $uploadName, UploaderInterface $uploader) |
| 113 | 113 | { |
| 114 | - if (! array_key_exists($uploadName, $this->registeredUploaders) || ! in_array($uploader, $this->registeredUploaders[$uploadName])) { |
|
| 114 | + if (!array_key_exists($uploadName, $this->registeredUploaders) || !in_array($uploader, $this->registeredUploaders[$uploadName])) { |
|
| 115 | 115 | $this->registeredUploaders[$uploadName][] = $uploader; |
| 116 | 116 | } |
| 117 | 117 | } |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | */ |
| 159 | 159 | public function getRegisteredUploadNames(string $uploadName) |
| 160 | 160 | { |
| 161 | - return array_map(function ($uploader) { |
|
| 161 | + return array_map(function($uploader) { |
|
| 162 | 162 | return $uploader->getName(); |
| 163 | 163 | }, $this->getRegisteredUploadersFor($uploadName)); |
| 164 | 164 | } |