@@ -163,7 +163,11 @@ public function afterDelete(EventInterface $event, EntityInterface $entity, Arra
163
163
$ result = true ;
164
164
165
165
foreach ($ this ->getConfig (null , []) as $ field => $ settings ) {
166
- if (in_array ($ field , $ this ->protectedFieldNames ) || Hash::get ($ settings , 'keepFilesOnDelete ' , true )) {
166
+ if (
167
+ in_array ($ field , $ this ->protectedFieldNames )
168
+ || Hash::get ($ settings , 'keepFilesOnDelete ' , true )
169
+ || $ entity ->get ($ field ) === null
170
+ ) {
167
171
continue ;
168
172
}
169
173
@@ -206,7 +210,7 @@ public function getPathProcessor(
206
210
EntityInterface $ entity ,
207
211
string |UploadedFileInterface $ data ,
208
212
string $ field ,
209
- array $ settings
213
+ array $ settings,
210
214
): ProcessorInterface {
211
215
/** @var class-string<\Josegonzalez\Upload\File\Path\ProcessorInterface> $processorClass */
212
216
$ processorClass = Hash::get ($ settings , 'pathProcessor ' , DefaultProcessor::class);
@@ -227,7 +231,7 @@ public function getWriter(
227
231
EntityInterface $ entity ,
228
232
?UploadedFileInterface $ data ,
229
233
string $ field ,
230
- array $ settings
234
+ array $ settings,
231
235
): WriterInterface {
232
236
/** @var class-string<\Josegonzalez\Upload\File\Writer\WriterInterface> $writerClass */
233
237
$ writerClass = Hash::get ($ settings , 'writer ' , DefaultWriter::class);
@@ -262,7 +266,7 @@ public function constructFiles(
262
266
UploadedFileInterface $ data ,
263
267
string $ field ,
264
268
array $ settings ,
265
- array $ pathinfo
269
+ array $ pathinfo,
266
270
): array {
267
271
$ basepath = $ pathinfo ['basepath ' ];
268
272
$ filename = $ pathinfo ['filename ' ];
@@ -284,7 +288,7 @@ public function constructFiles(
284
288
} else {
285
289
throw new UnexpectedValueException (sprintf (
286
290
"'transformer' not set to instance of TransformerInterface: %s " ,
287
- $ transformerClass
291
+ $ transformerClass,
288
292
));
289
293
}
290
294
0 commit comments