callback_routes.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <?php
  2. /**
  3. * A holding class for route callback tests
  4. *
  5. * @group kohana
  6. *
  7. * @package Unittest
  8. * @author Kohana Team
  9. * @copyright (c) Kohana Team
  10. * @license https://koseven.ga/LICENSE.md
  11. */
  12. class Route_Holder
  13. {
  14. /**
  15. * Just an empty callback that doesn't match anything
  16. */
  17. public static function default_callback($uri)
  18. {
  19. }
  20. /**
  21. * Just an empty callback that matches everything
  22. *
  23. * @return array
  24. */
  25. public static function default_return_callback($uri)
  26. {
  27. return [
  28. ];
  29. }
  30. /**
  31. * Route callback for test_matches_returns_array_of_parameters_on_successful_match
  32. *
  33. * @return array
  34. */
  35. public static function matches_returns_array_of_parameters_on_successful_match($uri)
  36. {
  37. return [
  38. 'controller' => 'welcome',
  39. 'action' => 'index',
  40. ];
  41. }
  42. /**
  43. * Route callback for test_required_parameters_are_needed
  44. *
  45. * @return array
  46. */
  47. public static function required_parameters_are_needed($uri)
  48. {
  49. if (substr($uri, 0, 5) == 'admin')
  50. {
  51. return [
  52. 'controller' => 'foo',
  53. 'action' => 'bar',
  54. ];
  55. }
  56. }
  57. /**
  58. * Route callback for test reverse_routing_returns_routes_uri_if_route_is_static
  59. *
  60. * @return array
  61. */
  62. public static function reverse_routing_returns_routes_uri_if_route_is_static($uri)
  63. {
  64. if ($uri == 'info/about_us')
  65. {
  66. return [
  67. ];
  68. }
  69. }
  70. /**
  71. * Route callback for test route_filter_modify_params
  72. *
  73. * @return array
  74. */
  75. public static function route_filter_modify_params_array(Route $route, $params)
  76. {
  77. $params['action'] = 'modified';
  78. return $params;
  79. }
  80. /**
  81. * Route callback for test route_filter_modify_params
  82. *
  83. * @return array
  84. */
  85. public static function route_filter_modify_params_false(Route $route, $params)
  86. {
  87. return FALSE;
  88. }
  89. }