add view profile, and create edit profile route
This commit is contained in:
36
src/Controller/ProfileController.php
Normal file
36
src/Controller/ProfileController.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Form\RegistrationFormType;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
use App\Repository\ParticipantRepository;
|
||||
|
||||
class ProfileController extends AbstractController
|
||||
{
|
||||
#[Route('/profile/{uuid}', name: 'profile_view', methods: ['GET'])]
|
||||
public function viewProfile(string $uuid, ParticipantRepository $participantRepository): Response
|
||||
{
|
||||
$currentProfile = $participantRepository->findOneBy(['idParticipant' => $uuid]);
|
||||
return $this->render('profile/view.html.twig', [
|
||||
'profile' => $currentProfile,
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/profile/edit/{uuid}', name: 'profile_edit', methods: ['GET', 'POST'])]
|
||||
public function editProfile(string $uuid, ParticipantRepository $participantRepository, Request $request): Response
|
||||
{
|
||||
$currentProfile = $participantRepository->findOneBy(['idParticipant' => $uuid]);
|
||||
$form = $this->createForm(RegistrationFormType::class, $currentProfile);
|
||||
$form->handleRequest($request);
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
|
||||
}
|
||||
return $this->render('profile/view.html.twig', [
|
||||
'profile' => $currentProfile,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user