StringBase
abstract class StringBase implements StringInterface (View source)
Defines the locale string base class.
This is the base class to be used for locale string objects and contains the common properties and methods for source and translation strings.
Properties
| int | $lid | The string identifier. |
|
| string | $locations | The string locations indexed by type. |
|
| string | $source | The source string. |
|
| string | $context | The string context. |
|
| string | $version | The string version. |
|
| protected StringStorageInterface | $storage | The locale storage this string comes from or is to be saved to. |
Methods
Constructs a new locale string object.
Gets the string unique identifier.
Sets the string unique identifier.
Gets the string version.
Sets the string version.
Splits string to work with plural values.
Sets this string using array of plural values.
Gets the string storage.
Sets an array of values as object properties.
Gets field values that are set for given field names.
Gets location information for this string.
Adds a location for this string.
Checks whether the string has a given location.
Saves string object to storage.
Deletes string object from storage.
Details
__construct(object|array $values = [])
Constructs a new locale string object.
int
getId()
Gets the string unique identifier.
$this
setId($lid)
Sets the string unique identifier.
string
getVersion()
Gets the string version.
$this
setVersion(string $version)
Sets the string version.
array
getPlurals()
Splits string to work with plural values.
$this
setPlurals(array $plurals)
Sets this string using array of plural values.
Serializes plural variants in one string glued by \Drupal\Component\Gettext\PoItem::DELIMITER.
StringStorageInterface
getStorage()
Gets the string storage.
$this
setStorage(StringStorageInterface $storage)
Sets the string storage.
$this
setValues(array $values, bool $override = TRUE)
Sets an array of values as object properties.
array
getValues(array $fields)
Gets field values that are set for given field names.
array
getLocations(bool $check_only = FALSE)
Gets location information for this string.
Locations are arbitrary pairs of type and name strings, used to store information about the origins of the string, like the file name it was found on, the path on which it was discovered, etc.
A string can have any number of locations since the same string may be found on different places of Drupal code and configuration.
$this
addLocation(string $type, string $name)
Adds a location for this string.
bool
hasLocation(string $type, string $name)
Checks whether the string has a given location.
$this
save()
Saves string object to storage.
$this
delete()
Deletes string object from storage.