ClassMetadataInterface.php 3.4 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\Mapping;
  11. /**
  12. * Stores all metadata needed for validating objects of specific class.
  13. *
  14. * Most importantly, the metadata stores the constraints against which an object
  15. * and its properties should be validated.
  16. *
  17. * Additionally, the metadata stores whether the "Default" group is overridden
  18. * by a group sequence for that class and whether instances of that class
  19. * should be traversed or not.
  20. *
  21. * @author Bernhard Schussek <bschussek@gmail.com>
  22. *
  23. * @see MetadataInterface
  24. * @see \Symfony\Component\Validator\Constraints\GroupSequence
  25. * @see \Symfony\Component\Validator\GroupSequenceProviderInterface
  26. * @see TraversalStrategy
  27. */
  28. interface ClassMetadataInterface extends MetadataInterface
  29. {
  30. /**
  31. * Returns the names of all constrained properties.
  32. *
  33. * @return string[] A list of property names
  34. */
  35. public function getConstrainedProperties();
  36. /**
  37. * Returns whether the "Default" group is overridden by a group sequence.
  38. *
  39. * If it is, you can access the group sequence with {@link getGroupSequence()}.
  40. *
  41. * @return bool Returns true if the "Default" group is overridden
  42. *
  43. * @see \Symfony\Component\Validator\Constraints\GroupSequence
  44. */
  45. public function hasGroupSequence();
  46. /**
  47. * Returns the group sequence that overrides the "Default" group for this
  48. * class.
  49. *
  50. * @return \Symfony\Component\Validator\Constraints\GroupSequence|null The group sequence or null
  51. *
  52. * @see \Symfony\Component\Validator\Constraints\GroupSequence
  53. */
  54. public function getGroupSequence();
  55. /**
  56. * Returns whether the "Default" group is overridden by a dynamic group
  57. * sequence obtained by the validated objects.
  58. *
  59. * If this method returns true, the class must implement
  60. * {@link \Symfony\Component\Validator\GroupSequenceProviderInterface}.
  61. * This interface will be used to obtain the group sequence when an object
  62. * of this class is validated.
  63. *
  64. * @return bool Returns true if the "Default" group is overridden by
  65. * a dynamic group sequence
  66. *
  67. * @see \Symfony\Component\Validator\GroupSequenceProviderInterface
  68. */
  69. public function isGroupSequenceProvider();
  70. /**
  71. * Check if there's any metadata attached to the given named property.
  72. *
  73. * @param string $property The property name
  74. *
  75. * @return bool
  76. */
  77. public function hasPropertyMetadata(string $property);
  78. /**
  79. * Returns all metadata instances for the given named property.
  80. *
  81. * If your implementation does not support properties, throw an exception
  82. * in this method (for example a <tt>BadMethodCallException</tt>).
  83. *
  84. * @param string $property The property name
  85. *
  86. * @return PropertyMetadataInterface[] A list of metadata instances. Empty if
  87. * no metadata exists for the property.
  88. */
  89. public function getPropertyMetadata(string $property);
  90. /**
  91. * Returns the name of the backing PHP class.
  92. *
  93. * @return string The name of the backing class
  94. */
  95. public function getClassName();
  96. }