sfValidatorSchemaForEach.class.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /*
  3. * This file is part of the symfony package.
  4. * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
  5. *
  6. * For the full copyright and license information, please view the LICENSE
  7. * file that was distributed with this source code.
  8. */
  9. /**
  10. * sfValidatorSchemaForEach wraps a validator multiple times in a single validator.
  11. *
  12. * @package symfony
  13. * @subpackage validator
  14. * @author Fabien Potencier <fabien.potencier@symfony-project.com>
  15. * @version SVN: $Id: sfValidatorSchemaForEach.class.php 9048 2008-05-19 09:11:23Z FabianLange $
  16. */
  17. class sfValidatorSchemaForEach extends sfValidatorSchema
  18. {
  19. /**
  20. * Constructor.
  21. *
  22. * @param sfValidatorBase $validator Initial validator
  23. * @param integer $count The number of times to replicate the validator
  24. * @param array $options An array of options
  25. * @param array $messages An array of error messages
  26. *
  27. * @see sfValidatorBase
  28. */
  29. public function __construct(sfValidatorBase $validator, $count, $options = array(), $messages = array())
  30. {
  31. $fields = array();
  32. for ($i = 0; $i < $count; $i++)
  33. {
  34. $fields[$i] = clone $validator;
  35. }
  36. parent::__construct($fields, $options, $messages);
  37. }
  38. /**
  39. * @see sfValidatorBase
  40. */
  41. public function asString($indent = 0)
  42. {
  43. throw new Exception('Unable to convert a sfValidatorSchemaForEach to string.');
  44. }
  45. }