示例#1
0
 public function createFromRequest($namespace, $user, Request $request)
 {
     if (!$request->request->has('topic')) {
         throw new NotFoundHttpException('Missing topic id');
     }
     $topic = $this->getEntityManager()->getRepository('AppBundle:Topic')->find($request->request->get('topic'));
     if (!$topic) {
         throw new NotFoundHttpException('Missing or invalid topic id');
     }
     $content = \AppBundle\StringCleaner::clean($request->request->get('content'));
     $post = $this->create($user, $topic, $content, $request->request->getBoolean('isSticky', false));
     return $post;
 }
示例#2
0
 public function createFromRequest($namespace, $user, Request $request)
 {
     if (!$request->request->has('post')) {
         throw new NotFoundHttpException('Missing post id');
     }
     $post = $this->getEntityManager()->getRepository('AppBundle:Post')->find($request->request->get('post'));
     if (!$post) {
         throw new NotFoundHttpException('Missing or invalid post id');
     }
     $content = \AppBundle\StringCleaner::clean($request->request->get('content'));
     $reply = $this->create($user, $post, $content);
     return $reply;
 }