You are here

public function StringBase::setValues in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/locale/src/StringBase.php \Drupal\locale\StringBase::setValues()
  2. 10 core/modules/locale/src/StringBase.php \Drupal\locale\StringBase::setValues()

Sets an array of values as object properties.

Parameters

array $values: Array with values indexed by property name.

bool $override: (optional) Whether to override already set fields, defaults to TRUE.

Return value

$this

Overrides StringInterface::setValues

1 call to StringBase::setValues()
StringBase::__construct in core/modules/locale/src/StringBase.php
Constructs a new locale string object.

File

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

Class

StringBase
Defines the locale string base class.

Namespace

Drupal\locale

Code

public function setValues(array $values, $override = TRUE) {
  foreach ($values as $key => $value) {
    if (property_exists($this, $key) && ($override || !isset($this->{$key}))) {
      $this->{$key} = $value;
    }
  }
  return $this;
}