ResponseFactory.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <?php
  2. namespace Illuminate\Contracts\Routing;
  3. interface ResponseFactory
  4. {
  5. /**
  6. * Create a new response instance.
  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. * 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 $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 string|array|object $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 string|array|object $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 \Closure $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 response instance as a file download.
  64. *
  65. * @param \Closure $callback
  66. * @param string|null $name
  67. * @param array $headers
  68. * @param string|null $disposition
  69. * @return \Symfony\Component\HttpFoundation\StreamedResponse
  70. */
  71. public function streamDownload($callback, $name = null, array $headers = [], $disposition = 'attachment');
  72. /**
  73. * Create a new file download response.
  74. *
  75. * @param \SplFileInfo|string $file
  76. * @param string|null $name
  77. * @param array $headers
  78. * @param string|null $disposition
  79. * @return \Symfony\Component\HttpFoundation\BinaryFileResponse
  80. */
  81. public function download($file, $name = null, array $headers = [], $disposition = 'attachment');
  82. /**
  83. * Return the raw contents of a binary file.
  84. *
  85. * @param \SplFileInfo|string $file
  86. * @param array $headers
  87. * @return \Symfony\Component\HttpFoundation\BinaryFileResponse
  88. */
  89. public function file($file, array $headers = []);
  90. /**
  91. * Create a new redirect response to the given path.
  92. *
  93. * @param string $path
  94. * @param int $status
  95. * @param array $headers
  96. * @param bool|null $secure
  97. * @return \Illuminate\Http\RedirectResponse
  98. */
  99. public function redirectTo($path, $status = 302, $headers = [], $secure = null);
  100. /**
  101. * Create a new redirect response to a named route.
  102. *
  103. * @param string $route
  104. * @param array $parameters
  105. * @param int $status
  106. * @param array $headers
  107. * @return \Illuminate\Http\RedirectResponse
  108. */
  109. public function redirectToRoute($route, $parameters = [], $status = 302, $headers = []);
  110. /**
  111. * Create a new redirect response to a controller action.
  112. *
  113. * @param string $action
  114. * @param array $parameters
  115. * @param int $status
  116. * @param array $headers
  117. * @return \Illuminate\Http\RedirectResponse
  118. */
  119. public function redirectToAction($action, $parameters = [], $status = 302, $headers = []);
  120. /**
  121. * Create a new redirect response, while putting the current URL in the session.
  122. *
  123. * @param string $path
  124. * @param int $status
  125. * @param array $headers
  126. * @param bool|null $secure
  127. * @return \Illuminate\Http\RedirectResponse
  128. */
  129. public function redirectGuest($path, $status = 302, $headers = [], $secure = null);
  130. /**
  131. * Create a new redirect response to the previously intended location.
  132. *
  133. * @param string $default
  134. * @param int $status
  135. * @param array $headers
  136. * @param bool|null $secure
  137. * @return \Illuminate\Http\RedirectResponse
  138. */
  139. public function redirectToIntended($default = '/', $status = 302, $headers = [], $secure = null);
  140. }