TestsAppsController.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. /**
  3. * TestsAppsController file
  4. *
  5. * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
  6. * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
  7. *
  8. * Licensed under The MIT License
  9. * For full copyright and license information, please see the LICENSE.txt
  10. * Redistributions of files must retain the above copyright notice
  11. *
  12. * @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
  13. * @link https://cakephp.org CakePHP(tm) Project
  14. * @since 1.2.0
  15. * @license https://opensource.org/licenses/mit-license.php MIT License
  16. */
  17. /**
  18. * TestsAppsController
  19. */
  20. namespace TestApp\Controller;
  21. class TestsAppsController extends AppController
  22. {
  23. public $components = [
  24. 'RequestHandler' => [
  25. 'enableBeforeRedirect' => false
  26. ]
  27. ];
  28. public function index()
  29. {
  30. $var = '';
  31. if (isset($this->request->query['var'])) {
  32. $var = $this->request->query['var'];
  33. }
  34. $this->set('var', $var);
  35. }
  36. public function some_method()
  37. {
  38. $this->response->body(5);
  39. return $this->response;
  40. }
  41. public function set_action()
  42. {
  43. $this->set('var', 'string');
  44. $this->render('index');
  45. }
  46. public function redirect_to()
  47. {
  48. return $this->redirect('http://cakephp.org');
  49. }
  50. public function redirect_to_permanent()
  51. {
  52. return $this->redirect('http://cakephp.org', 301);
  53. }
  54. public function set_type()
  55. {
  56. $this->response->type('json');
  57. return $this->response;
  58. }
  59. public function throw_exception()
  60. {
  61. throw new \RuntimeException('Foo');
  62. }
  63. }