Collection.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Validator\Constraints;
  11. class Collection extends \Symfony\Component\Validator\Constraint
  12. {
  13. public $fields;
  14. public $allowExtraFields = false;
  15. public $allowMissingFields = false;
  16. public $extraFieldsMessage = 'The fields {{ fields }} were not expected';
  17. public $missingFieldsMessage = 'The fields {{ fields }} are missing';
  18. /**
  19. * {@inheritDoc}
  20. */
  21. public function __construct($options = null)
  22. {
  23. // no known options set? $options is the fields array
  24. if (is_array($options)
  25. && !array_intersect(array_keys($options), array('groups', 'fields', 'allowExtraFields', 'allowMissingFields', 'extraFieldsMessage', 'missingFieldsMessage'))) {
  26. $options = array('fields' => $options);
  27. }
  28. parent::__construct($options);
  29. }
  30. public function getRequiredOptions()
  31. {
  32. return array('fields');
  33. }
  34. }