diff --git a/app/models/Data/RequestMeta.php b/app/models/Data/RequestMeta.php index 808025d..df164fa 100644 --- a/app/models/Data/RequestMeta.php +++ b/app/models/Data/RequestMeta.php @@ -25,6 +25,13 @@ class RequestMeta extends Model */ protected $uri; + /** + * Cached query parameters from request uri. + * + * @var array|null + */ + protected $_uri_query = null; + /** * * @var string @@ -72,6 +79,19 @@ class RequestMeta extends Model 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 */ @@ -81,15 +101,28 @@ class RequestMeta extends Model } /** - * @param string $uri - * @return RequestMeta + * @return array */ - public function setUri($uri) + public function getUriQuery() { - $this->uri = (string) $uri; - return $this; + if ($this->_uri_query === null) { + + $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 *