public function edit() { $news_collection = new NewsCollection(); if ($_SERVER['REQUEST_METHOD'] == 'POST') { $news = new NewsEntity(); $news->setId($_GET['id'])->setTitle($_POST['title'])->setContent($_POST['content'])->setAuthor($_POST['author'])->setDate($_POST['date_added']); if ($_FILES['image']['tmp_name'] != '') { $news->saveImage($_FILES['image']); } $news_collection->save($news); header('Location: index.php?controller=news'); } $data = $news_collection->get($_GET['id']); $this->loadView('cms/news_edit', array('data' => $data)); }
function bindNewsDto($newsDto) { if ($newsDto != null) { $newsEntity = new NewsEntity(); $newsEntity->setNewsId($newsDto->getNewsId()); $newsEntity->setNewsHeading($newsDto->getNewsHeading()); $newsEntity->setDataContent($newsDto->getDataContent()); $newsEntity->setNewsDate($newsDto->getNewsDate()); return $newsEntity; } else { return null; } }