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
<?php
namespace hji\membership\services;
class Request
{
protected $query;
protected $post;
protected $get;
function __construct()
{
add_filter('parse_request', array($this, 'setQuery'));
$this->post = $_POST;
$this->get = $_GET;
}
public function setQuery($query)
{
$this->query = $query;
}
function getQuery()
{
return $this->query;
}
function get($parameter)
{
if (is_object($this->query))
{
if (isset($this->query->$parameter))
{
return $this->query->$parameter;
}
else if (isset($this->query->query_vars[$parameter]))
{
return $this->query->query_vars[$parameter];
}
}
if (isset($this->post[$parameter]))
{
return $this->post[$parameter];
}
else if (isset($this->get[$parameter]))
{
return $this->get[$parameter];
}
}
}