public function delete() { $postId = $this->getPostId(); if (null !== $postId) { $post = new Model\Post(); $post->remove($postId); $this->console->write(); $this->console->write($this->console->colorize('Post Removed!', Console::BOLD_RED)); } }
public function post() { $view = new View($this->viewPath . '/post.phtml'); $view->title = 'Post Comment'; $view->form = new Form\Post(); if ($this->request->isPost()) { $view->form->addFilter('strip_tags')->addFilter('htmlentities', [ENT_QUOTES, 'UTF-8'])->setFieldValues($this->request->getPost()); if ($view->form->isValid()) { $view->form->clearFilters()->addFilter('html_entity_decode', [ENT_QUOTES, 'UTF-8']); $post = new Model\Post(); $post->save($view->form->getFields()); Response::redirect('/'); exit; } } $this->response->setBody($view->render()); $this->response->send(); }