public function postNewsAction() { $entityManager = $this->get('doctrine.orm.entity_manager'); $news = new News(); $news->setTitle('Test'); $news->setSlug('test'); $news->setMarkup('ot bedzie długi tekst o pisanie na komputerze...'); $news->setIdAuthor(140); $entityManager->persist($news); $entityManager->flush(); $view = $this->view($news, 201); return $this->handleView($view); }
/** * @Given there are news: */ public function thereAreNews(TableNode $table) { $em = $this->getContainer()->get('doctrine')->getManager(); $i = 1; foreach ($table->getHash() as $row) { $news = new News(); $news->setTitle($row['title']); // $article->setCategory($this->findArticleCategory(['name' => $row['category']])); $news->setIdAuthor(1); $news->setSlug($row['title']); $em->persist($news); $em->flush(); // var_dump($news->getModificationDate()); $this->getParameterBag()->set(sprintf('NEWS_%s_ID', $i), $news->getIdNews()); $this->getParameterBag()->set(sprintf('NEWS_AUTHOR_%s_ID', $i), $news->getIdAuthor()); // $this->getParameterBag()->set('NEWS_MODIFICATION_DATE', $news->getModificationDate()->format(DATE_ISO8601)); $i++; } }