You are here

public function ContributorName::setValue in Bibliography & Citation 8

Same name and namespace in other branches
  1. 2.0.x modules/bibcite_entity/src/ContributorName.php \Drupal\bibcite_entity\ContributorName::setValue()

Overrides \Drupal\Core\TypedData\TypedData::setValue().

Parameters

array|null $values: An array of values of the field items, or NULL to unset the field.

Overrides ComputedItemListTrait::setValue

File

modules/bibcite_entity/src/ContributorName.php, line 57

Class

ContributorName
Contributor name computed field.

Namespace

Drupal\bibcite_entity

Code

public function setValue($values, $notify = TRUE) {
  parent::setValue($values, $notify);

  // Gather new string value, so we do not worry how it was set: as string
  // or as array.
  // We cannot use $this->value because it'll be newly calculated value but
  // from old name parts i.e. old value in result.
  // If the parent should be notified about the change,
  // update the contributor entity.
  if ($notify) {
    $value = isset($this->list[0]) ? $this->list[0]->value : NULL;
    $this
      ->updateContributorEntity($value);
  }
}