root/trunk/src/main/php/net/stubbles/ipo/request/stubRequest.php

Revision 1547, 6.7 kB (checked in by mikey, 1 month ago)

refactoring #139, part 6: moved net::stubbles::util::validators to net::stubbles::ipo::request::validators

Line 
1 <?php
2 /**
3  * Interface for handling request variables.
4  *
5  * @author      Frank Kleine <mikey@stubbles.net>
6  * @package     stubbles
7  * @subpackage  ipo_request
8  */
9 stubClassLoader::load('net::stubbles::ipo::request::stubRequestValueError',
10                       'net::stubbles::ipo::request::filter::stubFilter',
11                       'net::stubbles::ipo::request::validator::stubValidator'
12 );
13 /**
14  * Interface for handling request variables.
15  *
16  * The request contains all data send by the user-agent: parameters,
17  * headers and cookies. It allows to retrieve this values via validators
18  * and filters. Errors that occurred during filtering are collected as well.
19  *
20  * @package     stubbles
21  * @subpackage  ipo_request
22  * @see         http://stubbles.net/wiki/Docs/Validators
23  */
24 interface stubRequest extends stubObject
25 {
26     /**
27      * registry key for request class to be used
28      */
29     const CLASS_REGISTRY_KEY = 'net.stubbles.ipo.request.class';
30     /**
31      * request source: cookies
32      */
33     const SOURCE_COOKIE      = 1;
34     /**
35      * request source: header
36      */
37     const SOURCE_HEADER      = 2;
38     /**
39      * request source: parameters
40      */
41     const SOURCE_PARAM       = 4;
42
43     /**
44      * checks if requestor accepts cookies
45      *
46      * @return  bool
47      */
48     public function acceptsCookies();
49
50     /**
51      * checks whether a request value is set or not
52      *
53      * @param   string  $valueName  name of request value
54      * @param   int     $source     optional  source type: cookie, header, param
55      * @return  bool
56      */
57     public function hasValue($valueName, $source = self::SOURCE_PARAM);
58
59     /**
60      * add a value error for a request value
61      *
62      * @param  stubRequestValueError  $valueError
63      * @param  string                 $valueName
64      * @param  int                    $source
65      */
66     public function addValueError(stubRequestValueError $valueError, $valueName, $source = self::SOURCE_PARAM);
67
68     /**
69      * checks whether a request value has any error after a filter was applied
70      *
71      * @param   string  $valueName  name of request value
72      * @param   int     $source     optional  source type: cookie, header, param
73      * @return  bool
74      */
75     public function hasValueError($valueName, $source = self::SOURCE_PARAM);
76
77     /**
78      * checks whether a request value has a specific error after a filter was applied
79      *
80      * @param   string  $valueName  name of request value
81      * @param   string  $errorId    id of error to check for
82      * @param   int     $source     optional  source type: cookie, header, param
83      * @return  bool
84      */
85     public function hasValueErrorWithId($valueName, $errorId, $source = stubRequest::SOURCE_PARAM);
86
87     /**
88      * returns a request value error with a specific id
89      *
90      * @param   string  $valueName  name of request value
91      * @param   string  $errorId    id of error to check for
92      * @param   int     $source     optional  source type: cookie, header, param
93      * @return  stubRequestValueError|null
94      */
95     public function getValueErrorWithId($valueName, $errorId, $source = stubRequest::SOURCE_PARAM);
96     
97     /**
98      * returns a list of errors for given request value
99      *
100      * @param   string  $valueName  name of request value
101      * @param   int     $source     optional  source type: cookie, header, param
102      * @return  array<stubRequestValueError>
103      */
104     public function getValueError($valueName, $source = self::SOURCE_PARAM);
105
106     /**
107      * checks whether there are any value errors
108      *
109      * @param   int   $source  optional  source type: cookie, header, param
110      * @return  bool
111      */
112     public function hasValueErrors($source = self::SOURCE_PARAM);
113
114     /**
115      * returns a list of all request value names with their errors
116      *
117      * @param   int  $source  optional  source type: cookie, header, param
118      * @return  array<string,array<stubRequestValueError>>
119      */
120     public function getValueErrors($source = self::SOURCE_PARAM);
121
122     /**
123      * cancels the request, e.g. if it was detected that it is invalid
124      */
125     public function cancel();
126
127     /**
128      * checks whether the request has been cancelled or not
129      *
130      * @return  bool
131      */
132     public function isCancelled();
133
134     /**
135      * returns the request method
136      *
137      * @return  string
138      */
139     public function getMethod();
140
141     /**
142      * returns the uri of the request
143      *
144      * @return  string
145      */
146     public function getURI();
147
148     /**
149      * checks whether raw data is valid or not
150      *
151      * @param   stubValidator  $validator  validator to use
152      * @return  bool
153      */
154     public function validateRawData(stubValidator $validator);
155
156     /**
157      * returns the validated raw data
158      *
159      * If the validator says the raw data is not valid the return value is null.
160      *
161      * @param   stubValidator  $validator  validator to use
162      * @return  string
163      */
164     public function getValidatedRawData(stubValidator $validator);
165
166     /**
167      * returns the raw data filtered
168      *
169      * @param   stubFilter  $filter
170      * @return  mixed
171      * @throws  stubFilterException
172      */
173     public function getFilteredRawData(stubFilter $filter);
174
175     /**
176      * checks whether a request value is valid or nor
177      *
178      * @param   stubValidator  $validator  validator to use
179      * @param   string         $valueName  name of request value
180      * @param   int            $source     optional  source type: cookie, header, param
181      * @return  bool
182      */
183     public function validateValue(stubValidator $validator, $valueName, $source = self::SOURCE_PARAM);
184
185     /**
186      * returns the validated request value
187      *
188      * If the validator says the value is not valid the return value is null.
189      *
190      * @param   stubValidator  $validator  validator to use
191      * @param   string         $valueName  name of request value
192      * @param   int            $source     optional  source type: cookie, header, param
193      * @return  string
194      */
195     public function getValidatedValue(stubValidator $validator, $valueName, $source = self::SOURCE_PARAM);
196
197     /**
198      * returns a filtered request value
199      *
200      * @param   stubFilter  $filter     filter to use
201      * @param   string      $valueName  name of request value
202      * @param   int         $source     optional  source type: cookie, header, param
203      * @return  mixed
204      */
205     public function getFilteredValue(stubFilter $filter, $valueName, $source = self::SOURCE_PARAM);
206
207     /**
208      * return an array of all keys registered in this request
209      *
210      * @param   int            $source     optional  source type: cookie, header, param
211      * @return  array<string>
212      */
213     public function getValueKeys($source = self::SOURCE_PARAM);
214 }
215 ?>
Note: See TracBrowser for help on using the browser.