ResponseFactory.php 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <?php
  2. namespace Illuminate\Contracts\Routing;
  3. interface ResponseFactory
  4. {
  5. /**
  6. * Return a new response from the application.
  7. *
  8. * @param string $content
  9. * @param int $status
  10. * @param array $headers
  11. * @return \Illuminate\Http\Response
  12. */
  13. public function make($content = '', $status = 200, array $headers = []);
  14. /**
  15. * Return a new view response from the application.
  16. *
  17. * @param string $view
  18. * @param array $data
  19. * @param int $status
  20. * @param array $headers
  21. * @return \Illuminate\Http\Response
  22. */
  23. public function view($view, $data = [], $status = 200, array $headers = []);
  24. /**
  25. * Return a new JSON response from the application.
  26. *
  27. * @param string|array $data
  28. * @param int $status
  29. * @param array $headers
  30. * @param int $options
  31. * @return \Illuminate\Http\JsonResponse
  32. */
  33. public function json($data = [], $status = 200, array $headers = [], $options = 0);
  34. /**
  35. * Return a new JSONP response from the application.
  36. *
  37. * @param string $callback
  38. * @param string|array $data
  39. * @param int $status
  40. * @param array $headers
  41. * @param int $options
  42. * @return \Illuminate\Http\JsonResponse
  43. */
  44. public function jsonp($callback, $data = [], $status = 200, array $headers = [], $options = 0);
  45. /**
  46. * Return a new streamed response from the application.
  47. *
  48. * @param \Closure $callback
  49. * @param int $status
  50. * @param array $headers
  51. * @return \Symfony\Component\HttpFoundation\StreamedResponse
  52. */
  53. public function stream($callback, $status = 200, array $headers = []);
  54. /**
  55. * Return a new streamed response as a file download from the application.
  56. *
  57. * @param \Closure $callback
  58. * @param string|null $name
  59. * @param array $headers
  60. * @param string|null $disposition
  61. * @return \Symfony\Component\HttpFoundation\StreamedResponse
  62. */
  63. public function streamDownload($callback, $name = null, array $headers = [], $disposition = 'attachment');
  64. /**
  65. * Create a new file download response.
  66. *
  67. * @param \SplFileInfo|string $file
  68. * @param string|null $name
  69. * @param array $headers
  70. * @param string|null $disposition
  71. * @return \Symfony\Component\HttpFoundation\BinaryFileResponse
  72. */
  73. public function download($file, $name = null, array $headers = [], $disposition = 'attachment');
  74. /**
  75. * Create a new redirect response to the given path.
  76. *
  77. * @param string $path
  78. * @param int $status
  79. * @param array $headers
  80. * @param bool|null $secure
  81. * @return \Illuminate\Http\RedirectResponse
  82. */
  83. public function redirectTo($path, $status = 302, $headers = [], $secure = null);
  84. /**
  85. * Create a new redirect response to a named route.
  86. *
  87. * @param string $route
  88. * @param array $parameters
  89. * @param int $status
  90. * @param array $headers
  91. * @return \Illuminate\Http\RedirectResponse
  92. */
  93. public function redirectToRoute($route, $parameters = [], $status = 302, $headers = []);
  94. /**
  95. * Create a new redirect response to a controller action.
  96. *
  97. * @param string $action
  98. * @param array $parameters
  99. * @param int $status
  100. * @param array $headers
  101. * @return \Illuminate\Http\RedirectResponse
  102. */
  103. public function redirectToAction($action, $parameters = [], $status = 302, $headers = []);
  104. /**
  105. * Create a new redirect response, while putting the current URL in the session.
  106. *
  107. * @param string $path
  108. * @param int $status
  109. * @param array $headers
  110. * @param bool|null $secure
  111. * @return \Illuminate\Http\RedirectResponse
  112. */
  113. public function redirectGuest($path, $status = 302, $headers = [], $secure = null);
  114. /**
  115. * Create a new redirect response to the previously intended location.
  116. *
  117. * @param string $default
  118. * @param int $status
  119. * @param array $headers
  120. * @param bool|null $secure
  121. * @return \Illuminate\Http\RedirectResponse
  122. */
  123. public function redirectToIntended($default = '/', $status = 302, $headers = [], $secure = null);
  124. }