Skip to content

Commit d7b1661

Browse files
Allowing no file in the PathProcessor
1 parent c1de324 commit d7b1661

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/Model/Behavior/UploadBehavior.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,20 +197,24 @@ public function afterDelete(EventInterface $event, EntityInterface $entity, Arra
197197
* for a given file upload
198198
*
199199
* @param \Cake\Datasource\EntityInterface $entity an entity
200-
* @param \Psr\Http\Message\UploadedFileInterface|string $data the data being submitted for a save or the filename
200+
* @param \Psr\Http\Message\UploadedFileInterface|string|null $data the data being submitted for a save or the filename
201201
* @param string $field the field for which data will be saved
202202
* @param array $settings the settings for the current field
203203
* @return \Josegonzalez\Upload\File\Path\ProcessorInterface
204204
*/
205205
public function getPathProcessor(
206206
EntityInterface $entity,
207-
string|UploadedFileInterface $data,
207+
string|UploadedFileInterface|null $data,
208208
string $field,
209209
array $settings
210210
): ProcessorInterface {
211211
/** @var class-string<\Josegonzalez\Upload\File\Path\ProcessorInterface> $processorClass */
212212
$processorClass = Hash::get($settings, 'pathProcessor', DefaultProcessor::class);
213213

214+
if ($data === null) {
215+
$data = "";
216+
}
217+
214218
return new $processorClass($this->_table, $entity, $data, $field, $settings);
215219
}
216220

0 commit comments

Comments
 (0)