Пример #1
0
 public function createPost(Request $request, Response $response)
 {
     $title = $request->getParam('title');
     $content = $request->getParam('content');
     $slug = trim($title);
     $slug = str_replace(' ', '-', $slug);
     $post = new Post();
     $post->setTitle($title);
     $post->setContent($content);
     $post->setSlug($slug);
     $this->em->persist($post);
     $this->em->flush();
     echo "Da them bai viet moi thanh cong";
 }