callback_routes.php 1.7 KB

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