1
|
|
|
<?php |
2
|
|
|
namespace JayaCode\Framework\Core\Http; |
3
|
|
|
|
4
|
|
|
use Symfony\Component\HttpFoundation\Request as BaseRequest; |
5
|
|
|
|
6
|
|
|
class Request extends BaseRequest |
7
|
|
|
{ |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Get the current path info for the request. |
11
|
|
|
* |
12
|
|
|
* @return string |
13
|
|
|
*/ |
14
|
|
|
public function path() |
15
|
|
|
{ |
16
|
|
|
$pattern = trim($this->getPathInfo(), '/'); |
17
|
|
|
return $pattern == '' ? '/' : $pattern; |
18
|
|
|
} |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Get the request method. |
22
|
|
|
* |
23
|
|
|
* @return string |
24
|
|
|
*/ |
25
|
|
|
public function method() |
26
|
|
|
{ |
27
|
|
|
return $this->getMethod(); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Get the root URL |
32
|
|
|
* |
33
|
|
|
* @return string |
34
|
|
|
*/ |
35
|
|
|
public function rootURL() |
36
|
|
|
{ |
37
|
|
|
return rtrim($this->getSchemeAndHttpHost().$this->getBaseUrl(), '/'); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Return true if server HTTP_REFERER isset |
42
|
|
|
* |
43
|
|
|
* @return bool |
44
|
|
|
*/ |
45
|
|
|
public function hasRefererURL() |
46
|
|
|
{ |
47
|
|
|
return $this->server->has("HTTP_REFERER"); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Return server HTTP_REFERER |
52
|
|
|
* |
53
|
|
|
* @return string |
54
|
|
|
*/ |
55
|
|
|
public function refererURL() |
56
|
|
|
{ |
57
|
|
|
return $this->server->get("HTTP_REFERER"); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* Creates a new request with values from PHP's super globals. |
62
|
|
|
* |
63
|
|
|
* @return Request A new request |
64
|
|
|
*/ |
65
|
|
|
public static function createFromSymfonyGlobal() |
66
|
|
|
{ |
67
|
|
|
$baseRequest = BaseRequest::createFromGlobals(); |
68
|
|
|
|
69
|
|
|
$query = $baseRequest->query->all(); |
70
|
|
|
$request = $baseRequest->request->all(); |
71
|
|
|
$attributes = array(); |
72
|
|
|
$cookies = $baseRequest->cookies->all(); |
73
|
|
|
$files = $baseRequest->files->all(); |
74
|
|
|
$server = $baseRequest->server->all(); |
75
|
|
|
$content = $baseRequest->getContent(); |
76
|
|
|
|
77
|
|
|
return new static($query, $request, $attributes, $cookies, $files, $server, $content); |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
|