MAPG-115 add new classes to store request data (get, post, session, etc.)
This commit is contained in:
1 parent
ecaf8ca9d4
commit
fe814908c7
5 files changed
+130
No files matched your search
@@ -0,0 +1,57 @@
|
||||
<?php namespace MapGuesser\Request;
|
||||
|
||||
use MapGuesser\Interfaces\Authentication\IUser;
|
||||
use MapGuesser\Interfaces\Request\IRequest;
|
||||
use MapGuesser\Interfaces\Request\ISession;
|
||||
use MapGuesser\Model\User;
|
||||
|
||||
class Request implements IRequest
|
||||
{
|
||||
private array $get;
|
||||
|
||||
private array $routeParams;
|
||||
|
||||
private array $post;
|
||||
|
||||
private Session $session;
|
||||
|
||||
public function __construct(array &$get, array &$routeParams, array &$post, array &$session)
|
||||
{
|
||||
$this->get = &$get;
|
||||
$this->routeParams = &$routeParams;
|
||||
$this->post = &$post;
|
||||
$this->session = new Session($session);
|
||||
}
|
||||
|
||||
public function query($key)
|
||||
{
|
||||
if (isset($this->get[$key])) {
|
||||
return $this->get[$key];
|
||||
}
|
||||
|
||||
if (isset($this->routeParams[$key])) {
|
||||
return $this->routeParams[$key];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function post($key)
|
||||
{
|
||||
if (isset($this->post[$key])) {
|
||||
return $this->post[$key];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function session(): ISession
|
||||
{
|
||||
return $this->session;
|
||||
}
|
||||
|
||||
public function user(): ?IUser
|
||||
{
|
||||
return $this->session->get('user');
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user