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