|
@@ -16,17 +16,29 @@ class ProfileController extends AbstractController
|
|
|
$em = $this->getDoctrine()->getManager();
|
|
$em = $this->getDoctrine()->getManager();
|
|
|
$repository_profile = $em->getRepository(User::class);
|
|
$repository_profile = $em->getRepository(User::class);
|
|
|
$profile = $repository_profile->findOneBy(array('username' => $username));
|
|
$profile = $repository_profile->findOneBy(array('username' => $username));
|
|
|
|
|
+ $sessionUser = $this->get('session')->get('user');
|
|
|
|
|
+ $loginuserprofile = $repository_profile->findOneBy(array('username' => $sessionUser));
|
|
|
if ($profile === null) {
|
|
if ($profile === null) {
|
|
|
return new Response("Profil non existant");
|
|
return new Response("Profil non existant");
|
|
|
}
|
|
}
|
|
|
$username = $profile->getUsername();
|
|
$username = $profile->getUsername();
|
|
|
$isPrivate = $profile->getIsPrivate();
|
|
$isPrivate = $profile->getIsPrivate();
|
|
|
$description = $profile->getDescription();
|
|
$description = $profile->getDescription();
|
|
|
|
|
+ $privateNotAllowed = false;
|
|
|
|
|
+ $me = $sessionUser == $username ? true : false;
|
|
|
|
|
+ if (!$me and $isPrivate and !$profile->getSubscriptions()->contains($loginuserprofile)) {
|
|
|
|
|
+ $privateNotAllowed = true;
|
|
|
|
|
+ }
|
|
|
|
|
+ $follow = $loginuserprofile->getSubscriptions()->contains($profile) ? true : false;
|
|
|
return $this->render('profile/index.html.twig', [
|
|
return $this->render('profile/index.html.twig', [
|
|
|
'controller_name' => 'ProfileController',
|
|
'controller_name' => 'ProfileController',
|
|
|
|
|
+ 'privateNotAllowed' => $privateNotAllowed,
|
|
|
'username' => $username,
|
|
'username' => $username,
|
|
|
'isPrivate' => $isPrivate,
|
|
'isPrivate' => $isPrivate,
|
|
|
'description' => $description,
|
|
'description' => $description,
|
|
|
|
|
+ 'me' => $me,
|
|
|
|
|
+ 'sessionUser' => $sessionUser,
|
|
|
|
|
+ 'follow' => $follow,
|
|
|
]);
|
|
]);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|