예제 #1
0
 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;
         }
     }
 }