ClassMetadata.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <?php
  2. /*
  3. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  4. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  5. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  6. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  7. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  8. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  9. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  10. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  11. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  12. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  13. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  14. *
  15. * This software consists of voluntary contributions made by many individuals
  16. * and is licensed under the MIT license. For more information, see
  17. * <http://www.doctrine-project.org>.
  18. */
  19. namespace Doctrine\Common\Persistence\Mapping;
  20. /**
  21. * Contract for a Doctrine persistence layer ClassMetadata class to implement.
  22. *
  23. * @link www.doctrine-project.org
  24. * @since 2.1
  25. * @author Benjamin Eberlei <kontakt@beberlei.de>
  26. * @author Jonathan Wage <jonwage@gmail.com>
  27. */
  28. interface ClassMetadata
  29. {
  30. /**
  31. * Gets the fully-qualified class name of this persistent class.
  32. *
  33. * @return string
  34. */
  35. public function getName();
  36. /**
  37. * Gets the mapped identifier field name.
  38. *
  39. * The returned structure is an array of the identifier field names.
  40. *
  41. * @return array
  42. */
  43. public function getIdentifier();
  44. /**
  45. * Gets the ReflectionClass instance for this mapped class.
  46. *
  47. * @return \ReflectionClass
  48. */
  49. public function getReflectionClass();
  50. /**
  51. * Checks if the given field name is a mapped identifier for this class.
  52. *
  53. * @param string $fieldName
  54. *
  55. * @return boolean
  56. */
  57. public function isIdentifier($fieldName);
  58. /**
  59. * Checks if the given field is a mapped property for this class.
  60. *
  61. * @param string $fieldName
  62. *
  63. * @return boolean
  64. */
  65. public function hasField($fieldName);
  66. /**
  67. * Checks if the given field is a mapped association for this class.
  68. *
  69. * @param string $fieldName
  70. *
  71. * @return boolean
  72. */
  73. public function hasAssociation($fieldName);
  74. /**
  75. * Checks if the given field is a mapped single valued association for this class.
  76. *
  77. * @param string $fieldName
  78. *
  79. * @return boolean
  80. */
  81. public function isSingleValuedAssociation($fieldName);
  82. /**
  83. * Checks if the given field is a mapped collection valued association for this class.
  84. *
  85. * @param string $fieldName
  86. *
  87. * @return boolean
  88. */
  89. public function isCollectionValuedAssociation($fieldName);
  90. /**
  91. * A numerically indexed list of field names of this persistent class.
  92. *
  93. * This array includes identifier fields if present on this class.
  94. *
  95. * @return array
  96. */
  97. public function getFieldNames();
  98. /**
  99. * Returns an array of identifier field names numerically indexed.
  100. *
  101. * @return array
  102. */
  103. public function getIdentifierFieldNames();
  104. /**
  105. * Returns a numerically indexed list of association names of this persistent class.
  106. *
  107. * This array includes identifier associations if present on this class.
  108. *
  109. * @return array
  110. */
  111. public function getAssociationNames();
  112. /**
  113. * Returns a type name of this field.
  114. *
  115. * This type names can be implementation specific but should at least include the php types:
  116. * integer, string, boolean, float/double, datetime.
  117. *
  118. * @param string $fieldName
  119. *
  120. * @return string
  121. */
  122. public function getTypeOfField($fieldName);
  123. /**
  124. * Returns the target class name of the given association.
  125. *
  126. * @param string $assocName
  127. *
  128. * @return string
  129. */
  130. public function getAssociationTargetClass($assocName);
  131. /**
  132. * Checks if the association is the inverse side of a bidirectional association.
  133. *
  134. * @param string $assocName
  135. *
  136. * @return boolean
  137. */
  138. public function isAssociationInverseSide($assocName);
  139. /**
  140. * Returns the target field of the owning side of the association.
  141. *
  142. * @param string $assocName
  143. *
  144. * @return string
  145. */
  146. public function getAssociationMappedByTargetField($assocName);
  147. /**
  148. * Returns the identifier of this object as an array with field name as key.
  149. *
  150. * Has to return an empty array if no identifier isset.
  151. *
  152. * @param object $object
  153. *
  154. * @return array
  155. */
  156. public function getIdentifierValues($object);
  157. }