@@ -163,7 +163,11 @@ public function afterDelete(EventInterface $event, EntityInterface $entity, Arra
163163 $ result = true ;
164164
165165 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+ ) {
167171 continue ;
168172 }
169173
@@ -206,7 +210,7 @@ public function getPathProcessor(
206210 EntityInterface $ entity ,
207211 string |UploadedFileInterface $ data ,
208212 string $ field ,
209- array $ settings
213+ array $ settings,
210214 ): ProcessorInterface {
211215 /** @var class-string<\Josegonzalez\Upload\File\Path\ProcessorInterface> $processorClass */
212216 $ processorClass = Hash::get ($ settings , 'pathProcessor ' , DefaultProcessor::class);
@@ -227,7 +231,7 @@ public function getWriter(
227231 EntityInterface $ entity ,
228232 ?UploadedFileInterface $ data ,
229233 string $ field ,
230- array $ settings
234+ array $ settings,
231235 ): WriterInterface {
232236 /** @var class-string<\Josegonzalez\Upload\File\Writer\WriterInterface> $writerClass */
233237 $ writerClass = Hash::get ($ settings , 'writer ' , DefaultWriter::class);
@@ -262,7 +266,7 @@ public function constructFiles(
262266 UploadedFileInterface $ data ,
263267 string $ field ,
264268 array $ settings ,
265- array $ pathinfo
269+ array $ pathinfo,
266270 ): array {
267271 $ basepath = $ pathinfo ['basepath ' ];
268272 $ filename = $ pathinfo ['filename ' ];
@@ -284,7 +288,7 @@ public function constructFiles(
284288 } else {
285289 throw new UnexpectedValueException (sprintf (
286290 "'transformer' not set to instance of TransformerInterface: %s " ,
287- $ transformerClass
291+ $ transformerClass,
288292 ));
289293 }
290294
0 commit comments