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 interface.
|
Chris@0
|
7 */
|
Chris@0
|
8 interface StringInterface {
|
Chris@0
|
9
|
Chris@0
|
10 /**
|
Chris@0
|
11 * Gets the string unique identifier.
|
Chris@0
|
12 *
|
Chris@0
|
13 * @return int
|
Chris@0
|
14 * The string identifier.
|
Chris@0
|
15 */
|
Chris@0
|
16 public function getId();
|
Chris@0
|
17
|
Chris@0
|
18 /**
|
Chris@0
|
19 * Sets the string unique identifier.
|
Chris@0
|
20 *
|
Chris@0
|
21 * @param int $id
|
Chris@0
|
22 * The string identifier.
|
Chris@0
|
23 *
|
Chris@0
|
24 * @return $this
|
Chris@0
|
25 */
|
Chris@0
|
26 public function setId($id);
|
Chris@0
|
27
|
Chris@0
|
28 /**
|
Chris@0
|
29 * Gets the string version.
|
Chris@0
|
30 *
|
Chris@0
|
31 * @return string
|
Chris@0
|
32 * Version identifier.
|
Chris@0
|
33 */
|
Chris@0
|
34 public function getVersion();
|
Chris@0
|
35
|
Chris@0
|
36 /**
|
Chris@0
|
37 * Sets the string version.
|
Chris@0
|
38 *
|
Chris@0
|
39 * @param string $version
|
Chris@0
|
40 * Version identifier.
|
Chris@0
|
41 *
|
Chris@0
|
42 * @return $this
|
Chris@0
|
43 */
|
Chris@0
|
44 public function setVersion($version);
|
Chris@0
|
45
|
Chris@0
|
46 /**
|
Chris@0
|
47 * Gets plain string contained in this object.
|
Chris@0
|
48 *
|
Chris@0
|
49 * @return string
|
Chris@0
|
50 * The string contained in this object.
|
Chris@0
|
51 */
|
Chris@0
|
52 public function getString();
|
Chris@0
|
53
|
Chris@0
|
54 /**
|
Chris@0
|
55 * Sets the string contained in this object.
|
Chris@0
|
56 *
|
Chris@0
|
57 * @param string $string
|
Chris@0
|
58 * String to set as value.
|
Chris@0
|
59 *
|
Chris@0
|
60 * @return $this
|
Chris@0
|
61 */
|
Chris@0
|
62 public function setString($string);
|
Chris@0
|
63
|
Chris@0
|
64 /**
|
Chris@0
|
65 * Splits string to work with plural values.
|
Chris@0
|
66 *
|
Chris@0
|
67 * @return array
|
Chris@0
|
68 * Array of strings that are plural variants.
|
Chris@0
|
69 */
|
Chris@0
|
70 public function getPlurals();
|
Chris@0
|
71
|
Chris@0
|
72 /**
|
Chris@0
|
73 * Sets this string using array of plural values.
|
Chris@0
|
74 *
|
Chris@0
|
75 * Serializes plural variants in one string glued by LOCALE_PLURAL_DELIMITER.
|
Chris@0
|
76 *
|
Chris@0
|
77 * @param array $plurals
|
Chris@0
|
78 * Array of strings with plural variants.
|
Chris@0
|
79 *
|
Chris@0
|
80 * @return $this
|
Chris@0
|
81 */
|
Chris@0
|
82 public function setPlurals($plurals);
|
Chris@0
|
83
|
Chris@0
|
84 /**
|
Chris@0
|
85 * Gets the string storage.
|
Chris@0
|
86 *
|
Chris@0
|
87 * @return \Drupal\locale\StringStorageInterface
|
Chris@0
|
88 * The storage used for this string.
|
Chris@0
|
89 */
|
Chris@0
|
90 public function getStorage();
|
Chris@0
|
91
|
Chris@0
|
92 /**
|
Chris@0
|
93 * Sets the string storage.
|
Chris@0
|
94 *
|
Chris@0
|
95 * @param \Drupal\locale\StringStorageInterface $storage
|
Chris@0
|
96 * The storage to use for this string.
|
Chris@0
|
97 *
|
Chris@0
|
98 * @return $this
|
Chris@0
|
99 */
|
Chris@0
|
100 public function setStorage($storage);
|
Chris@0
|
101
|
Chris@0
|
102 /**
|
Chris@0
|
103 * Checks whether the object is not saved to storage yet.
|
Chris@0
|
104 *
|
Chris@0
|
105 * @return bool
|
Chris@0
|
106 * TRUE if the object exists in the storage, FALSE otherwise.
|
Chris@0
|
107 */
|
Chris@0
|
108 public function isNew();
|
Chris@0
|
109
|
Chris@0
|
110 /**
|
Chris@0
|
111 * Checks whether the object is a source string.
|
Chris@0
|
112 *
|
Chris@0
|
113 * @return bool
|
Chris@0
|
114 * TRUE if the object is a source string, FALSE otherwise.
|
Chris@0
|
115 */
|
Chris@0
|
116 public function isSource();
|
Chris@0
|
117
|
Chris@0
|
118 /**
|
Chris@0
|
119 * Checks whether the object is a translation string.
|
Chris@0
|
120 *
|
Chris@0
|
121 * @return bool
|
Chris@0
|
122 * TRUE if the object is a translation string, FALSE otherwise.
|
Chris@0
|
123 */
|
Chris@0
|
124 public function isTranslation();
|
Chris@0
|
125
|
Chris@0
|
126 /**
|
Chris@0
|
127 * Sets an array of values as object properties.
|
Chris@0
|
128 *
|
Chris@0
|
129 * @param array $values
|
Chris@0
|
130 * Array with values indexed by property name.
|
Chris@0
|
131 * @param bool $override
|
Chris@0
|
132 * (optional) Whether to override already set fields, defaults to TRUE.
|
Chris@0
|
133 *
|
Chris@0
|
134 * @return $this
|
Chris@0
|
135 */
|
Chris@0
|
136 public function setValues(array $values, $override = TRUE);
|
Chris@0
|
137
|
Chris@0
|
138 /**
|
Chris@0
|
139 * Gets field values that are set for given field names.
|
Chris@0
|
140 *
|
Chris@0
|
141 * @param array $fields
|
Chris@0
|
142 * Array of field names.
|
Chris@0
|
143 *
|
Chris@0
|
144 * @return array
|
Chris@0
|
145 * Array of field values indexed by field name.
|
Chris@0
|
146 */
|
Chris@0
|
147 public function getValues(array $fields);
|
Chris@0
|
148
|
Chris@0
|
149 /**
|
Chris@0
|
150 * Gets location information for this string.
|
Chris@0
|
151 *
|
Chris@0
|
152 * Locations are arbitrary pairs of type and name strings, used to store
|
Chris@0
|
153 * information about the origins of the string, like the file name it
|
Chris@0
|
154 * was found on, the path on which it was discovered, etc.
|
Chris@0
|
155 *
|
Chris@0
|
156 * A string can have any number of locations since the same string may be
|
Chris@0
|
157 * found on different places of Drupal code and configuration.
|
Chris@0
|
158 *
|
Chris@0
|
159 * @param bool $check_only
|
Chris@0
|
160 * (optional) Set to TRUE to get only new locations added during the
|
Chris@0
|
161 * current page request and not loading all existing locations.
|
Chris@0
|
162 *
|
Chris@0
|
163 * @return array
|
Chris@0
|
164 * Location ids indexed by type and name.
|
Chris@0
|
165 */
|
Chris@0
|
166 public function getLocations($check_only = FALSE);
|
Chris@0
|
167
|
Chris@0
|
168 /**
|
Chris@0
|
169 * Adds a location for this string.
|
Chris@0
|
170 *
|
Chris@0
|
171 * @param string $type
|
Chris@0
|
172 * Location type that may be any arbitrary string. Types used in Drupal
|
Chris@0
|
173 * core are: 'javascript', 'path', 'code', 'configuration'.
|
Chris@0
|
174 * @param string $name
|
Chris@0
|
175 * Location name. Drupal path in case of online discovered translations,
|
Chris@0
|
176 * file path in case of imported strings, configuration name for strings
|
Chris@0
|
177 * that come from configuration, etc.
|
Chris@0
|
178 *
|
Chris@0
|
179 * @return $this
|
Chris@0
|
180 */
|
Chris@0
|
181 public function addLocation($type, $name);
|
Chris@0
|
182
|
Chris@0
|
183 /**
|
Chris@0
|
184 * Checks whether the string has a given location.
|
Chris@0
|
185 *
|
Chris@0
|
186 * @param string $type
|
Chris@0
|
187 * Location type.
|
Chris@0
|
188 * @param string $name
|
Chris@0
|
189 * Location name.
|
Chris@0
|
190 *
|
Chris@0
|
191 * @return bool
|
Chris@0
|
192 * TRUE if the string has a location with this type and name.
|
Chris@0
|
193 */
|
Chris@0
|
194 public function hasLocation($type, $name);
|
Chris@0
|
195
|
Chris@0
|
196 /**
|
Chris@0
|
197 * Saves string object to storage.
|
Chris@0
|
198 *
|
Chris@0
|
199 * @return $this
|
Chris@0
|
200 *
|
Chris@0
|
201 * @throws \Drupal\locale\StringStorageException
|
Chris@0
|
202 * In case of failures, an exception is thrown.
|
Chris@0
|
203 */
|
Chris@0
|
204 public function save();
|
Chris@0
|
205
|
Chris@0
|
206 /**
|
Chris@0
|
207 * Deletes string object from storage.
|
Chris@0
|
208 *
|
Chris@0
|
209 * @return $this
|
Chris@0
|
210 *
|
Chris@0
|
211 * @throws \Drupal\locale\StringStorageException
|
Chris@0
|
212 * In case of failures, an exception is thrown.
|
Chris@0
|
213 */
|
Chris@0
|
214 public function delete();
|
Chris@0
|
215
|
Chris@0
|
216 }
|