Exemplo n.º 1
0
 public function postCategoryArticlesAction(Request $request, $category)
 {
     $entityManager = $this->getDoctrine()->getEntityManager();
     $repository = $entityManager->getRepository('AppBundle:ArticleCategory');
     $categoryEntity = $repository->findOneBy(['slug' => $category]);
     //        $category = new ArticleCategory();
     //        print_r($category);
     $title = $request->request->get('title');
     $slug = $request->request->get('slug');
     $number = random_int(1, 100);
     $article = new Article();
     $article->setCategory($categoryEntity);
     //        $article->setIdArticleTemplate(null);
     $article->setIdAuthor(140);
     $article->setTitle($title . $number);
     $article->setSlug($slug . $number);
     $article->setMarkup('<p>To bedzie długi artykul...</p>');
     $article->setMarkup('To bedzie długi artykul...');
     $article->setCreationDate(new \DateTime());
     //        $article->setModificationDate();
     //        $article->setRated();
     //        $article->getSum();
     //        print_r($article);
     //        $article->setIdArticleCategory(86);
     //        $article->setIdArticleTemplate(1);
     $entityManager->persist($article);
     $entityManager->flush();
     $view = $this->view($article, 201);
     return $this->handleView($view);
 }