MockPostsController.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. /**
  3. * Lithium: the most rad php framework
  4. *
  5. * @copyright Copyright 2013, Union of RAD (http://union-of-rad.org)
  6. * @license http://opensource.org/licenses/bsd-license.php The BSD License
  7. */
  8. namespace lithium\tests\mocks\action;
  9. class MockPostsController extends \lithium\action\Controller {
  10. public $stopped = false;
  11. public function index($test = false) {
  12. if ($test) {
  13. return array('foo' => 'bar');
  14. }
  15. return 'List of posts';
  16. }
  17. public function delete($id = null) {
  18. if (empty($id)) {
  19. return $this->redirect('/posts', array('exit' => false));
  20. }
  21. return "Deleted {$id}";
  22. }
  23. public function send() {
  24. $this->redirect('/posts', array('exit' => true));
  25. }
  26. public function type($raw = false) {
  27. return array('data' => 'test');
  28. }
  29. public function notFound($id = null) {
  30. $this->response->status(404);
  31. $this->render(array('json' => $this->response->status));
  32. }
  33. public function view($id = null) {
  34. $this->render(array('text', 'data' => 'This is a post'));
  35. }
  36. public function view2($id = null) {
  37. $this->render(array('template' => 'view'));
  38. }
  39. public function view3($id = null) {
  40. $this->render(array('layout' => false, 'template' => 'view'));
  41. }
  42. public function changeTemplate() {
  43. $this->_render['template'] = 'foo';
  44. }
  45. protected function _safe() {
  46. throw new Exception('Something wrong happened');
  47. }
  48. public function access($var) {
  49. return $this->{$var};
  50. }
  51. protected function _stop($status = 0 ) {
  52. $this->stopped = true;
  53. }
  54. }
  55. ?>