3 namespace Drupal\locale;
6 * Defines the locale string storage interface.
8 interface StringStorageInterface {
11 * Loads multiple source string objects.
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.
28 * Array of \Drupal\locale\StringInterface objects matching the conditions.
30 public function getStrings(array $conditions = [], array $options = []);
33 * Loads multiple string translation objects.
35 * @param array $conditions
36 * (optional) Array with conditions that will be used to filter the strings
37 * returned and may include all of the conditions defined by getStrings().
38 * @param array $options
39 * (optional) An associative array of additional options. It may contain
40 * any of the options defined by getStrings().
42 * @return \Drupal\locale\StringInterface[]
43 * Array of \Drupal\locale\StringInterface objects matching the conditions.
45 * @see \Drupal\locale\StringStorageInterface::getStrings()
47 public function getTranslations(array $conditions = [], array $options = []);
50 * Loads string location information.
52 * @param array $conditions
53 * (optional) Array with conditions to filter the locations that may be any
54 * of the following elements:
55 * - 'sid', The string identifier.
56 * - 'type', The location type.
57 * - 'name', The location name.
59 * @return \Drupal\locale\StringInterface[]
60 * Array of \Drupal\locale\StringInterface objects matching the conditions.
62 * @see \Drupal\locale\StringStorageInterface::getStrings()
64 public function getLocations(array $conditions = []);
67 * Loads a string source object, fast query.
69 * These 'fast query' methods are the ones in the critical path and their
70 * implementation must be optimized for speed, as they may run many times
71 * in a single page request.
73 * @param array $conditions
74 * (optional) Array with conditions that will be used to filter the strings
75 * returned and may include all of the conditions defined by getStrings().
77 * @return \Drupal\locale\SourceString|null
78 * Minimal TranslationString object if found, NULL otherwise.
80 public function findString(array $conditions);
83 * Loads a string translation object, fast query.
85 * This function must only be used when actually translating strings as it
86 * will have the effect of updating the string version. For other purposes
87 * the getTranslations() method should be used instead.
89 * @param array $conditions
90 * (optional) Array with conditions that will be used to filter the strings
91 * returned and may include all of the conditions defined by getStrings().
93 * @return \Drupal\locale\TranslationString|null
94 * Minimal TranslationString object if found, NULL otherwise.
96 public function findTranslation(array $conditions);
99 * Save string object to storage.
101 * @param \Drupal\locale\StringInterface $string
104 * @return \Drupal\locale\StringStorageInterface
107 * @throws \Drupal\locale\StringStorageException
108 * In case of failures, an exception is thrown.
110 public function save($string);
113 * Delete string from storage.
115 * @param \Drupal\locale\StringInterface $string
118 * @return \Drupal\locale\StringStorageInterface
121 * @throws \Drupal\locale\StringStorageException
122 * In case of failures, an exception is thrown.
124 public function delete($string);
127 * Deletes source strings and translations using conditions.
129 * @param array $conditions
130 * Array with simple field conditions for source strings.
132 public function deleteStrings($conditions);
135 * Deletes translations using conditions.
137 * @param array $conditions
138 * Array with simple field conditions for string translations.
140 public function deleteTranslations($conditions);
143 * Counts source strings.
146 * The number of source strings contained in the storage.
148 public function countStrings();
151 * Counts translations.
154 * The number of translations for each language indexed by language code.
156 public function countTranslations();
159 * Creates a source string object bound to this storage but not saved.
161 * @param array $values
162 * (optional) Array with initial values. Defaults to empty array.
164 * @return \Drupal\locale\SourceString
165 * New source string object.
167 public function createString($values = []);
170 * Creates a string translation object bound to this storage but not saved.
172 * @param array $values
173 * (optional) Array with initial values. Defaults to empty array.
175 * @return \Drupal\locale\TranslationString
176 * New string translation object.
178 public function createTranslation($values = []);