-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSystemEnvironment.php
137 lines (122 loc) · 2.6 KB
/
SystemEnvironment.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<?php
/**
* Definition of SystemEnvironment
*
* @copyright 2013-today Justso GmbH
* @author [email protected]
* @package justso
*/
namespace justso\justapi;
// @codeCoverageIgnoreStart
require_once(__DIR__ . "/AbstractSystemEnvironment.php");
//@codeCoverageIgnoreEnd
/**
* Handles the outer world interface to the browser
*
* @copyright 2013-today Justso GmbH
* @author [email protected]
* @package justso
* @codeCoverageIgnore
*/
class SystemEnvironment extends AbstractSystemEnvironment
{
/**
* @var RequestHelper
*/
private $request;
/**
* @var string[]
*/
private $header = array();
/**
* @var Session
*/
private $session;
/**
* Initializes the SystemEnvironment
*/
public function __construct()
{
parent::__construct();
$this->request = new RequestHelper();
if (function_exists('apache_request_headers')) {
$this->header = apache_request_headers();
}
$this->session = new Session();
}
/**
* @return RequestHelper
*/
public function getRequestHelper()
{
return $this->request;
}
/**
* @return string[]
*/
public function getHeader()
{
return $this->header;
}
/**
* @param string $header
*/
public function sendHeader($header)
{
header($header);
}
/**
* @param string $response
*/
public function sendResponse($response)
{
echo $response;
}
/**
* Changes the current user account. The permissions of this account are used for subsequent calls in this request.
*
* @param int $user key of user
*/
public function switchUser($user)
{
}
/**
* @return FileSystemInterface
*/
public function getFileSystem()
{
return new FileSystem();
}
/**
* @param string $name
* @param string $value
* @param int $expire
* @param string $path
* @param string $domain
* @param bool $secure
* @param bool $httpOnly
* @return bool
*/
public function sendCookie(
$name,
$value = null,
$expire = null,
$path = null,
$domain = null,
$secure = null,
$httpOnly = null
) {
return setcookie($name, $value, $expire, $path, $domain, $secure, $httpOnly);
}
/**
* @return Session
*/
public function getSession()
{
return $this->session;
}
public function getStdInput()
{
return file_get_contents("php://input");
}
}