StringStorageInterface.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <?php
  2. /**
  3. * @file
  4. * Contains \StringStorageInterface.
  5. */
  6. /**
  7. * Defines the locale string storage interface.
  8. */
  9. interface StringStorageInterface {
  10. /**
  11. * Loads multiple source string objects.
  12. *
  13. * @param array $conditions
  14. * (optional) Array with conditions that will be used to filter the strings
  15. * returned and may include any of the following elements:
  16. * - Any simple field value indexed by field name.
  17. * - 'translated', TRUE to get only translated strings or FALSE to get only
  18. * untranslated strings. If not set it returns both translated and
  19. * untranslated strings that fit the other conditions.
  20. * Defaults to no conditions which means that it will load all strings.
  21. * @param array $options
  22. * (optional) An associative array of additional options. It may contain
  23. * any of the following optional keys:
  24. * - 'filters': Array of string filters indexed by field name.
  25. * - 'pager limit': Use pager and set this limit value.
  26. *
  27. * @return array
  28. * Array of \StringInterface objects matching the conditions.
  29. */
  30. public function getStrings(array $conditions = array(), array $options = array());
  31. /**
  32. * Loads multiple string translation objects.
  33. *
  34. * @param array $conditions
  35. * (optional) Array with conditions that will be used to filter the strings
  36. * returned and may include all of the conditions defined by getStrings().
  37. * @param array $options
  38. * (optional) An associative array of additional options. It may contain
  39. * any of the options defined by getStrings().
  40. *
  41. * @return array
  42. * Array of \StringInterface objects matching the conditions.
  43. *
  44. * @see StringStorageInterface::getStrings()
  45. */
  46. public function getTranslations(array $conditions = array(), array $options = array());
  47. /**
  48. * Loads a string source object, fast query.
  49. *
  50. * These 'fast query' methods are the ones in the critical path and their
  51. * implementation must be optimized for speed, as they may run many times
  52. * in a single page request.
  53. *
  54. * @param array $conditions
  55. * (optional) Array with conditions that will be used to filter the strings
  56. * returned and may include all of the conditions defined by getStrings().
  57. *
  58. * @return \SourceString|null
  59. * Minimal TranslationString object if found, NULL otherwise.
  60. */
  61. public function findString(array $conditions);
  62. /**
  63. * Loads a string translation object, fast query.
  64. *
  65. * This function must only be used when actually translating strings as it
  66. * will have the effect of updating the string version. For other purposes
  67. * the getTranslations() method should be used instead.
  68. *
  69. * @param array $conditions
  70. * (optional) Array with conditions that will be used to filter the strings
  71. * returned and may include all of the conditions defined by getStrings().
  72. *
  73. * @return \TranslationString|null
  74. * Minimal TranslationString object if found, NULL otherwise.
  75. */
  76. public function findTranslation(array $conditions);
  77. /**
  78. * Save string object to storage.
  79. *
  80. * @param \StringInterface $string
  81. * The string object.
  82. *
  83. * @return \StringStorageInterface
  84. * The called object.
  85. *
  86. * @throws \StringStorageException
  87. * In case of failures, an exception is thrown.
  88. */
  89. public function save($string);
  90. /**
  91. * Delete string from storage.
  92. *
  93. * @param \StringInterface $string
  94. * The string object.
  95. *
  96. * @return \StringStorageInterface
  97. * The called object.
  98. *
  99. * @throws \StringStorageException
  100. * In case of failures, an exception is thrown.
  101. */
  102. public function delete($string);
  103. /**
  104. * Deletes source strings and translations using conditions.
  105. *
  106. * @param array $conditions
  107. * Array with simple field conditions for source strings.
  108. */
  109. public function deleteStrings($conditions);
  110. /**
  111. * Deletes translations using conditions.
  112. *
  113. * @param array $conditions
  114. * Array with simple field conditions for string translations.
  115. */
  116. public function deleteTranslations($conditions);
  117. /**
  118. * Counts source strings.
  119. *
  120. * @return int
  121. * The number of source strings contained in the storage.
  122. */
  123. public function countStrings();
  124. /**
  125. * Counts translations.
  126. *
  127. * @return array
  128. * The number of translations for each language indexed by language code.
  129. */
  130. public function countTranslations();
  131. /**
  132. * Creates a source string object bound to this storage but not saved.
  133. *
  134. * @param array $values
  135. * (optional) Array with initial values. Defaults to empty array.
  136. *
  137. * @return \SourceString
  138. * New source string object.
  139. */
  140. public function createString($values = array());
  141. /**
  142. * Creates a string translation object bound to this storage but not saved.
  143. *
  144. * @param array $values
  145. * (optional) Array with initial values. Defaults to empty array.
  146. *
  147. * @return \TranslationString
  148. * New string translation object.
  149. */
  150. public function createTranslation($values = array());
  151. }