TestsAppsController.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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 Cake\Http\Response;
  23. use RuntimeException;
  24. class TestsAppsController extends AppController
  25. {
  26. public function index()
  27. {
  28. $var = '';
  29. if ($this->request->getQuery('var')) {
  30. $var = $this->request->getQuery('var');
  31. }
  32. $this->set('var', $var);
  33. }
  34. /**
  35. * @return \Cake\Http\Response
  36. */
  37. public function some_method()
  38. {
  39. return $this->response->withStringBody('5');
  40. }
  41. public function set_action()
  42. {
  43. $this->set('var', 'string');
  44. $this->render('index');
  45. }
  46. /**
  47. * @return \Cake\Http\Response
  48. */
  49. public function redirect_to(): ?Response
  50. {
  51. return $this->redirect('http://cakephp.org');
  52. }
  53. /**
  54. * @return \Cake\Http\Response
  55. */
  56. public function redirect_to_permanent(): ?Response
  57. {
  58. return $this->redirect('http://cakephp.org', 301);
  59. }
  60. /**
  61. * @return \Cake\Http\Response
  62. */
  63. public function set_type()
  64. {
  65. return $this->response->withType('json');
  66. }
  67. public function throw_exception(): never
  68. {
  69. throw new RuntimeException('Foo');
  70. }
  71. }