Ajout controleur Profil

pull/16/head
Corentin RICHARD 6 months ago
parent f0f720ae3e
commit 52b63aaec1

@ -23,10 +23,10 @@ APP_SECRET=5e7ed9de1fd633f917d0e87e2e05f923
# Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml
#
# DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db"
DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db"
# DATABASE_URL="mysql://app:!ChangeMe!@127.0.0.1:3306/app?serverVersion=8.0.32&charset=utf8mb4"
# DATABASE_URL="mysql://app:!ChangeMe!@127.0.0.1:3306/app?serverVersion=10.11.2-MariaDB&charset=utf8mb4"
DATABASE_URL="postgresql://app:!ChangeMe!@127.0.0.1:5432/app?serverVersion=16&charset=utf8"
# DATABASE_URL="postgresql://app:!ChangeMe!@127.0.0.1:5432/app?serverVersion=16&charset=utf8"
###< doctrine/doctrine-bundle ###
###> symfony/messenger ###

@ -0,0 +1,7 @@
INSERT INTO profil (id, name, description, password)
VALUES (
7,
'name:VARCHAR(255)',
'description:VARCHAR(255)',
'password:VARCHAR(255)'
);

@ -22,3 +22,7 @@ services:
# add more service definitions when explicit configuration is needed
# please note that last definitions always *replace* previous ones
App\Controller\ProfilController:
arguments:
$mgr: '@doctrine.orm.entity_manager'

@ -0,0 +1,36 @@
<?php
namespace App\Controller;
use App\Entity\Profil;
use Doctrine\ORM\EntityManager;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
class ProfilController extends AbstractController
{
public function __construct(private EntityManager $mgr) {}
#[Route('/profil/{id}',requirements: ['page' => '\d+'])]
public function profil(int $id): Response
{
$profil = $this->mgr->find(Profil::class,$id);
return $this->render('profil/index.html.twig', [
'profil' => $profil
]);
}
#[Route('/profil/{id}/follow',requirements: ['page' => '\d+'])]
public function followProfil(int $id): Response
{
// $profil = $this->mgr->find(Profil::class,$id);
return $this->render('profil/index.html.twig', [
// 'profil' => $profil
]);
}
}

@ -0,0 +1,11 @@
{# templates/profil/show.html.twig #}
{% extends 'base.html.twig' %}
{% block title %}Profil - {{ profil.name }}{% endblock %}
{% block body %}
<h1>Profil: {{ profil.name }}</h1>
<p>ID: {{ profil.id }}</p>
<p>Description: {{ profil.description }}</p>
{% endblock %}

Binary file not shown.
Loading…
Cancel
Save