8000 [File Uploads] Check if the entity contains the files by Guikingone · Pull Request #7358 · symfony/symfony-docs · GitHub
[go: up one dir, main page]

Skip to content

[File Uploads] Check if the entity contains the files #7358

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions controller/upload_file.rst
Original file line number Diff line number Diff line change
Expand Up @@ -442,10 +442,17 @@ controller.
public function postLoad(LifecycleEventArgs $args)
{
$entity = $args->getEntity();

$fileName = $entity->getBrochure();

$entity->setBrochure(new File($this->targetPath.'/'.$fileName));

// Only for tests purpose and proper object validation
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checking for the right object below indeed is needed. However, this comment looks confusing to me and I would just remove it.

if (!$entity instanceof ObjectWanted) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the class should be Product here

return;
}

if ($entity->getBrochure()) {
$fileName = $entity->getBrochure();

$entity->setBrochure(new File($this->targetPath.'/'.$fileName));
}
}
}

Expand Down
0