annotate core/modules/locale/src/StringInterface.php @ 19:fa3358dc1485 tip

Add ndrum files
author Chris Cannam
date Wed, 28 Aug 2019 13:14:47 +0100
parents af1871eacc83
children
rev   line source
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@18 75 * Serializes plural variants in one string glued by
Chris@18 76 * \Drupal\Component\Gettext\PoItem::DELIMITER.
Chris@0 77 *
Chris@0 78 * @param array $plurals
Chris@0 79 * Array of strings with plural variants.
Chris@0 80 *
Chris@0 81 * @return $this
Chris@0 82 */
Chris@0 83 public function setPlurals($plurals);
Chris@0 84
Chris@0 85 /**
Chris@0 86 * Gets the string storage.
Chris@0 87 *
Chris@0 88 * @return \Drupal\locale\StringStorageInterface
Chris@0 89 * The storage used for this string.
Chris@0 90 */
Chris@0 91 public function getStorage();
Chris@0 92
Chris@0 93 /**
Chris@0 94 * Sets the string storage.
Chris@0 95 *
Chris@0 96 * @param \Drupal\locale\StringStorageInterface $storage
Chris@0 97 * The storage to use for this string.
Chris@0 98 *
Chris@0 99 * @return $this
Chris@0 100 */
Chris@0 101 public function setStorage($storage);
Chris@0 102
Chris@0 103 /**
Chris@0 104 * Checks whether the object is not saved to storage yet.
Chris@0 105 *
Chris@0 106 * @return bool
Chris@0 107 * TRUE if the object exists in the storage, FALSE otherwise.
Chris@0 108 */
Chris@0 109 public function isNew();
Chris@0 110
Chris@0 111 /**
Chris@0 112 * Checks whether the object is a source string.
Chris@0 113 *
Chris@0 114 * @return bool
Chris@0 115 * TRUE if the object is a source string, FALSE otherwise.
Chris@0 116 */
Chris@0 117 public function isSource();
Chris@0 118
Chris@0 119 /**
Chris@0 120 * Checks whether the object is a translation string.
Chris@0 121 *
Chris@0 122 * @return bool
Chris@0 123 * TRUE if the object is a translation string, FALSE otherwise.
Chris@0 124 */
Chris@0 125 public function isTranslation();
Chris@0 126
Chris@0 127 /**
Chris@0 128 * Sets an array of values as object properties.
Chris@0 129 *
Chris@0 130 * @param array $values
Chris@0 131 * Array with values indexed by property name.
Chris@0 132 * @param bool $override
Chris@0 133 * (optional) Whether to override already set fields, defaults to TRUE.
Chris@0 134 *
Chris@0 135 * @return $this
Chris@0 136 */
Chris@0 137 public function setValues(array $values, $override = TRUE);
Chris@0 138
Chris@0 139 /**
Chris@0 140 * Gets field values that are set for given field names.
Chris@0 141 *
Chris@0 142 * @param array $fields
Chris@0 143 * Array of field names.
Chris@0 144 *
Chris@0 145 * @return array
Chris@0 146 * Array of field values indexed by field name.
Chris@0 147 */
Chris@0 148 public function getValues(array $fields);
Chris@0 149
Chris@0 150 /**
Chris@0 151 * Gets location information for this string.
Chris@0 152 *
Chris@0 153 * Locations are arbitrary pairs of type and name strings, used to store
Chris@0 154 * information about the origins of the string, like the file name it
Chris@0 155 * was found on, the path on which it was discovered, etc.
Chris@0 156 *
Chris@0 157 * A string can have any number of locations since the same string may be
Chris@0 158 * found on different places of Drupal code and configuration.
Chris@0 159 *
Chris@0 160 * @param bool $check_only
Chris@0 161 * (optional) Set to TRUE to get only new locations added during the
Chris@0 162 * current page request and not loading all existing locations.
Chris@0 163 *
Chris@0 164 * @return array
Chris@0 165 * Location ids indexed by type and name.
Chris@0 166 */
Chris@0 167 public function getLocations($check_only = FALSE);
Chris@0 168
Chris@0 169 /**
Chris@0 170 * Adds a location for this string.
Chris@0 171 *
Chris@0 172 * @param string $type
Chris@0 173 * Location type that may be any arbitrary string. Types used in Drupal
Chris@0 174 * core are: 'javascript', 'path', 'code', 'configuration'.
Chris@0 175 * @param string $name
Chris@0 176 * Location name. Drupal path in case of online discovered translations,
Chris@0 177 * file path in case of imported strings, configuration name for strings
Chris@0 178 * that come from configuration, etc.
Chris@0 179 *
Chris@0 180 * @return $this
Chris@0 181 */
Chris@0 182 public function addLocation($type, $name);
Chris@0 183
Chris@0 184 /**
Chris@0 185 * Checks whether the string has a given location.
Chris@0 186 *
Chris@0 187 * @param string $type
Chris@0 188 * Location type.
Chris@0 189 * @param string $name
Chris@0 190 * Location name.
Chris@0 191 *
Chris@0 192 * @return bool
Chris@0 193 * TRUE if the string has a location with this type and name.
Chris@0 194 */
Chris@0 195 public function hasLocation($type, $name);
Chris@0 196
Chris@0 197 /**
Chris@0 198 * Saves string object to storage.
Chris@0 199 *
Chris@0 200 * @return $this
Chris@0 201 *
Chris@0 202 * @throws \Drupal\locale\StringStorageException
Chris@0 203 * In case of failures, an exception is thrown.
Chris@0 204 */
Chris@0 205 public function save();
Chris@0 206
Chris@0 207 /**
Chris@0 208 * Deletes string object from storage.
Chris@0 209 *
Chris@0 210 * @return $this
Chris@0 211 *
Chris@0 212 * @throws \Drupal\locale\StringStorageException
Chris@0 213 * In case of failures, an exception is thrown.
Chris@0 214 */
Chris@0 215 public function delete();
Chris@0 216
Chris@0 217 }