Browse Source

Ajout page profil

Clément K 4 years ago
parent
commit
158c67e8d5
4 changed files with 45 additions and 2 deletions
  1. 1 1
      .idea/php.xml
  2. 1 1
      composer.json
  3. 31 0
      src/Controller/ProfileController.php
  4. 12 0
      templates/profile/index.html.twig

+ 1 - 1
.idea/php.xml

@@ -105,5 +105,5 @@
       <path value="$PROJECT_DIR$/vendor/twig/twig" />
     </include_path>
   </component>
-  <component name="PhpProjectSharedConfiguration" php_language_level="7.2" />
+  <component name="PhpProjectSharedConfiguration" php_language_level="8.0" />
 </project>

+ 1 - 1
composer.json

@@ -4,7 +4,7 @@
     "minimum-stability": "dev",
     "prefer-stable": true,
     "require": {
-        "php": ">=7.2.5",
+        "php": ">=8.0",
         "ext-ctype": "*",
         "ext-iconv": "*",
         "composer/package-versions-deprecated": "1.11.99.1",

+ 31 - 0
src/Controller/ProfileController.php

@@ -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,
+        ]);
+    }
+}

+ 12 - 0
templates/profile/index.html.twig

@@ -0,0 +1,12 @@
+{% extends 'base.html.twig' %}
+
+{% block title %}Hello ProfileController!{% endblock %}
+
+{% block body %}
+<style>
+    .example-wrapper { margin: 1em auto; max-width: 800px; width: 95%; font: 18px/1.5 sans-serif; }
+    .example-wrapper code { background: #F5F5F5; padding: 2px 6px; }
+</style>
+
+
+{% endblock %}