ValidReferenceConstraint.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace Drupal\Core\Entity\Plugin\Validation\Constraint;
  3. use Symfony\Component\Validator\Constraint;
  4. /**
  5. * Entity Reference valid reference constraint.
  6. *
  7. * Verifies that referenced entities are valid.
  8. *
  9. * @Constraint(
  10. * id = "ValidReference",
  11. * label = @Translation("Entity Reference valid reference", context = "Validation")
  12. * )
  13. */
  14. class ValidReferenceConstraint extends Constraint {
  15. /**
  16. * The default violation message.
  17. *
  18. * @var string
  19. */
  20. public $message = 'This entity (%type: %id) cannot be referenced.';
  21. /**
  22. * Violation message when the entity does not exist.
  23. *
  24. * @var string
  25. */
  26. public $nonExistingMessage = 'The referenced entity (%type: %id) does not exist.';
  27. /**
  28. * Violation message when a new entity ("autocreate") is invalid.
  29. *
  30. * @var string
  31. */
  32. public $invalidAutocreateMessage = 'This entity (%type: %label) cannot be referenced.';
  33. /**
  34. * Violation message when the target_id is empty.
  35. *
  36. * @var string
  37. */
  38. public $nullMessage = 'This value should not be null.';
  39. }