EnableAutoMapping.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
  13. /**
  14. * Enables auto mapping.
  15. *
  16. * Using the annotations on a property has higher precedence than using it on a class,
  17. * which has higher precedence than any configuration that might be defined outside the class.
  18. *
  19. * @Annotation
  20. *
  21. * @author Kévin Dunglas <dunglas@gmail.com>
  22. */
  23. #[\Attribute(\Attribute::TARGET_PROPERTY | \Attribute::TARGET_METHOD | \Attribute::TARGET_CLASS)]
  24. class EnableAutoMapping extends Constraint
  25. {
  26. public function __construct(array $options = null)
  27. {
  28. if (\is_array($options) && \array_key_exists('groups', $options)) {
  29. throw new ConstraintDefinitionException(sprintf('The option "groups" is not supported by the constraint "%s".', __CLASS__));
  30. }
  31. parent::__construct($options);
  32. }
  33. /**
  34. * {@inheritdoc}
  35. */
  36. public function getTargets()
  37. {
  38. return [self::PROPERTY_CONSTRAINT, self::CLASS_CONSTRAINT];
  39. }
  40. }