createCreateForm($scope); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $em = $this->managerRegistry->getManager(); $em->persist($scope); $em->flush(); return $this->redirectToRoute('admin_scope'); } return $this->render('@ChillMain/Scope/new.html.twig', [ 'entity' => $scope, 'form' => $form->createView(), ]); } /** * Displays a form to edit an existing Scope entity. */ #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/scope/{id}/edit', name: 'admin_scope_edit')] public function editAction(Scope $scope, Request $request): Response { $editForm = $this->createEditForm($scope); $editForm->handleRequest($request); if ($editForm->isSubmitted() && $editForm->isValid()) { $this->entityManager->flush(); return $this->redirectToRoute('admin_scope_edit', ['id' => $scope->getId()]); } return $this->render('@ChillMain/Scope/edit.html.twig', [ 'entity' => $scope, 'edit_form' => $editForm->createView(), ]); } /** * Lists all Scope entities. */ #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/scope/', name: 'admin_scope')] public function indexAction() { $em = $this->managerRegistry->getManager(); $entities = $em->getRepository(Scope::class)->findAll(); return $this->render('@ChillMain/Scope/index.html.twig', [ 'entities' => $entities, ]); } /** * Displays a form to create a new Scope entity. */ #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/scope/new', name: 'admin_scope_new')] public function newAction() { $scope = new Scope(); $form = $this->createCreateForm($scope); return $this->render('@ChillMain/Scope/new.html.twig', [ 'entity' => $scope, 'form' => $form->createView(), ]); } /** * Finds and displays a Scope entity. */ public function showAction(mixed $id) { $em = $this->managerRegistry->getManager(); $scope = $em->getRepository(Scope::class)->find($id); if (!$scope) { throw $this->createNotFoundException('Unable to find Scope entity.'); } return $this->render('@ChillMain/Scope/show.html.twig', [ 'entity' => $scope, ]); } /** * Creates a form to create a Scope entity. * * @param Scope $scope The entity */ private function createCreateForm(Scope $scope): FormInterface { $form = $this->createForm(ScopeType::class, $scope, [ 'action' => $this->generateUrl('admin_scope_create'), 'method' => 'POST', ]); $form->add('submit', SubmitType::class, ['label' => 'Create']); return $form; } /** * Creates a form to edit a Scope entity. * * @param Scope $scope The entity */ private function createEditForm(Scope $scope): FormInterface { $form = $this->createForm(ScopeType::class, $scope); $form->add('submit', SubmitType::class, ['label' => 'Update']); return $form; } }