1 | <?php |
||
14 | class UrlGenerator |
||
15 | { |
||
16 | |||
17 | /** |
||
18 | * The route collection. |
||
19 | * |
||
20 | * @var RouteCollection |
||
21 | */ |
||
22 | protected $routes; |
||
23 | |||
24 | /** |
||
25 | * The request instance. |
||
26 | * |
||
27 | * @var Request |
||
28 | */ |
||
29 | protected $request; |
||
30 | |||
31 | /** |
||
32 | * A cached copy of the URL root for the current request. |
||
33 | * |
||
34 | * @var string|null |
||
35 | */ |
||
36 | protected $cachedRoot; |
||
37 | |||
38 | /** |
||
39 | * A cached copy of the URL schema for the current request. |
||
40 | * |
||
41 | * @var string|null |
||
42 | */ |
||
43 | protected $cachedSchema; |
||
44 | |||
45 | /** |
||
46 | * The forced URL root. |
||
47 | * |
||
48 | * @var string |
||
49 | */ |
||
50 | protected $forcedRoot; |
||
51 | |||
52 | /** |
||
53 | * The forced schema for URLs. |
||
54 | * |
||
55 | * @var string |
||
56 | */ |
||
57 | protected $forceScheme; |
||
58 | |||
59 | /** |
||
60 | * The callback to use to format hosts. |
||
61 | * |
||
62 | * @var \Closure |
||
63 | */ |
||
64 | protected $formatHostUsing; |
||
65 | |||
66 | /** |
||
67 | * The callback to use to format paths. |
||
68 | * |
||
69 | * @var \Closure |
||
70 | */ |
||
71 | protected $formatPathUsing; |
||
72 | |||
73 | /** |
||
74 | * Create a new URL Generator instance. |
||
75 | * |
||
76 | * @param RouteCollection $routes |
||
77 | * @param Request $request |
||
78 | */ |
||
79 | public function __construct(RouteCollection $routes, Request $request) |
||
84 | |||
85 | /** |
||
86 | * Set the current request instance. |
||
87 | * |
||
88 | * @param Request $request |
||
89 | * @return void |
||
90 | */ |
||
91 | public function setRequest(Request $request) |
||
99 | |||
100 | /** |
||
101 | * Get the full URL for the current request. |
||
102 | * |
||
103 | * @return string |
||
104 | */ |
||
105 | public function full() |
||
109 | |||
110 | /** |
||
111 | * Get the current URL for the request. |
||
112 | * |
||
113 | * @return string |
||
114 | */ |
||
115 | public function current() |
||
119 | |||
120 | /** |
||
121 | * Generate an absolute URL to the given path. |
||
122 | * |
||
123 | * @param string $path |
||
124 | * @param mixed $extra |
||
125 | * @param bool|null $secure |
||
126 | * @return string |
||
127 | */ |
||
128 | public function to($path, $extra = [], $secure = null) |
||
148 | |||
149 | /** |
||
150 | * Determine if the given path is a valid URL. |
||
151 | * |
||
152 | * @param string $path |
||
153 | * @return bool |
||
154 | */ |
||
155 | public function isValidUrl($path) |
||
162 | |||
163 | /** |
||
164 | * Format the array of URL parameters. |
||
165 | * |
||
166 | * @param mixed|array $parameters |
||
167 | * @return array |
||
168 | */ |
||
169 | public function formatParameters($parameters) |
||
179 | |||
180 | /** |
||
181 | * Get the base URL for the request. |
||
182 | * |
||
183 | * @param string $scheme |
||
184 | * @param string $root |
||
185 | * @return string |
||
186 | */ |
||
187 | public function formatRoot($scheme, $root = null) |
||
198 | |||
199 | /** |
||
200 | * Get the default scheme for a raw URL. |
||
201 | * |
||
202 | * @param bool|null $secure |
||
203 | * @return string |
||
204 | */ |
||
205 | public function formatScheme($secure) |
||
215 | |||
216 | /** |
||
217 | * Extract the query string from the given path. |
||
218 | * |
||
219 | * @param string $path |
||
220 | * @return array |
||
221 | */ |
||
222 | protected function extractQueryString($path) |
||
232 | |||
233 | /** |
||
234 | * Format the given URL segments into a single URL. |
||
235 | * |
||
236 | * @param string $root |
||
237 | * @param string $path |
||
238 | * @return string |
||
239 | */ |
||
240 | public function format($root, $path) |
||
251 | |||
252 | /** |
||
253 | * Get the URL for the previous request. |
||
254 | * |
||
255 | * @param mixed $fallback |
||
256 | * @return string |
||
257 | */ |
||
258 | public function previous($fallback = false) |
||
270 | |||
271 | /** |
||
272 | * Get the previous URL from the session if possible. |
||
273 | * |
||
274 | * @return string|null |
||
275 | */ |
||
276 | protected function getPreviousUrlFromSession() |
||
282 | |||
283 | /** |
||
284 | * Generate the URL to an application asset. |
||
285 | * |
||
286 | * @param string $path |
||
287 | * @param bool|null $secure |
||
288 | * @return string |
||
289 | */ |
||
290 | public function asset($path, $secure = null) |
||
301 | |||
302 | /** |
||
303 | * Remove the index.php file from a path. |
||
304 | * |
||
305 | * @param string $root |
||
306 | * @return string |
||
307 | */ |
||
308 | protected function removeIndex($root) |
||
313 | } |
||
314 |