|
|
@@ -19,6 +19,11 @@ class HashtagController extends AbstractController
|
|
|
#[Route('/hashtag/{name}', name: 'hashtag')]
|
|
|
public function index($name): Response
|
|
|
{
|
|
|
+ $session = $this->get('session');
|
|
|
+
|
|
|
+ if (null === $session->get('user')) {
|
|
|
+ return $this->redirectToRoute('login');
|
|
|
+ }
|
|
|
$em = $this->getDoctrine()->getManager();
|
|
|
$repository_hashtag = $em->getRepository(Hashtag::class);
|
|
|
$hashtag = $repository_hashtag->findOneBy(array("name" => $name));
|
|
|
@@ -26,7 +31,8 @@ class HashtagController extends AbstractController
|
|
|
$messages = $hashtag->getMessage()->getValues();
|
|
|
usort($messages, array($this, "cmp_array"));
|
|
|
return $this->render('hashtag/index.html.twig', [
|
|
|
- 'messages' => $messages
|
|
|
+ 'messages' => $messages,
|
|
|
+ 'username' => $session->get('user'),
|
|
|
]);
|
|
|
}
|
|
|
return new Response("Hashtag non existant");
|