Entity.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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\Tests\Fixtures;
  11. use Symfony\Component\Validator\Constraints as Assert;
  12. use Symfony\Component\Validator\ExecutionContextInterface;
  13. /**
  14. * @Symfony\Component\Validator\Tests\Fixtures\ConstraintA
  15. * @Assert\GroupSequence({"Foo", "Entity"})
  16. * @Assert\Callback({"Symfony\Component\Validator\Tests\Fixtures\CallbackClass", "callback"})
  17. */
  18. class Entity extends EntityParent implements EntityInterfaceB
  19. {
  20. /**
  21. * @Assert\NotNull
  22. * @Assert\Range(min=3)
  23. * @Assert\All({@Assert\NotNull, @Assert\Range(min=3)}),
  24. * @Assert\All(constraints={@Assert\NotNull, @Assert\Range(min=3)})
  25. * @Assert\Collection(fields={
  26. * "foo" = {@Assert\NotNull, @Assert\Range(min=3)},
  27. * "bar" = @Assert\Range(min=5)
  28. * })
  29. * @Assert\Choice(choices={"A", "B"}, message="Must be one of %choices%")
  30. */
  31. public $firstName;
  32. protected $lastName;
  33. public $reference;
  34. public $reference2;
  35. private $internal;
  36. public $data = 'Overridden data';
  37. public $initialized = false;
  38. public function __construct($internal = null)
  39. {
  40. $this->internal = $internal;
  41. }
  42. public function getInternal()
  43. {
  44. return $this->internal.' from getter';
  45. }
  46. public function setLastName($lastName)
  47. {
  48. $this->lastName = $lastName;
  49. }
  50. /**
  51. * @Assert\NotNull
  52. */
  53. public function getLastName()
  54. {
  55. return $this->lastName;
  56. }
  57. public function getValid()
  58. {
  59. }
  60. /**
  61. * @Assert\IsTrue
  62. */
  63. public function isValid()
  64. {
  65. return 'valid';
  66. }
  67. /**
  68. * @Assert\IsTrue
  69. */
  70. public function hasPermissions()
  71. {
  72. return 'permissions';
  73. }
  74. public function getData()
  75. {
  76. return 'Overridden data';
  77. }
  78. /**
  79. * @Assert\Callback(payload="foo")
  80. */
  81. public function validateMe(ExecutionContextInterface $context)
  82. {
  83. }
  84. /**
  85. * @Assert\Callback
  86. */
  87. public static function validateMeStatic($object, ExecutionContextInterface $context)
  88. {
  89. }
  90. }