public function searchAction() { $form = $this->view->form; $form->isValid($this->_getAllParams()); $repositorySpam = new Repository\Spam; $repositoryTweet = new Repository\Tweet; $tweets = $repositoryTweet ->search($form->text->getValue()) ->filter(new TweetSpecification\NoAdv($repositorySpam->getItems())); $this->view->tweets = $tweets; $this->view->map = new Model\Map($tweets); }
public function save() { try { $tweet = Factory\Tweet::create(array('name' => $this->_getParam('name'), 'message' => $this->_getParam('message'), 'timestamp' => time())); $repository = new Repository\Tweet(); $parentTweet = $repository->find($this->_getParam('id')); if (!$parentTweet) { $repository->save($tweet); } else { $parentTweet->add($tweet); $repository->save($parentTweet); } $this->getView()->message = 'OK'; } catch (\InvalidArgumentException $exception) { $this->getView()->message = $exception->getMessage(); } }