TestsAppsController.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * TestsAppsController file
  5. *
  6. * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
  7. * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
  8. *
  9. * Licensed under The MIT License
  10. * For full copyright and license information, please see the LICENSE.txt
  11. * Redistributions of files must retain the above copyright notice
  12. *
  13. * @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
  14. * @link https://cakephp.org CakePHP(tm) Project
  15. * @since 1.2.0
  16. * @license https://opensource.org/licenses/mit-license.php MIT License
  17. */
  18. /**
  19. * TestsAppsController
  20. */
  21. namespace TestApp\Controller;
  22. use RuntimeException;
  23. class TestsAppsController extends AppController
  24. {
  25. public function index()
  26. {
  27. $var = '';
  28. if ($this->request->getQuery('var')) {
  29. $var = $this->request->getQuery('var');
  30. }
  31. $this->set('var', $var);
  32. }
  33. /**
  34. * @return \Cake\Http\Response
  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. /**
  46. * @return \Cake\Http\Response
  47. */
  48. public function redirect_to()
  49. {
  50. return $this->redirect('http://cakephp.org');
  51. }
  52. /**
  53. * @return \Cake\Http\Response
  54. */
  55. public function redirect_to_permanent()
  56. {
  57. return $this->redirect('http://cakephp.org', 301);
  58. }
  59. /**
  60. * @return \Cake\Http\Response
  61. */
  62. public function set_type()
  63. {
  64. return $this->response->withType('json');
  65. }
  66. public function throw_exception(): never
  67. {
  68. throw new RuntimeException('Foo');
  69. }
  70. }