ClassMetadata.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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 LGPL. 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. * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
  24. * @link www.doctrine-project.org
  25. * @since 2.1
  26. * @author Benjamin Eberlei <kontakt@beberlei.de>
  27. * @author Jonathan Wage <jonwage@gmail.com>
  28. */
  29. interface ClassMetadata
  30. {
  31. /**
  32. * Get fully-qualified class name of this persistent class.
  33. *
  34. * @return string
  35. */
  36. function getName();
  37. /**
  38. * Gets the mapped identifier field name.
  39. *
  40. * The returned structure is an array of the identifier field names.
  41. *
  42. * @return array
  43. */
  44. function getIdentifier();
  45. /**
  46. * Gets the ReflectionClass instance for this mapped class.
  47. *
  48. * @return ReflectionClass
  49. */
  50. function getReflectionClass();
  51. /**
  52. * Checks if the given field name is a mapped identifier for this class.
  53. *
  54. * @param string $fieldName
  55. * @return boolean
  56. */
  57. function isIdentifier($fieldName);
  58. /**
  59. * Checks if the given field is a mapped property for this class.
  60. *
  61. * @param string $fieldName
  62. * @return boolean
  63. */
  64. function hasField($fieldName);
  65. /**
  66. * Checks if the given field is a mapped association for this class.
  67. *
  68. * @param string $fieldName
  69. * @return boolean
  70. */
  71. function hasAssociation($fieldName);
  72. /**
  73. * Checks if the given field is a mapped single valued association for this class.
  74. *
  75. * @param string $fieldName
  76. * @return boolean
  77. */
  78. function isSingleValuedAssociation($fieldName);
  79. /**
  80. * Checks if the given field is a mapped collection valued association for this class.
  81. *
  82. * @param string $fieldName
  83. * @return boolean
  84. */
  85. function isCollectionValuedAssociation($fieldName);
  86. /**
  87. * A numerically indexed list of field names of this persistent class.
  88. *
  89. * This array includes identifier fields if present on this class.
  90. *
  91. * @return array
  92. */
  93. function getFieldNames();
  94. /**
  95. * Returns an array of identifier field names numerically indexed.
  96. *
  97. * @return array
  98. */
  99. function getIdentifierFieldNames();
  100. /**
  101. * A numerically indexed list of association names of this persistent class.
  102. *
  103. * This array includes identifier associations if present on this class.
  104. *
  105. * @return array
  106. */
  107. function getAssociationNames();
  108. /**
  109. * Returns a type name of this field.
  110. *
  111. * This type names can be implementation specific but should at least include the php types:
  112. * integer, string, boolean, float/double, datetime.
  113. *
  114. * @param string $fieldName
  115. * @return string
  116. */
  117. function getTypeOfField($fieldName);
  118. /**
  119. * Returns the target class name of the given association.
  120. *
  121. * @param string $assocName
  122. * @return string
  123. */
  124. function getAssociationTargetClass($assocName);
  125. /**
  126. * Checks if the association is the inverse side of a bidirectional association
  127. *
  128. * @param string $assocName
  129. * @return boolean
  130. */
  131. function isAssociationInverseSide($assocName);
  132. /**
  133. * Returns the target field of the owning side of the association
  134. *
  135. * @param string $assocName
  136. * @return string
  137. */
  138. function getAssociationMappedByTargetField($assocName);
  139. /**
  140. * Return the identifier of this object as an array with field name as key.
  141. *
  142. * Has to return an empty array if no identifier isset.
  143. *
  144. * @param object $object
  145. * @return array
  146. */
  147. function getIdentifierValues($object);
  148. }