interface StringStorageInterface (View source)

Defines the locale string storage interface.

Methods

array
getStrings(array $conditions = [], array $options = [])

Loads multiple source string objects.

getTranslations(array $conditions = [], array $options = [])

Loads multiple string translation objects.

getLocations(array $conditions = [])

Loads string location information.

findString(array $conditions)

Loads a string source object, fast query.

findTranslation(array $conditions)

Loads a string translation object, fast query.

$this
save(StringInterface $string)

Save string object to storage.

$this
delete(StringInterface $string)

Delete string from storage.

deleteStrings(array $conditions)

Deletes source strings and translations using conditions.

deleteTranslations(array $conditions)

Deletes translations using conditions.

int
countStrings()

Counts source strings.

array
countTranslations()

Counts translations.

createString(array $values = [])

Creates a source string object bound to this storage but not saved.

createTranslation(array $values = [])

Creates a string translation object bound to this storage but not saved.

Details

array getStrings(array $conditions = [], array $options = [])

Loads multiple source string objects.

Parameters

array $conditions

(optional) Array with conditions that will be used to filter the strings returned and may include any of the following elements:

  • Any simple field value indexed by field name.
  • 'translated', TRUE to get only translated strings or FALSE to get only untranslated strings. If not set it returns both translated and untranslated strings that fit the other conditions. Defaults to no conditions which means that it will load all strings.
array $options

(optional) An associative array of additional options. It may contain any of the following optional keys:

  • 'filters': Array of string filters indexed by field name.
  • 'pager limit': Use pager and set this limit value.

Return Value

array

Array of \Drupal\locale\StringInterface objects matching the conditions.

StringInterface[] getTranslations(array $conditions = [], array $options = [])

Loads multiple string translation objects.

Parameters

array $conditions

(optional) Array with conditions that will be used to filter the strings returned and may include all of the conditions defined by getStrings().

array $options

(optional) An associative array of additional options. It may contain any of the options defined by getStrings().

Return Value

StringInterface[]

Array of \Drupal\locale\StringInterface objects matching the conditions.

See also

StringStorageInterface::getStrings

StringInterface[] getLocations(array $conditions = [])

Loads string location information.

Parameters

array $conditions

(optional) Array with conditions to filter the locations that may be any of the following elements:

  • 'sid', The string identifier.
  • 'type', The location type.
  • 'name', The location name.

Return Value

StringInterface[]

Array of \Drupal\locale\StringInterface objects matching the conditions.

See also

StringStorageInterface::getStrings

SourceString|null findString(array $conditions)

Loads a string source object, fast query.

These 'fast query' methods are the ones in the critical path and their implementation must be optimized for speed, as they may run many times in a single page request.

Parameters

array $conditions

(optional) Array with conditions that will be used to filter the strings returned and may include all of the conditions defined by getStrings().

Return Value

SourceString|null

Minimal TranslationString object if found, NULL otherwise.

TranslationString|null findTranslation(array $conditions)

Loads a string translation object, fast query.

This function must only be used when actually translating strings as it will have the effect of updating the string version. For other purposes the getTranslations() method should be used instead.

Parameters

array $conditions

(optional) Array with conditions that will be used to filter the strings returned and may include all of the conditions defined by getStrings().

Return Value

TranslationString|null

Minimal TranslationString object if found, NULL otherwise.

$this save(StringInterface $string)

Save string object to storage.

Parameters

StringInterface $string

The string object.

Return Value

$this

The called object.

Exceptions

StringStorageException

$this delete(StringInterface $string)

Delete string from storage.

Parameters

StringInterface $string

The string object.

Return Value

$this

The called object.

Exceptions

StringStorageException

deleteStrings(array $conditions)

Deletes source strings and translations using conditions.

Parameters

array $conditions

Array with simple field conditions for source strings.

deleteTranslations(array $conditions)

Deletes translations using conditions.

Parameters

array $conditions

Array with simple field conditions for string translations.

int countStrings()

Counts source strings.

Return Value

int

The number of source strings contained in the storage.

array countTranslations()

Counts translations.

Return Value

array

The number of translations for each language indexed by language code.

SourceString createString(array $values = [])

Creates a source string object bound to this storage but not saved.

Parameters

array $values

(optional) Array with initial values. Defaults to empty array.

Return Value

SourceString

New source string object.

TranslationString createTranslation(array $values = [])

Creates a string translation object bound to this storage but not saved.

Parameters

array $values

(optional) Array with initial values. Defaults to empty array.

Return Value

TranslationString

New string translation object.