ClassMetadata.php 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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. public 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. public function getIdentifier();
  45. /**
  46. * Gets the ReflectionClass instance for this mapped class.
  47. *
  48. * @return ReflectionClass
  49. */
  50. public 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. public 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. public 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. public 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. public 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. public 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. public function getFieldNames();
  94. /**
  95. * A numerically indexed list of association names of this persistent class.
  96. *
  97. * This array includes identifier associations if present on this class.
  98. *
  99. * @return array
  100. */
  101. public function getAssociationNames();
  102. /**
  103. * Returns a type name of this field.
  104. *
  105. * This type names can be implementation specific but should at least include the php types:
  106. * integer, string, boolean, float/double, datetime.
  107. *
  108. * @param string $fieldName
  109. * @return string
  110. */
  111. public function getTypeOfField($fieldName);
  112. /**
  113. * Returns the target class name of the given association.
  114. *
  115. * @param string $assocName
  116. * @return string
  117. */
  118. public function getAssociationTargetClass($assocName);
  119. }