Ejemplo n.º 1
0
 /**
  * @Route("/newtodo",name="newtodo")
  */
 public function createAction(Request $request)
 {
     $todo = new Todo();
     $todo->setName("Cour C++");
     $pr = $this->getDoctrine()->getManager();
     $pr->persist($todo);
     $pr->flush();
     // replace this example code with whatever you need
     return new Response('Row Created By Success');
 }
Ejemplo n.º 2
0
 public function load(ObjectManager $manager)
 {
     $task1 = new Todo();
     $task1->setDescription('This is my first task');
     $task1->setIsComplete(false);
     $manager->persist($task1);
     $task2 = new Todo();
     $task2->setDescription('This is my second and coolest task');
     $task2->setIsComplete(true);
     $manager->persist($task2);
     $manager->flush();
 }
Ejemplo n.º 3
0
 /**
  * @Route("/api/todos", name="createTodo")
  * @Method({"POST"})
  */
 public function createTodoAction(Request $request)
 {
     $number = $this->getDoctrine()->getRepository('AppBundle:Todo')->getTodosNumber();
     if ($number >= 10) {
         $response = new JsonResponse('You are too busy bro... You can\'t have other tasks :) ');
         return $response;
     }
     $body = $request->getContent();
     $data = json_decode($body, true);
     $todo = new Todo();
     $todo->setDescription($data['description']);
     $em = $this->getDoctrine()->getManager();
     $em->persist($todo);
     $em->flush();
     $response = new JsonResponse('cewl');
     return $response;
 }
 /**
  * @Route("/notebook/todos/createTodo/", name="todosCreateTodo")
  * @Method("POST")
  */
 public function createTodoAction(Request $request)
 {
     $project = $request->request->get('project');
     $folder = $request->request->get('folder');
     $date = new \DateTime("now");
     $user = $this->get('security.token_storage')->getToken()->getUser();
     $userId = $user->getId();
     $todosResult = $this->getDoctrine()->getRepository('AppBundle:Todo')->findBy(array('userId' => $userId), array('userSpecificId' => 'DESC'));
     if ($todosResult) {
         $nextSpecificId = $todosResult[0]->getUserSpecificId() + 1;
     } else {
         $nextSpecificId = 1;
     }
     $todo = new Todo();
     $todo->setUserId($userId);
     $todo->setUserSpecificId($nextSpecificId);
     $todo->setDateCreated($date);
     $todo->setDateModified($date);
     $todo->setTodo("");
     $todo->setNotes("");
     $todo->setLabels("");
     $todo->setIsCompleted(false);
     $todo->setPriority(1);
     $todo->setProject($project);
     $todo->setFolder($folder);
     $em = $this->getDoctrine()->getManager();
     $em->persist($todo);
     $em->flush();
     $response = new JsonResponse(array('id' => $todo->getId(), 'itemId' => $todo->getUserSpecificId(), 'project' => $todo->getProject(), 'folder' => $todo->getFolder(), 'priority' => $todo->getPriority()));
     return $response;
 }
Ejemplo n.º 5
0
 private function setTodoUrl(Todo $todo)
 {
     $url = $this->generateUrl('api_get_todo', ['id' => $todo->getId()], UrlGeneratorInterface::ABSOLUTE_URL);
     $todo->url = $url;
     return $todo;
 }