/** * Get {@link FlightBooking} by the identifier 'id' found in the URL. * @return FlightBooking {@link FlightBooking} instance * @throws NotFoundException if the param or {@link FlightBooking} instance is not found */ public static function getBlogPostByGetId() { $id = null; try { $id = self::getUrlParam('id'); } catch (Exception $ex) { throw new NotFoundException('No BlogPost identifier provided.'); } if (!is_numeric($id)) { throw new NotFoundException('Invalid BlogPost identifier provided.'); } $blogPostDao = new BlogPostDao(); $blogPost = $blogPostDao->findById($id); if ($blogPost === null) { throw new NotFoundException('Unknown BlogPost identifier provided.'); } return $blogPost; }
// private $createdBy; // private $modifiedBy; // private $description; // private $nameOfRestaurant; // private $overallRating; // private $restaurant_id; // private $username; // private $status = self::PENDING; $blogPostData = array('content' => $_POST['content'], 'date' => $_POST['date'] . ' 00:00:00', 'created_by' => 'char', 'modified_by' => 'char', 'description' => $_POST['content'], 'restaurant_id' => '44', 'status' => 'pending', 'modified_date' => $_POST['date'] . ' 00:00:00'); $blogRestaurantData = array('name_of_restaurant' => $_POST['name_of_restaurant'], 'overall_rating' => $_POST['overall_rating']); $blogChipData = array('chip_colour' => $_POST['chip_colour'], 'chip_crunch' => $_POST['chip_crunch'], 'chip_condiments' => $_POST['chip_condiments'], 'chip_consistency' => $_POST['chip_consistency'], 'chip_cash' => $_POST['chip_cash'], 'chip_charisma' => $_POST['chip_charisma']); // map BlogPostMapper::simpleMap($blogPost, $blogPostData); BlogRestaurantMapper::map($blogRestaurant, $blogRestaurantData); BlogChipMapper::map($blogChip, $blogChipData); // validate $errors = BlogPostValidator::validate($blogPost); $errors = BlogRestaurantValidator::validate($blogRestaurant); if (empty($errors)) { // save $blogPostDao = new BlogPostDao(); $blogRestaurantDao = new BlogRestaurantDao(); $blogChipDao = new BlogChipDao(); $blogPost = $blogPostDao->save($blogPost); $blogRestaurant = $blogRestaurantDao->save($blogRestaurant); $blogChip = $blogChipDao->save($blogChip); Flash::addFlash('Thanks for the review Chipper!'); // redirect Utils::redirect('list', array('status' => 'pending')); } }
<?php $status = Utils::getUrlParam('status'); //TodoValidator::validateStatus($status); // $blogPostDao = new BlogPostDao(); $blogRestaurantDao = new BlogRestaurantDao(); //$blogChipDao = new BlogChipDao(); // data for template $title = ucfirst($status) . ' reviews'; $blogPosts = $blogPostDao->find($status); //$blogRestaurants = $blogRestaurantDao->find($status); //$blogChips = $blogChipDao->find($status);
<?php //status of list $status = Utils::getUrlParam('status'); //command $cmd = Utils::getUrlParam('cmd'); $blogPost = Utils::getBlogPostByGetId(); $blogPost->setStatus($cmd); //if (array_key_exists('comment', $_POST)) { // $todo->setComment($_POST['comment']); //} $dao = new BlogPostDao(); $dao->save($blogPost); $msg = ''; if ($cmd === SimpleBlogPost::VOIDED) { $msg = 'Review deleted successfully.'; } else { $msg = 'Review status changed successfully.'; } Flash::addFlash($msg); Utils::redirect('list', array('status' => $status));