File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -332,6 +332,7 @@ automatically upload the file when persisting the entity::
332332 class BrochureUploadListener
333333 {
334334 private $uploader;
335+ private $fileName;
335336
336337 public function __construct(FileUploader $uploader)
337338 {
@@ -362,11 +363,10 @@ automatically upload the file when persisting the entity::
362363 $file = $entity->getBrochure();
363364
364365 // only upload new files
365- if (! $file instanceof UploadedFile) {
366- return ;
366+ if ($file instanceof UploadedFile) {
367+ $fileName = $this->uploader->upload($file) ;
367368 }
368369
369- $fileName = $this->uploader->upload($file);
370370 $entity->setBrochure($fileName);
371371 }
372372 }
@@ -449,8 +449,9 @@ controller.
449449 return;
450450 }
451451
452- if ($fileName = $entity->getBrochure()) {
453- $entity->setBrochure(new File($this->uploader->getTargetDir().'/'.$fileName));
452+ $this->fileName = $entity->getBrochure()
453+ if ($this->fileName) {
454+ $entity->setBrochure(new File($this->uploader->getTargetDir().'/'.$this->fileName));
454455 }
455456 }
456457 }
You can’t perform that action at this time.
0 commit comments