Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7fb0887

Browse files
committed
minor#7981 Update upload_file.rst (rumours86)
This PR was submitted for the 3.3 branch but it was merged into the 2.7 branch instead (closes#7981).Discussion----------Update upload_file.rstIf you edit an existing product with an attached file and do not fill in the fields for the file, after saving the field with the file is resetCommits-------d015048 Update upload_file.rst
2 parents581bebb +d015048 commit7fb0887

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

‎controller/upload_file.rst‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp