createCreateForm($scope); $form->handleRequest($request); if ($form->isValid()) { $em = $this->getDoctrine()->getManager(); $em->persist($scope); $em->flush(); return $this->redirect($this->generateUrl('admin_scope_show', ['id' => $scope->getId()])); } return $this->render('@ChillMain/Scope/new.html.twig', [ 'entity' => $scope, 'form' => $form->createView(), ]); } /** * Displays a form to edit an existing Scope entity. * * @param mixed $id */ public function editAction($id) { $em = $this->getDoctrine()->getManager(); $scope = $em->getRepository(\Chill\MainBundle\Entity\Scope::class)->find($id); if (!$scope) { throw $this->createNotFoundException('Unable to find Scope entity.'); } $editForm = $this->createEditForm($scope); return $this->render('@ChillMain/Scope/edit.html.twig', [ 'entity' => $scope, 'edit_form' => $editForm->createView(), ]); } /** * Lists all Scope entities. */ public function indexAction() { $em = $this->getDoctrine()->getManager(); $entities = $em->getRepository(\Chill\MainBundle\Entity\Scope::class)->findAll(); return $this->render('@ChillMain/Scope/index.html.twig', [ 'entities' => $entities, ]); } /** * Displays a form to create a new Scope entity. */ 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. * * @param mixed $id */ public function showAction($id) { $em = $this->getDoctrine()->getManager(); $scope = $em->getRepository(\Chill\MainBundle\Entity\Scope::class)->find($id); if (!$scope) { throw $this->createNotFoundException('Unable to find Scope entity.'); } return $this->render('@ChillMain/Scope/show.html.twig', [ 'entity' => $scope, ]); } /** * Edits an existing Scope entity. * * @param mixed $id */ public function updateAction(Request $request, $id) { $em = $this->getDoctrine()->getManager(); $scope = $em->getRepository(\Chill\MainBundle\Entity\Scope::class)->find($id); if (!$scope) { throw $this->createNotFoundException('Unable to find Scope entity.'); } $editForm = $this->createEditForm($scope); $editForm->handleRequest($request); if ($editForm->isValid()) { $em->flush(); return $this->redirect($this->generateUrl('admin_scope_edit', ['id' => $id])); } return $this->render('@ChillMain/Scope/edit.html.twig', [ 'entity' => $scope, 'edit_form' => $editForm->createView(), ]); } /** * Creates a form to create a Scope entity. * * @param Scope $scope The entity * * @return \Symfony\Component\Form\Form The form */ private function createCreateForm(Scope $scope) { $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 * * @return \Symfony\Component\Form\Form The form */ private function createEditForm(Scope $scope) { $form = $this->createForm(ScopeType::class, $scope, [ 'action' => $this->generateUrl('admin_scope_update', ['id' => $scope->getId()]), 'method' => 'PUT', ]); $form->add('submit', SubmitType::class, ['label' => 'Update']); return $form; } }