예제 #1
0
파일: App.php 프로젝트: kasonyang/hiano
 /**
  * 
  * @param \Hiano\Controller\Controller $controller
  * @param string $action_name
  */
 private static function dispatchAction($controller, $action_name)
 {
     $phpcomment = new \PhpComment\Comment($controller);
     $action_method_name = Controller\Controller::getActionMethodName($action_name);
     $tag = $phpcomment->getMethodTags()[$action_method_name];
     /* @var $tag \PhpComment\Tags */
     $request = self::getRequest();
     if ($request->isPost()) {
         $validate_tags = $tag->get('hiano-validate');
         if ($validate_tags) {
             foreach ($validate_tags as $v) {
                 $validate_info = explode(' ', $v, 2);
                 $validate_value = self::getRequest()->getPost($validate_info[0]);
                 $validate_validator_names = explode(',', $validate_info[1]);
                 foreach ($validate_validator_names as $vvn) {
                     $validate_ret = \Hiano\Validator\Validator::validate($validate_value, $vvn);
                     $validate_ret or \Hiano\Exception::validateFailed($validate_info[0], $validate_value, $vvn);
                 }
             }
         }
     }
     return $action_ret = $controller->dispatch($action_name);
 }
예제 #2
0
 /**
  * 抛出错误,后面的代码不再执行
  * @param string $description 错误描述
  * @param int $code 错误代号
  * @throws spStopException
  */
 function error($description, $code = 0)
 {
     \Hiano\Exception::error($description, $code);
 }