createCreateForm($entity); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $em = $this->getDoctrine()->getManager(); $em->persist($entity); $em->flush(); return $this->redirectToRoute('chill_activity_activityreason', ['id' => $entity->getId()]); } return $this->render('@ChillActivity/ActivityReason/new.html.twig', [ 'entity' => $entity, 'form' => $form->createView(), ]); } /** * Displays a form to edit an existing ActivityReason entity. */ public function editAction(mixed $id) { $em = $this->getDoctrine()->getManager(); $entity = $em->getRepository(\Chill\ActivityBundle\Entity\ActivityReason::class)->find($id); if (null === $entity) { throw new NotFoundHttpException('Unable to find ActivityReason entity.'); } $editForm = $this->createEditForm($entity); return $this->render('@ChillActivity/ActivityReason/edit.html.twig', [ 'entity' => $entity, 'edit_form' => $editForm->createView(), ]); } /** * Lists all ActivityReason entities. */ public function indexAction() { $em = $this->getDoctrine()->getManager(); $entities = $this->activityReasonRepository->findAll(); return $this->render('@ChillActivity/ActivityReason/index.html.twig', [ 'entities' => $entities, ]); } /** * Displays a form to create a new ActivityReason entity. */ public function newAction() { $entity = new ActivityReason(); $form = $this->createCreateForm($entity); return $this->render('@ChillActivity/ActivityReason/new.html.twig', [ 'entity' => $entity, 'form' => $form->createView(), ]); } /** * Finds and displays a ActivityReason entity. */ public function showAction(mixed $id) { $em = $this->getDoctrine()->getManager(); $entity = $em->getRepository(\Chill\ActivityBundle\Entity\ActivityReason::class)->find($id); if (!$entity) { throw $this->createNotFoundException('Unable to find ActivityReason entity.'); } return $this->render('@ChillActivity/ActivityReason/show.html.twig', [ 'entity' => $entity, ]); } /** * Edits an existing ActivityReason entity. */ public function updateAction(Request $request, mixed $id) { $em = $this->getDoctrine()->getManager(); $entity = $em->getRepository(\Chill\ActivityBundle\Entity\ActivityReason::class)->find($id); if (!$entity) { throw $this->createNotFoundException('Unable to find ActivityReason entity.'); } $editForm = $this->createEditForm($entity); $editForm->handleRequest($request); if ($editForm->isSubmitted() && $editForm->isValid()) { $em->flush(); return $this->redirectToRoute('chill_activity_activityreason', ['id' => $id]); } return $this->render('@ChillActivity/ActivityReason/edit.html.twig', [ 'entity' => $entity, 'edit_form' => $editForm->createView(), ]); } /** * Creates a form to create a ActivityReason entity. * * @param ActivityReason $entity The entity * * @return \Symfony\Component\Form\Form The form */ private function createCreateForm(ActivityReason $entity) { $form = $this->createForm(ActivityReasonType::class, $entity, [ 'action' => $this->generateUrl('chill_activity_activityreason_create'), 'method' => 'POST', ]); $form->add('submit', SubmitType::class, ['label' => 'Create']); return $form; } /** * Creates a form to edit a ActivityReason entity. * * @param ActivityReason $entity The entity * * @return \Symfony\Component\Form\Form The form */ private function createEditForm(ActivityReason $entity) { $form = $this->createForm(ActivityReasonType::class, $entity, [ 'action' => $this->generateUrl('chill_activity_activityreason_update', ['id' => $entity->getId()]), 'method' => 'PUT', ]); $form->add('submit', SubmitType::class, ['label' => 'Update']); return $form; } }