Collection.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. use Symfony\Component\Validator\Constraint;
  12. class Collection extends Constraint
  13. {
  14. public $fields;
  15. public $allowExtraFields = false;
  16. public $allowMissingFields = false;
  17. public $extraFieldsMessage = 'The fields {{ fields }} were not expected';
  18. public $missingFieldsMessage = 'The fields {{ fields }} are missing';
  19. /**
  20. * {@inheritDoc}
  21. */
  22. public function __construct($options = null)
  23. {
  24. // no known options set? $options is the fields array
  25. if (is_array($options)
  26. && !array_intersect(array_keys($options), array('groups', 'fields', 'allowExtraFields', 'allowMissingFields', 'extraFieldsMessage', 'missingFieldsMessage'))) {
  27. $options = array('fields' => $options);
  28. }
  29. parent::__construct($options);
  30. }
  31. public function getRequiredOptions()
  32. {
  33. return array('fields');
  34. }
  35. }