app/models/Data/RequestMeta.php: adding getUriQuery()
This commit is contained in:
parent
51a2675366
commit
0aa1107797
1 changed files with 38 additions and 5 deletions
|
|
@ -25,6 +25,13 @@ class RequestMeta extends Model
|
||||||
*/
|
*/
|
||||||
protected $uri;
|
protected $uri;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cached query parameters from request uri.
|
||||||
|
*
|
||||||
|
* @var array|null
|
||||||
|
*/
|
||||||
|
protected $_uri_query = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
|
|
@ -72,6 +79,19 @@ class RequestMeta extends Model
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $uri
|
||||||
|
* @return RequestMeta
|
||||||
|
*/
|
||||||
|
public function setUri($uri)
|
||||||
|
{
|
||||||
|
$this->uri = (string) $uri;
|
||||||
|
|
||||||
|
// New uri string, invalidate query.
|
||||||
|
$this->_uri_query = null;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
|
@ -81,15 +101,28 @@ class RequestMeta extends Model
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $uri
|
* @return array
|
||||||
* @return RequestMeta
|
|
||||||
*/
|
*/
|
||||||
public function setUri($uri)
|
public function getUriQuery()
|
||||||
{
|
{
|
||||||
$this->uri = (string) $uri;
|
if ($this->_uri_query === null) {
|
||||||
return $this;
|
|
||||||
|
$query = (string) parse_url($this->getUri(), PHP_URL_QUERY);
|
||||||
|
|
||||||
|
$ret = array();
|
||||||
|
foreach(explode('&', $query) as $v) {
|
||||||
|
@list($k, $v) = explode('=', $v, 2);
|
||||||
|
if (strlen($k) > 0) {
|
||||||
|
$ret[$k] = $v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$this->_uri_query = $ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->_uri_query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method to set the value of field Timestamp
|
* Method to set the value of field Timestamp
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Reference in a new issue