Development

Changeset 8755

You must first sign up to be able to contribute.

Changeset 8755

Show
Ignore:
Timestamp:
05/03/08 20:34:29 (5 months ago)
Author:
FabianLange
Message:

validation yml with fillin is used even without other validators defined in the file. fixed #3232

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.1/lib/plugins/sfCompat10Plugin/lib/config/sfValidatorConfigHandler.class.php

    r7792 r8755  
    4646      if (!isset($config[$category])) 
    4747      { 
    48         throw new sfParseException(sprintf('Configuration file "%s" is missing "%s" category.', $configFiles[0], $category)); 
     48        if (!isset($config['fillin'])) 
     49        { 
     50          throw new sfParseException(sprintf('Configuration file "%s" is missing "%s" category.', $configFiles[0], $category)); 
     51        } 
     52        $config[$category] = array(); 
    4953      } 
    5054    } 
     
    96100    $data[] = "{"; 
    97101 
    98     $ret = $this->generateRegistration('GET', $data, $methods, $names, $validators); 
    99  
    100     if ($ret
    101     { 
    102       $data[] = sprintf("  \$this->context->getRequest()->setAttribute('symfony.fillin', %s);", $fillin); 
     102    $this->generateRegistration('GET', $data, $methods, $names, $validators); 
     103 
     104    if (count($fillin)
     105    { 
     106      $data[] = sprintf("  \$context->getRequest()->setAttribute('fillin', %s, 'symfony/filter');", $fillin); 
    103107    } 
    104108 
     
    109113    $data[] = "{"; 
    110114 
    111     $ret = $this->generateRegistration('POST', $data, $methods, $names, $validators); 
    112  
    113     if ($ret
    114     { 
    115       $data[] = sprintf("  \$this->context->getRequest()->setAttribute('symfony.fillin', %s);", $fillin); 
     115    $this->generateRegistration('POST', $data, $methods, $names, $validators); 
     116 
     117    if (count($fillin)
     118    { 
     119      $data[] = sprintf("  \$context->getRequest()->setAttribute('fillin', %s, 'symfony/filter');", $fillin); 
    116120    } 
    117121 
     
    178182          $validator =& $validators[$valName]; 
    179183 
    180           $data[] = sprintf("  \$validators['%s'] = new %s(\$this->context, %s);\n", 
    181                             $valName, $validator['class'], $validator['parameters']); 
     184          $data[] = sprintf("  \$validators['%s'] = new %s();\n". 
     185                            "  \$validators['%s']->initialize(%s, %s);", 
     186                            $valName, $validator['class'], $valName, '$context', $validator['parameters']); 
    182187 
    183188          // mark this validator as created for this request method 
     
    247252        { 
    248253          // unknown parent or subname 
    249           throw new sfParseException(sprintf('Configuration file "%s" specifies unregistered parent "%s" or subname "%s".', $configFiles[0], $parent, $subname)); 
     254          $error = sprintf('Configuration file "%s" specifies unregistered parent "%s" or subname "%s"', $configFiles[0], $parent, $subname); 
     255          throw new sfParseException($error); 
    250256        } 
    251257 
     
    258264        { 
    259265          // unknown name 
    260           throw new sfParseException(sprintf('Configuration file "%s" specifies unregistered name "%s".', $configFiles[0], $name)); 
     266          $error = sprintf('Configuration file "%s" specifies unregistered name "%s"', $configFiles[0], $name); 
     267          throw new sfParseException($error); 
    261268        } 
    262269 
     
    309316      { 
    310317        // missing 'required' attribute 
    311         throw new sfParseException(sprintf('Configuration file "%s" specifies file or parameter "%s", but it is missing the "required" attribute.', $configFiles[0], $name)); 
     318        $error = sprintf('Configuration file "%s" specifies file or parameter "%s", but it is missing the "required" attribute', $configFiles[0], $name); 
     319        throw new sfParseException($error); 
    312320      } 
    313321 
     
    344352        // name contains an invalid character 
    345353        // this is most likely a typo where the user forgot to add a brace 
    346         throw new sfParseException(sprintf('Configuration file "%s" specifies method "%s" with invalid file/parameter name "%s".', $configFiles[0], $method, $name)); 
     354        $error = sprintf('Configuration file "%s" specifies method "%s" with invalid file/parameter name "%s"', $configFiles[0], $method, $name); 
     355        throw new sfParseException($error); 
    347356      } 
    348357      else 
     
    405414      { 
    406415        // validator hasn't been registered 
    407         throw new sfParseException(sprintf('Configuration file "%s" specifies unregistered validator "%s".', $configFiles[0], $validator)); 
     416        $error = sprintf('Configuration file "%s" specifies unregistered validator "%s"', $configFiles[0], $validator); 
     417        throw new sfParseException($error); 
    408418      } 
    409419 
     
    417427      { 
    418428        // missing class key 
    419         throw new sfParseException(sprintf('Configuration file "%s" specifies category "%s" with missing class key.', $configFiles[0], $validator)); 
     429        $error = sprintf('Configuration file "%s" specifies category "%s" with missing class key', $configFiles[0], $validator); 
     430        throw new sfParseException($error); 
    420431      } 
    421432 
     
    438449        { 
    439450          // file doesn't exist 
    440           throw new sfParseException(sprintf('Configuration file "%s" specifies category "%s" with nonexistent or unreadable file "%s".', $configFiles[0], $validator, $file)); 
     451          $error = sprintf('Configuration file "%s" specifies category "%s" with nonexistent or unreadable file "%s"', $configFiles[0], $validator, $file); 
     452          throw new sfParseException($error); 
    441453        } 
    442454