Beispiel #1
0
 public static function prepare()
 {
     if (FajrConfig::get('URL.Path')) {
         $_get = array_merge(FajrRouter::pathToParams(FajrUtils::pathInfo()), $_GET);
     } else {
         $_get = $_GET;
     }
     $_post = $_POST;
     // podla pola definujeceho vstupne parametre overim ich platnost
     foreach (self::$allowedParamters as $input => $params) {
         foreach ($params as $name => $type) {
             if (isset(${$input}[$name])) {
                 $checker = self::$conditions[$type]['cond'];
                 if (!Validator::$checker(${$input}[$name], self::$conditions[$type]['options'])) {
                     throw new Exception(str_replace('%%NAME%%', $name, self::$conditions[$type]['message']));
                 }
                 self::$inputParameters[$name] = ${$input}[$name];
                 self::${$input}[$name] = ${$input}[$name];
             }
         }
     }
     // budeme pouzivat uz len Input
     unset($_GET);
     unset($_POST);
 }
Beispiel #2
0
 public function prepare()
 {
     if (self::$prepared) {
         throw new IllegalStateException("Input::prepare should be called only once per request.");
     }
     self::$prepared = true;
     if (FajrConfig::get('URL.Path')) {
         $_get = array_merge(FajrRouter::pathToParams(FajrUtils::pathInfo()), $_GET);
     } else {
         $_get = $_GET;
     }
     $_post = $_POST;
     // budeme pouzivat uz len Input
     unset($_GET);
     unset($_POST);
     $this->_get = $this->_prepare_array($_get, $this->allowed_get);
     $this->_post = $this->_prepare_array($_post, $this->allowed_post);
     $this->inputParameters = array_merge($this->_get, $this->_post);
 }