Skip to content

Commit 402b96f

Browse files
committed
minor symfony#7358 [File Uploads] Check if the entity contains the files (Guikingone)
This PR was submitted for the master branch but it was merged into the 2.7 branch instead (closes symfony#7358). Discussion ---------- [File Uploads] Check if the entity contains the files After many tests, it seems that if the entity does not contains the files, the event throw a Exception, by checking the presence of files, the exception isn't thrown and the process can continue, this can be usefull if the entity isn't linked with file or if the file was stored into an array but not needed at this time. The return isn't needed after the if statement. Commits ------- cc0d418 [File Uploads] Check if the entity contains the files
2 parents ca786e9 + cc0d418 commit 402b96f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

controller/upload_file.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -456,9 +456,9 @@ controller.
456456
return;
457457
}
458458

459-
$fileName = $entity->getBrochure();
460-
461-
$entity->setBrochure(new File($this->uploader->getTargetDir().'/'.$fileName));
459+
if ($fileName = $entity->getBrochure()) {
460+
$entity->setBrochure(new File($this->uploader->getTargetDir().'/'.$fileName));
461+
}
462462
}
463463
}
464464

0 commit comments

Comments
 (0)