|
|
@@ -0,0 +1,31 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace App\Controller;
|
|
|
+
|
|
|
+use App\Entity\User;
|
|
|
+use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
|
+use Symfony\Component\HttpFoundation\Response;
|
|
|
+use Symfony\Component\Routing\Annotation\Route;
|
|
|
+
|
|
|
+class ProfileController extends AbstractController
|
|
|
+{
|
|
|
+ #[Route('/profile/{id}', name: 'profile')]
|
|
|
+ public function index($id): Response
|
|
|
+ {
|
|
|
+ $em = $this->getDoctrine()->getManager();
|
|
|
+ $repository_profile = $em->getRepository(User::class);
|
|
|
+ $profile = $repository_profile->find($id);
|
|
|
+ if ($profile === null) {
|
|
|
+ return new Response("Profil non existant");
|
|
|
+ }
|
|
|
+ $username = $profile->getUsername();
|
|
|
+ $isPrivate = $profile->getIsPrivate();
|
|
|
+ $description = $profile->getDescription();
|
|
|
+ return $this->render('profile/index.html.twig', [
|
|
|
+ 'controller_name' => 'ProfileController',
|
|
|
+ 'username' => $username,
|
|
|
+ 'isPrivate' => $isPrivate,
|
|
|
+ 'description' => $description,
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+}
|