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::
332
332
class BrochureUploadListener
333
333
{
334
334
private $uploader;
335
+ private $fileName;
335
336
336
337
public function __construct(FileUploader $uploader)
337
338
{
@@ -362,11 +363,10 @@ automatically upload the file when persisting the entity::
362
363
$file = $entity->getBrochure();
363
364
364
365
// only upload new files
365
- if (! $file instanceof UploadedFile) {
366
- return ;
366
+ if ($file instanceof UploadedFile) {
367
+ $fileName = $this->uploader->upload($file) ;
367
368
}
368
369
369
- $fileName = $this->uploader->upload($file);
370
370
$entity->setBrochure($fileName);
371
371
}
372
372
}
@@ -449,8 +449,9 @@ controller.
449
449
return;
450
450
}
451
451
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));
454
455
}
455
456
}
456
457
}
You can’t perform that action at this time.
0 commit comments