examples/retwitter/application/controllers/PostController.php
public function newAction()
    {
        $currentUser = Zend_Auth::getInstance()->getStorage()->read();
        
        $form = new Form_Post;
        
        if ($this->getRequest()->isPost() && $form->isValid($this->getRequest()->getPost())) {
            
            $postData = $form->getValues();
            $postData['id'] = Post::fetchNextId();
            $postData['userId'] = $currentUser['id'];
            
            // save post
            $post = new Post($postData['id']);
            $post->setValue($postData);
            
            $userPosts = new UserPosts($currentUser['id']);
            $userPosts->add($postData['id']);
            
            // save post in the follower feeds
            $followers = new Followers($currentUser['id']);
            foreach ($followers as $followerId) {
                $feed = new Feed($followerId);
                $feed->prepend($postData['id']);
            }
            
            $this->_redirect('/post/my');
        }
        
        $this->view->form = $form;
    }
public function newAction()
    {
        $currentUser = Zend_Auth::getInstance()->getStorage()->read();
        
        $form = new Form_Post;
        
        if ($this->getRequest()->isPost() && $form->isValid($this->getRequest()->getPost())) {
            
            $postData = $form->getValues();
            $postData['id'] = Post::fetchNextId();
            $postData['userId'] = $currentUser['id'];
            
            // save post
            $post = new Post($postData['id']);
            $post->setValue($postData);
            
            $userPosts = new UserPosts($currentUser['id']);
            $userPosts->add($postData['id']);
            
            // save post in the follower feeds
            $followers = new Followers($currentUser['id']);
            foreach ($followers as $followerId) {
                $feed = new Feed($followerId);
                $feed->prepend($postData['id']);
            }
            
            $this->_redirect('/post/my');
        }
        
        $this->view->form = $form;
    }
Create new post