コード例 #1
0
 /**
  * @see sfValidatorBase
  */
 protected function doClean($values)
 {
     if (is_null($values)) {
         $values = array();
     }
     if (!is_array($values)) {
         throw new InvalidArgumentException('You must pass an array parameter to the clean() method');
     }
     $loginValue = isset($values[$this->getOption('login_field')]) ? $values[$this->getOption('login_field')] : null;
     $passwordValue = isset($values[$this->getOption('password_field')]) ? $values[$this->getOption('password_field')] : null;
     if (!$loginValue) {
         return false;
     }
     $valid = AuthorPeer::retrieveByEmailAndPassword($loginValue, sha1($passwordValue));
     if (!$valid) {
         $error = new sfValidatorError($this, 'invalid', array('login_field' => $loginValue, 'password_field' => $passwordValue));
         if ($this->getOption('throw_global_error')) {
             throw $error;
         }
         throw new sfValidatorErrorSchema($this, array($this->getOption('login_field') => $error));
     }
     return $values;
 }