Пример #1
0
 /**
  * @Route("json/admin/tasks/add", name="json_tasks_add")
  * @Method("POST")
  * @param Request $request
  * @return Response
  */
 public function jsonAddTaskAction(Request $request)
 {
     $task = new Task();
     $task->setTitle($request->request->get('title'));
     $task->setCreatedAt(new DateTime($request->request->get('dateFrom')));
     $task->setFinishDate(new DateTime($request->request->get('dateTo')));
     $task->setDescription($request->request->get('description'));
     $this->get('task_manager')->saveTask($task);
     foreach ($request->request->get('employees') as $employee) {
         $user = $this->get('user_repository')->findByPk($employee);
         $user->addTask($task);
     }
     $this->getDoctrine()->getManager()->flush();
     return new JsonResponse(array('Success'));
 }