File tree Expand file tree Collapse file tree 3 files changed +38
-12
lines changed
Expand file tree Collapse file tree 3 files changed +38
-12
lines changed Original file line number Diff line number Diff line change @@ -66,26 +66,43 @@ public static function checkIfParamIsset($param = null)
6666 *
6767 * @return mixed
6868 */
69- public static function setParams ($ request = 1 )
69+ public static function setAndGetParams ($ request = 1 )
7070 {
7171 // if the param is not set then we use request method to
7272 // determine data received data from forms
7373
7474 // get Data using POST method
7575 if ($ request === INPUT_POST ){
76- self ::$ validator ->param = $ _POST ;
76+ self ::$ validator ->param = $ _POST ?: [] ;
7777 } elseif ($ request === INPUT_GET ){
78- self ::$ validator ->param = $ _GET ;
78+ self ::$ validator ->param = $ _GET ?: [] ;
7979 } else {
80- self ::$ validator ->param = $ _REQUEST ;
80+ self ::$ validator ->param = self :: createFromGlobals () ;
8181 }
82-
82+
8383 // convert into a collection of data
8484 self ::$ validator ->param = new Collection (self ::$ validator ->param );
8585
8686 return self ::$ validator ;
8787 }
8888
89+ /**
90+ * Create Params From Globals
91+ *
92+ * @return array
93+ */
94+ public static function createFromGlobals ()
95+ {
96+ $ post = $ _POST ?: [];
97+ $ get = $ _GET ?: [];
98+ $ request = $ _REQUEST ?: [];
99+ $ cookie = $ _COOKIE ?: [];
100+
101+ return array_merge (
102+ $ post , $ get , $ request , $ cookie
103+ );
104+ }
105+
89106 /**
90107 * Check if Form has been submitted
91108 * @return bool
Original file line number Diff line number Diff line change @@ -191,13 +191,15 @@ public function token(?bool $type = false)
191191 */
192192 public function post ()
193193 {
194- $ this ->config ['request ' ] = INPUT_POST ;
194+ $ request = INPUT_POST ;
195+ $ this ->config ['request ' ] = $ request ;
195196
196197 // initialize methods
197198 ValidatorMethod::initialize ($ this );
198199
199200 // set params
200- ValidatorMethod::setParams ($ this ->config ['request ' ]);
201+ $ param = ValidatorMethod::setAndGetParams ($ request );
202+ $ this ->param = $ param ->param ;
201203
202204 return $ this ;
203205 }
@@ -209,13 +211,15 @@ public function post()
209211 */
210212 public function get ()
211213 {
212- $ this ->config ['request ' ] = INPUT_GET ;
214+ $ request = INPUT_GET ;
215+ $ this ->config ['request ' ] = $ request ;
213216
214217 // initialize methods
215218 ValidatorMethod::initialize ($ this );
216219
217220 // set params
218- ValidatorMethod::setParams ($ this ->config ['request ' ]);
221+ $ param = ValidatorMethod::setAndGetParams ($ request );
222+ $ this ->param = $ param ->param ;
219223
220224 return $ this ;
221225 }
@@ -227,13 +231,15 @@ public function get()
227231 */
228232 public function all ()
229233 {
230- $ this ->config ['request ' ] = 2 ;
234+ $ request = 6 ;
235+ $ this ->config ['request ' ] = $ request ;
231236
232237 // initialize methods
233238 ValidatorMethod::initialize ($ this );
234239
235240 // set params
236- ValidatorMethod::setParams ($ this ->config ['request ' ]);
241+ $ param = ValidatorMethod::setAndGetParams ($ request );
242+ $ this ->param = $ param ->param ;
237243
238244 return $ this ;
239245 }
Original file line number Diff line number Diff line change @@ -62,7 +62,10 @@ public function __construct($attribute = null)
6262 ValidatorMethod::initialize ($ this );
6363
6464 // set params
65- ValidatorMethod::setParams ($ this ->config ['request ' ]);
65+ $ self = ValidatorMethod::setAndGetParams ($ this ->config ['request ' ]);
66+
67+ // replace with parent params
68+ $ this ->param = $ self ->param ;
6669 }
6770
6871 /**
You can’t perform that action at this time.
0 commit comments