|
|
@ -66,6 +66,12 @@ class ProfilController extends AbstractController
|
|
|
|
#[Route('/profil/{id}/unfollow', name: 'profil_unfollow', requirements: ['page' => '\d+'])]
|
|
|
|
#[Route('/profil/{id}/unfollow', name: 'profil_unfollow', requirements: ['page' => '\d+'])]
|
|
|
|
public function unfollowProfil(int $id): Response
|
|
|
|
public function unfollowProfil(int $id): Response
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
try{
|
|
|
|
|
|
|
|
$this->denyAccessUnlessGranted('IS_AUTHENTICATED');
|
|
|
|
|
|
|
|
}catch (\Exception $e){
|
|
|
|
|
|
|
|
return $this->redirectToRoute('app_login');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$profil = $this->mgr->find(Profil::class, $id);
|
|
|
|
$profil = $this->mgr->find(Profil::class, $id);
|
|
|
|
if ($profil instanceof Profil) {
|
|
|
|
if ($profil instanceof Profil) {
|
|
|
|
$profil->removeFollower($this->getUser());
|
|
|
|
$profil->removeFollower($this->getUser());
|
|
|
@ -101,14 +107,6 @@ class ProfilController extends AbstractController
|
|
|
|
]);
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// #[Route('/profil/new', name: 'profil_new')]
|
|
|
|
|
|
|
|
// public function new(): Response
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// $profil = new Profil();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// return $this->redirectToRoute('profil_show', ['id' => $profil->getId()]);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[Route('/profil/{id}/edit', name: 'profil_edit', requirements: ['page' => '\d'])]
|
|
|
|
#[Route('/profil/{id}/edit', name: 'profil_edit', requirements: ['page' => '\d'])]
|
|
|
|
public function editProfil(int $id, Request $request): Response
|
|
|
|
public function editProfil(int $id, Request $request): Response
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -134,12 +132,20 @@ class ProfilController extends AbstractController
|
|
|
|
#[Route('/profil/{id}/follow', name: 'profil_follow', requirements: ['page' => '\d+'])]
|
|
|
|
#[Route('/profil/{id}/follow', name: 'profil_follow', requirements: ['page' => '\d+'])]
|
|
|
|
public function followProfil(int $id): Response
|
|
|
|
public function followProfil(int $id): Response
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
try{
|
|
|
|
|
|
|
|
$this->denyAccessUnlessGranted('IS_AUTHENTICATED');
|
|
|
|
|
|
|
|
}catch (\Exception $e){
|
|
|
|
|
|
|
|
return $this->redirectToRoute('app_login');
|
|
|
|
|
|
|
|
}
|
|
|
|
$profil = $this->mgr->find(Profil::class, $id);
|
|
|
|
$profil = $this->mgr->find(Profil::class, $id);
|
|
|
|
|
|
|
|
|
|
|
|
if ($profil instanceof Profil) {
|
|
|
|
if ($profil instanceof Profil) {
|
|
|
|
$profil->addFollower($this->getUser());
|
|
|
|
if ($profil->getId() !== $this->getUser()->getId()) {
|
|
|
|
$this->mgr->persist($profil);
|
|
|
|
$profil->addFollower($this->getUser());
|
|
|
|
$this->mgr->flush();
|
|
|
|
$this->mgr->persist($profil);
|
|
|
|
$this->addFlash('success', '');
|
|
|
|
$this->mgr->flush();
|
|
|
|
|
|
|
|
$this->addFlash('success', '');
|
|
|
|
|
|
|
|
}
|
|
|
|
return $this->redirectToRoute('profil_show', ['id' => $id]);
|
|
|
|
return $this->redirectToRoute('profil_show', ['id' => $id]);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
$this->addFlash('error', '');
|
|
|
|
$this->addFlash('error', '');
|
|
|
|