ResponseFactory.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <?php
  2. namespace Illuminate\Contracts\Routing;
  3. interface ResponseFactory
  4. {
  5. /**
  6. * Create a new response instance.
  7. *
  8. * @param array|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. * Create a new "no content" response.
  16. *
  17. * @param int $status
  18. * @param array $headers
  19. * @return \Illuminate\Http\Response
  20. */
  21. public function noContent($status = 204, array $headers = []);
  22. /**
  23. * Create a new response for a given view.
  24. *
  25. * @param string|array $view
  26. * @param array $data
  27. * @param int $status
  28. * @param array $headers
  29. * @return \Illuminate\Http\Response
  30. */
  31. public function view($view, $data = [], $status = 200, array $headers = []);
  32. /**
  33. * Create a new JSON response instance.
  34. *
  35. * @param mixed $data
  36. * @param int $status
  37. * @param array $headers
  38. * @param int $options
  39. * @return \Illuminate\Http\JsonResponse
  40. */
  41. public function json($data = [], $status = 200, array $headers = [], $options = 0);
  42. /**
  43. * Create a new JSONP response instance.
  44. *
  45. * @param string $callback
  46. * @param mixed $data
  47. * @param int $status
  48. * @param array $headers
  49. * @param int $options
  50. * @return \Illuminate\Http\JsonResponse
  51. */
  52. public function jsonp($callback, $data = [], $status = 200, array $headers = [], $options = 0);
  53. /**
  54. * Create a new streamed response instance.
  55. *
  56. * @param callable $callback
  57. * @param int $status
  58. * @param array $headers
  59. * @return \Symfony\Component\HttpFoundation\StreamedResponse
  60. */
  61. public function stream($callback, $status = 200, array $headers = []);
  62. /**
  63. * Create a new streamed JSON response instance.
  64. *
  65. * @param array $data
  66. * @param int $status
  67. * @param array $headers
  68. * @param int $encodingOptions
  69. * @return \Symfony\Component\HttpFoundation\StreamedJsonResponse
  70. */
  71. public function streamJson($data, $status = 200, $headers = [], $encodingOptions = 15);
  72. /**
  73. * Create a new streamed response instance as a file download.
  74. *
  75. * @param callable $callback
  76. * @param string|null $name
  77. * @param array $headers
  78. * @param string|null $disposition
  79. * @return \Symfony\Component\HttpFoundation\StreamedResponse
  80. */
  81. public function streamDownload($callback, $name = null, array $headers = [], $disposition = 'attachment');
  82. /**
  83. * Create a new file download response.
  84. *
  85. * @param \SplFileInfo|string $file
  86. * @param string|null $name
  87. * @param array $headers
  88. * @param string|null $disposition
  89. * @return \Symfony\Component\HttpFoundation\BinaryFileResponse
  90. */
  91. public function download($file, $name = null, array $headers = [], $disposition = 'attachment');
  92. /**
  93. * Return the raw contents of a binary file.
  94. *
  95. * @param \SplFileInfo|string $file
  96. * @param array $headers
  97. * @return \Symfony\Component\HttpFoundation\BinaryFileResponse
  98. */
  99. public function file($file, array $headers = []);
  100. /**
  101. * Create a new redirect response to the given path.
  102. *
  103. * @param string $path
  104. * @param int $status
  105. * @param array $headers
  106. * @param bool|null $secure
  107. * @return \Illuminate\Http\RedirectResponse
  108. */
  109. public function redirectTo($path, $status = 302, $headers = [], $secure = null);
  110. /**
  111. * Create a new redirect response to a named route.
  112. *
  113. * @param \BackedEnum|string $route
  114. * @param mixed $parameters
  115. * @param int $status
  116. * @param array $headers
  117. * @return \Illuminate\Http\RedirectResponse
  118. */
  119. public function redirectToRoute($route, $parameters = [], $status = 302, $headers = []);
  120. /**
  121. * Create a new redirect response to a controller action.
  122. *
  123. * @param array|string $action
  124. * @param mixed $parameters
  125. * @param int $status
  126. * @param array $headers
  127. * @return \Illuminate\Http\RedirectResponse
  128. */
  129. public function redirectToAction($action, $parameters = [], $status = 302, $headers = []);
  130. /**
  131. * Create a new redirect response, while putting the current URL in the session.
  132. *
  133. * @param string $path
  134. * @param int $status
  135. * @param array $headers
  136. * @param bool|null $secure
  137. * @return \Illuminate\Http\RedirectResponse
  138. */
  139. public function redirectGuest($path, $status = 302, $headers = [], $secure = null);
  140. /**
  141. * Create a new redirect response to the previously intended location.
  142. *
  143. * @param string $default
  144. * @param int $status
  145. * @param array $headers
  146. * @param bool|null $secure
  147. * @return \Illuminate\Http\RedirectResponse
  148. */
  149. public function redirectToIntended($default = '/', $status = 302, $headers = [], $secure = null);
  150. }