Guest User

Untitled

a guest
May 27th, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. <?php
  2.  
  3. class BlogController extends Zend_Controller_Action
  4. {
  5. protected $_em;
  6.  
  7. public function init()
  8. {
  9. $this->_em = $this->getInvokeArg('bootstrap')->getResource('doctrine');
  10. }
  11.  
  12. public function postDispatch()
  13. {
  14. $this->_em->flush();
  15. }
  16.  
  17. /**
  18. * Lists the blog entries.
  19. *
  20. * @return void
  21. * @author Bryan Zarzuela
  22. */
  23. public function indexAction()
  24. {
  25. $posts = $this->_em->createQuery("SELECT p FROM D2Test_Model_Post p")->getResult();
  26. $this->view->posts = $posts;
  27. }
  28.  
  29. /**
  30. * Creates a new blog entry
  31. *
  32. * @return void
  33. * @author Bryan Zarzuela
  34. */
  35. public function newAction()
  36. {
  37. /*
  38. TODO Use Zend_Form
  39. */
  40.  
  41. if ($this->_request->isPost()) {
  42. $post = new D2Test_Model_Post;
  43. $post->setTitle($this->_getParam('title'));
  44. $post->setBody($this->_getParam('body'));
  45.  
  46. $this->_em->persist($post);
  47.  
  48. // $this->_redirect('/blog');
  49. }
  50.  
  51. }
  52. }
Add Comment
Please, Sign In to add comment