3 namespace Drupal\locale;
6 * Defines the locale string interface.
8 interface StringInterface {
11 * Gets the string unique identifier.
14 * The string identifier.
16 public function getId();
19 * Sets the string unique identifier.
22 * The string identifier.
26 public function setId($id);
29 * Gets the string version.
34 public function getVersion();
37 * Sets the string version.
39 * @param string $version
44 public function setVersion($version);
47 * Gets plain string contained in this object.
50 * The string contained in this object.
52 public function getString();
55 * Sets the string contained in this object.
57 * @param string $string
58 * String to set as value.
62 public function setString($string);
65 * Splits string to work with plural values.
68 * Array of strings that are plural variants.
70 public function getPlurals();
73 * Sets this string using array of plural values.
75 * Serializes plural variants in one string glued by LOCALE_PLURAL_DELIMITER.
77 * @param array $plurals
78 * Array of strings with plural variants.
82 public function setPlurals($plurals);
85 * Gets the string storage.
87 * @return \Drupal\locale\StringStorageInterface
88 * The storage used for this string.
90 public function getStorage();
93 * Sets the string storage.
95 * @param \Drupal\locale\StringStorageInterface $storage
96 * The storage to use for this string.
100 public function setStorage($storage);
103 * Checks whether the object is not saved to storage yet.
106 * TRUE if the object exists in the storage, FALSE otherwise.
108 public function isNew();
111 * Checks whether the object is a source string.
114 * TRUE if the object is a source string, FALSE otherwise.
116 public function isSource();
119 * Checks whether the object is a translation string.
122 * TRUE if the object is a translation string, FALSE otherwise.
124 public function isTranslation();
127 * Sets an array of values as object properties.
129 * @param array $values
130 * Array with values indexed by property name.
131 * @param bool $override
132 * (optional) Whether to override already set fields, defaults to TRUE.
136 public function setValues(array $values, $override = TRUE);
139 * Gets field values that are set for given field names.
141 * @param array $fields
142 * Array of field names.
145 * Array of field values indexed by field name.
147 public function getValues(array $fields);
150 * Gets location information for this string.
152 * Locations are arbitrary pairs of type and name strings, used to store
153 * information about the origins of the string, like the file name it
154 * was found on, the path on which it was discovered, etc.
156 * A string can have any number of locations since the same string may be
157 * found on different places of Drupal code and configuration.
159 * @param bool $check_only
160 * (optional) Set to TRUE to get only new locations added during the
161 * current page request and not loading all existing locations.
164 * Location ids indexed by type and name.
166 public function getLocations($check_only = FALSE);
169 * Adds a location for this string.
171 * @param string $type
172 * Location type that may be any arbitrary string. Types used in Drupal
173 * core are: 'javascript', 'path', 'code', 'configuration'.
174 * @param string $name
175 * Location name. Drupal path in case of online discovered translations,
176 * file path in case of imported strings, configuration name for strings
177 * that come from configuration, etc.
181 public function addLocation($type, $name);
184 * Checks whether the string has a given location.
186 * @param string $type
188 * @param string $name
192 * TRUE if the string has a location with this type and name.
194 public function hasLocation($type, $name);
197 * Saves string object to storage.
201 * @throws \Drupal\locale\StringStorageException
202 * In case of failures, an exception is thrown.
204 public function save();
207 * Deletes string object from storage.
211 * @throws \Drupal\locale\StringStorageException
212 * In case of failures, an exception is thrown.
214 public function delete();