public function testGetDataWithNull() { $pageClass = new PageEntity(); $pageClass->setUrl('url'); $pageArray = array('url' => 'url'); $this->assertEquals($pageArray, $this->em->getData($pageClass)); }
public function add() { if ($_SERVER['REQUEST_METHOD'] === 'POST') { $entity = new PageEntity(); $entity->setTitle($_POST['title'])->setContent($_POST['content'])->setDateAdded(date('Y-m-d H:i:s')); $pageCollection = new PageCollection(); $pageCollection->save($entity); header('Location: index.php?c=page'); exit; } $this->loadView('page/add'); }
public function edit() { $pages_collection = new PagesCollection(); if ($_SERVER['REQUEST_METHOD'] == 'POST') { $page = new PageEntity(); $page->setId($_GET['id']); $page->setTitle($_POST['title']); $page->setContent($_POST['content']); $pages_collection->save($page); header('Location: index.php?controller=pages'); } $data = $pages_collection->get($_GET['id']); $this->loadView('cms/pages_edit', array('data' => $data)); }
<?php require_once "./Model/entity/PageEntity.php"; $page = new PageEntity(); $page->setId(2); $page->setUrl('url'); echo $page->getId(); echo "<br />"; echo $page->getUrl();
<?php require_once "./entity/PageEntity.php"; $page = new PageEntity(array('id' => 1)); print_r($page->toArray());