Example #1
0
 /**
  * Validate処理を実行
  *
  **/
 public function prefilter()
 {
     if ($this->isCompleteAction()) {
         $this->log->info("CompleteActionフラグが立っているため、Validatorは実行されませんでした。");
         return;
     }
     // 前のフィルターでエラーが発生してなくて、項目がある場合には実行
     $attributes = $this->getAttributes();
     if (!$this->request->isFilterError() && is_array($attributes) && count($attributes) > 0) {
         $this->validatorManager->execute($attributes);
     }
     return;
 }
Example #2
0
 /**
  * バリデーションを実行します。
  *
  * @param Teeple_ActionBase $action
  * @param string $methodName
  */
 private function doValidation($action, $methodName)
 {
     $className = get_class($action);
     if (!defined($className . "::VALIDATION_CONFIG")) {
         return;
     }
     if (defined($className . "::VALIDATION_TARGET")) {
         $targets = explode(',', constant($className . "::VALIDATION_TARGET"));
         array_walk($targets, 'trim');
         if (!in_array($methodName, $targets)) {
             $this->log->info("メソッド{$methodName}はValidation対象ではありません。");
             return;
         }
     }
     $validationConfig = $this->validatorManager->parseYAML(constant($className . "::VALIDATION_CONFIG"));
     if (!$this->validatorManager->execute($action, $validationConfig)) {
         $this->request->setFilterError('Validate');
     }
     return;
 }