RequestHandlerTestController.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. /**
  3. * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
  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 3.0.0
  15. * @license https://opensource.org/licenses/mit-license.php MIT License
  16. */
  17. namespace TestApp\Controller;
  18. use Cake\Controller\Controller;
  19. /**
  20. * RequestHandlerTestController class
  21. */
  22. class RequestHandlerTestController extends Controller
  23. {
  24. /**
  25. * test method for ajax redirection
  26. *
  27. * @return void
  28. */
  29. public function destination()
  30. {
  31. $this->viewBuilder()->templatePath('Posts');
  32. $this->render('index');
  33. }
  34. /**
  35. * test method for ajax redirection + parameter parsing
  36. *
  37. * @param string|null $one
  38. * @param string|null $two
  39. * @return void
  40. */
  41. public function param_method($one = null, $two = null)
  42. {
  43. echo "one: $one two: $two";
  44. $this->autoRender = false;
  45. }
  46. /**
  47. * test method for testing layout rendering when isAjax()
  48. *
  49. * @return void
  50. */
  51. public function ajax2_layout()
  52. {
  53. $this->viewBuilder()->layout('ajax2');
  54. $this->destination();
  55. }
  56. /**
  57. * test method for testing that response type set in action doesn't get
  58. * overridden by RequestHandlerComponent::beforeRender()
  59. *
  60. * @return void
  61. */
  62. public function set_response_type()
  63. {
  64. $this->response = $this->response->withType('txt');
  65. }
  66. }