/** * Add tasks * * @param \AppBundle\Entity\Tasks $tasks * @return TaskLists */ public function addTask(\AppBundle\Entity\Tasks $tasks) { $tasks->setTaskList($this); $this->tasks[] = $tasks; return $this; }
/** * @Route("/project/saveIssue", name="_project_save_issue") */ public function saveIssueAction(Request $request) { $IssueTypeParams = $request->get("IssueType"); $histories = []; $attachments = []; $comments = []; $user = $this->get('security.token_storage')->getToken()->getUser(); if ($user == "anon.") { $user = null; } $return = ["success" => false, "error" => []]; if (empty($request->get("issueId"))) { $issue = new Tasks(); } else { $issue = $this->getDoctrine()->getRepository("AppBundle:Tasks")->find($request->get("issueId")); } if (empty($issue)) { $project = $this->getDoctrine()->getRepository("AppBundle:Projects")->find($IssueTypeParams["project"]); $issue = new Tasks(); $issues = $this->getDoctrine()->getRepository("AppBundle:Tasks")->findBy(["project" => $project]); $issue->setName($project->getName() . "-" . (count($issues) + 1)); $issue->setDateCreate(new \DateTime()); $issue->setUserCreate($user); } $issue->setDeleted(0); $issue->setStatus("NEW"); //$issue->setUserCreate($user); $form = $this->createForm("IssueType", $issue, array('csrf_protection' => false)); $form->handleRequest($request); if ($form->isValid()) { $em = $this->getDoctrine()->getManager(); try { $em->persist($issue); $em->flush(); $this->addFlash('success', 'Success! Issue saved.'); $return["success"] = true; $return["html"] = $this->get('twig')->render('AppBundle:Projects:_blocks/issue/editForm.html.twig', ["issue" => $issue, "histories" => $histories, "attachments" => $attachments, "comments" => $comments, "form" => $form->createView()]); } catch (Exception $e) { $return["error"][] = $e->getMessage(); } } else { $this->addFlash('error', 'Error! Invalid form data.'); foreach ($form->getErrors() as $error) { $return["error"][] = $error->getMessage(); } $return["html"] = $this->get('twig')->render('AppBundle:Projects:_blocks/issue/editForm.html.twig', ["issue" => $issue, "histories" => $histories, "attachments" => $attachments, "comments" => $comments, "form" => $form->createView()]); } return new JsonResponse($return); }
/** * Creates a form to delete a Tasks entity. * * @param Tasks $task The Tasks entity * * @return \Symfony\Component\Form\Form The form */ private function createDeleteForm(Tasks $task) { return $this->createFormBuilder()->setAction($this->generateUrl('tasks_delete', array('id' => $task->getId())))->setMethod('DELETE')->getForm(); }