You are here

public function ContributorName::setValue in Bibliography & Citation 2.0.x

Same name and namespace in other branches
  1. 8 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.

bool $notify: (optional) Whether to notify the parent object of the change. Defaults to TRUE.

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);
  }
}