Guest User

Untitled

a guest
May 23rd, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.55 KB | None | 0 0
  1. // Les routes
  2. // Avant
  3. cinema:
  4. url: /:sf_culture/cinema/:page
  5. param: { module: cinema, action: index }
  6.  
  7. cinema_show:
  8. class: sfDoctrineRoute
  9. url: /:sf_culture/cinema/:page/:slug.html
  10. param: { module: cinema, action: show }
  11. options:
  12. model: Cinema
  13. type: object
  14. method: getPublishedBySlug
  15.  
  16.  
  17. // Après
  18. cinema:
  19. class: sfDoctrineRoute
  20. url: /:sf_culture/cinema/:page
  21. param: { module: cinema, action: index }
  22. options:
  23. model: Cinema
  24. type: object
  25. method: getLastPublished
  26.  
  27. cinema_show:
  28. class: sfDoctrineRoute
  29. url: /:sf_culture/cinema/:page/:slug.html
  30. param: { module: cinema, action: show }
  31. options:
  32. model: Cinema
  33. type: object
  34. method: getPublishedBySlug
  35.  
  36.  
  37. // Les actions
  38. // Avant qui ne marchait pas
  39. class cinemaActions extends sfActions
  40. {
  41. protected function getPager($page)
  42. {
  43. $this->pager = new sfDoctrinePager('Cinema', sfConfig::get('app_news_page_count'));
  44. $this->pager->setQuery(Doctrine::getTable('Cinema')->getPublishedQuery($this->getUser()->getCulture()));
  45. $this->pager->setPage($page);
  46. $this->pager->init();
  47. }
  48.  
  49. public function executeIndex(sfWebRequest $request)
  50. {
  51. $this->cinema = Doctrine::getTable('cinema')->getLastPublished();
  52.  
  53. $this->getPager($request->getParameter('page', 1));
  54.  
  55. $this->setTemplate('show');
  56. }
  57.  
  58. public function executeShow(sfWebRequest $request)
  59. {
  60. $this->cinema = $this->getRoute()->getObject();
  61.  
  62. $this->getPager($request->getParameter('page', 1));
  63. }
  64. }
  65.  
  66. // Après qui marche
  67. class cinemaActions extends sfActions
  68. {
  69. protected function getPager($page)
  70. {
  71. $this->pager = new sfDoctrinePager('Cinema', sfConfig::get('app_news_page_count'));
  72. $this->pager->setQuery(Doctrine::getTable('Cinema')->getPublishedQuery($this->getUser()->getCulture()));
  73. $this->pager->setPage($page);
  74. $this->pager->init();
  75. }
  76.  
  77. public function executeIndex(sfWebRequest $request)
  78. {
  79. $this->cinema = $this->getRoute()->getObject();
  80.  
  81. $this->getPager($request->getParameter('page', 1));
  82.  
  83. $this->setTemplate('show');
  84. }
  85.  
  86. public function executeShow(sfWebRequest $request)
  87. {
  88. $this->cinema = $this->getRoute()->getObject();
  89.  
  90. $this->getPager($request->getParameter('page', 1));
  91. }
  92. }
Add Comment
Please, Sign In to add comment