Пример #1
0
 /**
  * @Route("/article/json/add", name="article-add-post")
  * @param Request $request
  * @return string|\Symfony\Component\HttpFoundation\Response
  * @Method("POST")
  */
 public function articleAddNewAction(Request $request)
 {
     //create new article
     $article = new Article();
     // get heading and content from $_POST
     $article->setHeading($request->request->get('heading'));
     $article->setContent($request->request->get('content'));
     $article->setTags($request->request->get('tags'));
     if ($request->request->get('privacy') == 'internal') {
         $article->setPrivate(true);
     } else {
         $article->setPrivate(false);
     }
     $article->setUserId($this->getUser());
     $categoryId = (int) $request->request->get('category');
     $this->get('article_manager')->save($article, $categoryId);
     return new Response('Created article ' . $article->getHeading());
 }