Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Update CoverPhoto
<?php
/**
* @ORM\OneToOne(targetEntity="App\Entity\User", inversedBy="companyCoverPhoto", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\JoinColumn(nullable=false)
*/
private $company;
<?php
/**
* @ORM\OneToOne(targetEntity="App\Entity\CompanyCoverPhoto", mappedBy="company", cascade={"persist", "remove"}, orphanRemoval=true)
*/
private $companyCoverPhoto;
<?php
public function showUserCoverPhoto(Request $request, EntityManagerInterface $m, Uploader $up)
{
/** @var User $usr */
$usr = $this->getUser();
$form = $this->createForm(CoverPhotoForm::class, $usr);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
// holds the submitted values iN MeM
$c = $form->getData();
/** @var UploadedFile $uploadedFile */
$uploadedFile = $form['imageFile']->getData();
if ($uploadedFile) {
$newFilename = $up->uploadCoverImage($uploadedFile, $c->getFilename());
$c->setFilename($newFilename);
}
$m->persist($c);
$m->flush();
return $this->redirectToRoute('show_blog');
}
return $this->render('user/cover_image.html.twig', [
'CoverForm' => $form->createView(),
'u' => $usr,
]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.