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)); }