Compare commits

..

3 Commits

Author SHA1 Message Date
9d4cb86d41
fix check in PersistentDataManager
All checks were successful
soko-web/pipeline/pr-master This commit looks good
2023-04-16 15:59:47 +02:00
bf4520a7dd
Merge pull request 'get and serve headers in Request' (#2) from feature/implement-header-parsing into master
All checks were successful
soko-web/pipeline/head This commit looks good
Reviewed-on: #2
2023-04-16 15:54:55 +02:00
fda796ab18
get and serve headers in Request
All checks were successful
soko-web/pipeline/pr-master This commit looks good
2023-04-16 15:52:50 +02:00
2 changed files with 21 additions and 1 deletions

View File

@ -12,6 +12,8 @@ interface IRequest
public function post(string $key);
public function header(string $key);
public function session(): ISession;
public function setUser(?IUser $user): void;

View File

@ -15,15 +15,24 @@ class Request implements IRequest
private array $post;
private array $headers;
private Session $session;
private ?IUser $user = null;
public function __construct(string $base, array &$get, array &$post, array &$session, IUserRepository $userRepository)
public function __construct(
string $base,
array &$get,
array &$post,
array $headers,
array &$session,
IUserRepository $userRepository)
{
$this->base = $base;
$this->get = &$get;
$this->post = &$post;
$this->headers = $headers;
$this->session = new Session($session);
$userId = $this->session->get('userId');
@ -64,6 +73,15 @@ class Request implements IRequest
return null;
}
public function header($key)
{
if (isset($this->headers[$key])) {
return $this->headers[$key];
}
return null;
}
public function session(): ISession
{
return $this->session;