/**
  * Méthode permettant d'enregistrer une adresse
  * @param $address L'adresse à enregistrer
  * @return void
  */
 public function save(WebsiteOpinion $websiteOpinion)
 {
     if ($websiteOpinion->isValid()) {
         $websiteOpinion->isNew() ? $this->add($websiteOpinion) : $this->modify($websiteOpinion);
     } else {
         throw new RuntimeException('L\'adresse doit être valide pour être enregistrée');
     }
 }
 protected function modify(WebsiteOpinion $websiteOpinion)
 {
     $q = $this->dao->prepare('UPDATE ' . $this->table() . ' SET USERNAME = :username, COMMENT = :comment, IS_PUBLISHED = :isPublished WHERE ID = :id');
     $q->bindValue(':username', $websiteOpinion->getUsername());
     $q->bindValue(':comment', $websiteOpinion->getComment());
     $q->bindValue(':isPublished', $websiteOpinion->getIsPublished());
     $q->bindValue(':id', $websiteOpinion->id());
     $q->execute();
 }
 public function executeOpinion(HTTPRequest $request)
 {
     if ($request->postExists('submit-form')) {
         $opinion = new WebsiteOpinion();
         $opinion->setUsername(htmlspecialchars($request->postData('username')));
         $opinion->setComment(htmlspecialchars($request->postData('comment')));
         $this->_opinionsManager->save($opinion);
         $this->page->smarty()->assign('isMessageSent', true);
     }
     $this->page->smarty()->assign('opinionsManager', $this->_opinionsManager);
 }