TestsAppsController.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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 ($this->request->getQuery('var')) {
  32. $var = $this->request->getQuery('var');
  33. }
  34. $this->set('var', $var);
  35. }
  36. public function some_method()
  37. {
  38. return $this->response->withStringBody(5);
  39. }
  40. public function set_action()
  41. {
  42. $this->set('var', 'string');
  43. $this->render('index');
  44. }
  45. public function redirect_to()
  46. {
  47. return $this->redirect('http://cakephp.org');
  48. }
  49. public function redirect_to_permanent()
  50. {
  51. return $this->redirect('http://cakephp.org', 301);
  52. }
  53. public function set_type()
  54. {
  55. return $this->response->withType('json');
  56. }
  57. public function throw_exception()
  58. {
  59. throw new \RuntimeException('Foo');
  60. }
  61. }