Buckets:
| namespace App\Controller; | |
| use App\Entity\User; | |
| use App\Form\UserForm; | |
| use App\Repository\UserRepository; | |
| use Doctrine\ORM\EntityManagerInterface; | |
| use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | |
| use Symfony\Component\HttpFoundation\Request; | |
| use Symfony\Component\HttpFoundation\Response; | |
| use Symfony\Component\Routing\Attribute\Route; | |
| ('/user') | |
| final class UserController extends AbstractController | |
| { | |
| (name: 'app_user_index', methods: ['GET']) | |
| public function index(UserRepository $userRepository): Response | |
| { | |
| return $this->render('user/index.html.twig', [ | |
| 'users' => $userRepository->findAll(), | |
| ]); | |
| } | |
| ('/new', name: 'app_user_new', methods: ['GET', 'POST']) | |
| public function new(Request $request, EntityManagerInterface $entityManager): Response | |
| { | |
| $user = new User(); | |
| $form = $this->createForm(UserForm::class, $user); | |
| $form->handleRequest($request); | |
| if ($form->isSubmitted() && $form->isValid()) { | |
| $entityManager->persist($user); | |
| $entityManager->flush(); | |
| return $this->redirectToRoute('app_user_index', [], Response::HTTP_SEE_OTHER); | |
| } | |
| return $this->render('user/new.html.twig', [ | |
| 'user' => $user, | |
| 'form' => $form, | |
| ]); | |
| } | |
| ('/{id}', name: 'app_user_show', methods: ['GET']) | |
| public function show(User $user): Response | |
| { | |
| return $this->render('user/show.html.twig', [ | |
| 'user' => $user, | |
| ]); | |
| } | |
| ('/{id}/edit', name: 'app_user_edit', methods: ['GET', 'POST']) | |
| public function edit(Request $request, User $user, EntityManagerInterface $entityManager): Response | |
| { | |
| $form = $this->createForm(UserForm::class, $user); | |
| $form->handleRequest($request); | |
| if ($form->isSubmitted() && $form->isValid()) { | |
| $entityManager->flush(); | |
| return $this->redirectToRoute('app_user_index', [], Response::HTTP_SEE_OTHER); | |
| } | |
| return $this->render('user/edit.html.twig', [ | |
| 'user' => $user, | |
| 'form' => $form, | |
| ]); | |
| } | |
| ('/{id}', name: 'app_user_delete', methods: ['POST']) | |
| public function delete(Request $request, User $user, EntityManagerInterface $entityManager): Response | |
| { | |
| if ($this->isCsrfTokenValid('delete'.$user->getId(), $request->getPayload()->getString('_token'))) { | |
| $entityManager->remove($user); | |
| $entityManager->flush(); | |
| } | |
| return $this->redirectToRoute('app_user_index', [], Response::HTTP_SEE_OTHER); | |
| } | |
| } | |
Xet Storage Details
- Size:
- 2.66 kB
- Xet hash:
- 21555c2fd4ce33d4360d2aefd13affb3d118ad689fe76832e98c997c7537c9b6
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.