You are here

public function IssueItem::setValue in Simplenews 3.x

Same name and namespace in other branches
  1. 8.2 src/Plugin/Field/FieldType/IssueItem.php \Drupal\simplenews\Plugin\Field\FieldType\IssueItem::setValue()
  2. 8 src/Plugin/Field/FieldType/IssueItem.php \Drupal\simplenews\Plugin\Field\FieldType\IssueItem::setValue()

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

Parameters

array|null $values: An array of property values.

bool $notify: (optional) Whether to notify the parent object of the change. Defaults to TRUE. If a property is updated from a parent object, set it to FALSE to avoid being notified again.

Overrides EntityReferenceItem::setValue

File

src/Plugin/Field/FieldType/IssueItem.php, line 118

Class

IssueItem
Defines the 'issue' entity field type (extended entity_reference).

Namespace

Drupal\simplenews\Plugin\Field\FieldType

Code

public function setValue($values, $notify = TRUE) {
  if (count($values) == 1 && isset($values['target_id'])) {
    $values = array_merge($this->values, $values);
    if (!isset($values['handler']) || $values['handler'] == NULL) {
      $values['handler'] = 'simplenews_all';
    }
    if (!isset($values['status']) || $values['status'] == NULL) {
      $values['status'] = 0;
    }
    if (!isset($values['sent_count']) || $values['sent_count'] == NULL) {
      $values['sent_count'] = 0;
    }
    if (!isset($values['error_count']) || $values['error_count'] == NULL) {
      $values['error_count'] = 0;
    }
    if (!isset($values['subscribers']) || $values['subscribers'] == NULL) {
      $values['subscribers'] = 0;
    }
  }
  parent::setValue($values, $notify);
}