Changeset 8755
- Timestamp:
- 05/03/08 20:34:29 (5 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.1/lib/plugins/sfCompat10Plugin/lib/config/sfValidatorConfigHandler.class.php
r7792 r8755 46 46 if (!isset($config[$category])) 47 47 { 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(); 49 53 } 50 54 } … … 96 100 $data[] = "{"; 97 101 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); 103 107 } 104 108 … … 109 113 $data[] = "{"; 110 114 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); 116 120 } 117 121 … … 178 182 $validator =& $validators[$valName]; 179 183 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']); 182 187 183 188 // mark this validator as created for this request method … … 247 252 { 248 253 // 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); 250 256 } 251 257 … … 258 264 { 259 265 // 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); 261 268 } 262 269 … … 309 316 { 310 317 // 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); 312 320 } 313 321 … … 344 352 // name contains an invalid character 345 353 // 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); 347 356 } 348 357 else … … 405 414 { 406 415 // 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); 408 418 } 409 419 … … 417 427 { 418 428 // 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); 420 431 } 421 432 … … 438 449 { 439 450 // 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); 441 453 } 442 454