public function save(PageEntity $page) { $now = new \DateTime('now'); // Created if (!$page->getCreated()) { $page->setCreated($now); } // The updated datetime $page->setUpdated($now); $this->getEntityManager()->persist($page); $this->getEntityManager()->flush(); }
public function testSetters() { $page = new Page(); $page->setTitle('Imprint'); $this->assertEquals('Imprint', $page->getTitle()); $page->setRoute('imprint'); $this->assertEquals('imprint', $page->getRoute()); $page->setContent('lorem ipsum'); $this->assertEquals('lorem ipsum', $page->getContent()); $page->setStatus('published'); $this->assertEquals('published', $page->getStatus()); $now = new \DateTime('now'); $page->setCreated($now); $this->assertEquals($now, $page->getCreated()); $page->setUpdated($now); $this->assertEquals($now, $page->getUpdated()); }