3 // Copyright (c) 2011 Blue Static
5 // This program is free software: you can redistribute it and/or modify it
6 // under the terms of the GNU General Public License as published by the Free
7 // Software Foundation, either version 3 of the License, or any later version.
9 // This program is distributed in the hope that it will be useful, but WITHOUT
10 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 // You should have received a copy of the GNU General Public License along with
15 // this program. If not, see <http://www.gnu.org/licenses/>.
17 namespace hoplite\http
;
19 require_once HOPLITE_ROOT
. '/base/strict_object.php';
22 A Request represents a HTTP request and holds the data and contexte associated
25 class Request
extends \hoplite
\base\StrictObject
27 /*! @var string The request method (upper case). */
28 public $http_method = NULL
;
30 /*! @var string The URL, relataive to the RootController. */
33 /*! @var array HTTP request data. */
34 public $data = array();
37 Constructor. Takes an optional URL.
39 public function __construct($url = '')
45 Wrapper around filter_input() that stores the result in the ::$data field.
47 public function Filter($type, $name, $filter=FILTER_SANITIZE_STRING
, $options=NULL
)
49 $rv = filter_input($type, $name, $filter, $options);
50 $this->data
[$name] = $rv;
55 Wrapper around filter_input() that merges the result in the ::$data field.
57 public function FilterArray($type, $definition, $add_empty=TRUE
)
59 $rv = filter_input_array($type, $definition, $add_empty);
60 $this->data
= array_merge($this->data
, $rv);