You are here

public function StringBase::getValues in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/locale/src/StringBase.php \Drupal\locale\StringBase::getValues()

Gets field values that are set for given field names.

Parameters

array $fields: Array of field names.

Return value

array Array of field values indexed by field name.

Overrides StringInterface::getValues

File

core/modules/locale/src/StringBase.php, line 141

Class

StringBase
Defines the locale string base class.

Namespace

Drupal\locale

Code

public function getValues(array $fields) {
  $values = [];
  foreach ($fields as $field) {
    if (isset($this->{$field})) {
      $values[$field] = $this->{$field};
    }
  }
  return $values;
}