Esempio n. 1
0
 public function posterAction()
 {
     $form = new Application_Form_Tweet();
     if ($this->getRequest()->isPost()) {
         $data = $this->_request->getPost();
         if ($form->isValid($data)) {
             $tweet = new Application_Model_Tweet();
             $tweet->fromArray($data);
             $membre = Zend_Auth::getInstance()->getStorage()->read();
             // Récupération de l'id de la personne connectée
             $tweet->setMembre_id($membre->getId());
             $mapper = new Application_Model_Mapper_Tweet();
             $mapper->add($tweet);
             $session = new Zend_Session_Namespace('messages');
             $session->tweetSucces = "Votre tweet à bien été posté !";
             $this->_helper->getHelper('Redirector')->gotoSimple(array('action' => 'index', 'membre' => $membre->getLogin()));
         } else {
             $form->populate($data);
             $form->buildBootstrapErrorDecorators();
             $this->view->msgErreur = "Veuillez vérifier votre formulaire !";
         }
     }
     $this->view->form = $form;
 }
Esempio n. 2
0
 public function indexAction()
 {
     $mapper = new Application_Model_Mapper_Tweet();
     $tweets = $mapper->getAllWithMembre();
     $this->view->tweets = $tweets;
 }