/** * @Route("/notebook/editor/create/", name="editorCreate") * @Method("POST") */ public function createAction(Request $request) { $dateTimeFormat = $this->container->getParameter('AppBundle.dateTimeFormat'); $standardArea = $request->request->get('standardArea'); $folder = $request->request->get('folder'); $project = $request->request->get('project'); $syntax = $request->request->get('syntax'); $date = new \DateTime("now"); $user = $this->get('security.token_storage')->getToken()->getUser(); $userId = $user->getId(); $pages = new Pages(); $pages->setUserId($userId); $pages->setContent(""); $pages->setDateCreated($date); $pages->setDateModified($date); $pages->setFolder($folder); $pages->setProject($project); $pages->setSyntax($syntax); $pages->setArea($standardArea); $em = $this->getDoctrine()->getManager(); $em->persist($pages); $em->flush(); $response = new JsonResponse(array('id' => $pages->getId(), 'syntax' => $pages->getSyntax(), 'folder' => $pages->getFolder(), 'project' => $pages->getProject(), 'date' => $pages->getDateModified()->format($dateTimeFormat), 'year' => $pages->getDateCreated()->format('Y'))); return $response; }