コード例 #1
0
ファイル: Validation.php プロジェクト: moiseh/metapages
 public function checkErrors()
 {
     switch ($this->command) {
         case 'querySql':
             if (isset($this->paramValues[0])) {
                 $err = \Meta\Builder::sqlError($this->paramValues[0]);
                 if ($err) {
                     throw new \Exception(t('Error on SQL query validation: ' . $err));
                 }
             }
             break;
     }
 }
コード例 #2
0
ファイル: View.php プロジェクト: moiseh/metapages
 public function checkErrors()
 {
     // check template
     if ($this->templateFile) {
         $file = abspath('views/' . $this->templateFile);
         if (!file_exists($file)) {
             throw new \Exception(t("The template '{$this->templateFile}' not found."));
         }
     }
     // sql query errors
     if ($this->query) {
         $error = \Meta\Builder::sqlError($this->query);
         if ($error) {
             throw new \Exception($error);
         }
     }
     parent::checkErrors();
 }
コード例 #3
0
ファイル: Commands.php プロジェクト: moiseh/metapages
 public static function checkCmds($cmds = array())
 {
     $cmdInstance = new self();
     foreach ($cmds as $cmd) {
         $cmd instanceof \Meta\Builder\Command;
         if (!method_exists($cmdInstance, $cmd->command)) {
             throw new \Exception(t('The command defined "' . $cmd->command . '" not exists in class Command'));
         }
         switch ($cmd->command) {
             case 'executePhpFunction':
                 $callback = $cmd->getArgument(0);
                 if (!function_exists($callback)) {
                     throw new \Exception(t('The defined public function "' . $callback . '" not found in system'));
                 }
                 break;
             case 'fetchFromSql':
                 $sql = $cmd->getArgument(0);
                 $this->errors[] = \Meta\Builder::sqlError($sql);
                 break;
             case 'fetchFromTable':
             case 'saveRecordInTable':
             case 'deleteRowFromTable':
                 $table = $cmd->getArgument(0);
                 if (!Db::tableExists($table)) {
                     throw new \Exception(t("The table '{$table}' was not found on database"));
                 }
                 break;
         }
     }
 }
コード例 #4
0
ファイル: Field.php プロジェクト: moiseh/metapages
 public function checkErrors()
 {
     // check for type-specific errors
     switch ($this->type) {
         case 'select':
         case 'radio':
             if ($this->optionsSql) {
                 $err = \Meta\Builder::sqlError($this->optionsSql);
                 if ($err) {
                     throw new \Exception(t('Error on SQL of field ' . $this->name . ': ' . $err));
                 }
             } else {
                 if ($this->optionsFunction && !function_exists($this->optionsFunction)) {
                     throw new \Exception(t("The public function defined `{$this->optionsFunction}` not exists"));
                 }
             }
             break;
         case 'btn_validated':
         case 'btn_simple':
             if ($this->commands) {
                 \Meta\Builder\Commands::checkCmds($this->commands);
             }
             break;
     }
     // check for validations errors
     foreach ($this->validations as $valid) {
         $valid instanceof Validation;
         $valid->checkErrors();
     }
 }