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['subscribers']) || $values['subscribers'] == NULL) { $values['subscribers'] = 0; } } parent::setValue($values, $notify); // TODO: Change the autogenerated stub }
/** * {@inheritdoc} */ public function setValue($values, $notify = TRUE) { if (isset($values) && !is_array($values)) { // If either a scalar or an object was passed as the value for the item, // assign it to the 'entity' property since that works for both cases. $this->set('entity', $values, $notify); } else { parent::setValue($values, FALSE); // Support setting the field item with only one property, but make sure // values stay in sync if only property is passed. // NULL is a valid value, so we use array_key_exists(). if (is_array($values) && array_key_exists('target_id', $values) && !isset($values['entity'])) { $this->onChange('target_id', FALSE); } elseif (is_array($values) && array_key_exists('target_revision_id', $values) && !isset($values['entity'])) { $this->onChange('target_revision_id', FALSE); } elseif (is_array($values) && !array_key_exists('target_id', $values) && !array_key_exists('target_revision_id', $values) && isset($values['entity'])) { $this->onChange('entity', FALSE); } elseif (is_array($values) && array_key_exists('target_id', $values) && isset($values['entity'])) { // If both properties are passed, verify the passed values match. The // only exception we allow is when we have a new entity: in this case // its actual id and target_id will be different, due to the new entity // marker. $entity_id = $this->get('entity')->getTargetIdentifier(); // If the entity has been saved and we're trying to set both the // target_id and the entity values with a non-null target ID, then the // value for target_id should match the ID of the entity value. if (!$this->entity->isNew() && $values['target_id'] !== NULL && $entity_id !== $values['target_id']) { throw new \InvalidArgumentException('The target id and entity passed to the entity reference item do not match.'); } } // Notify the parent if necessary. if ($notify && $this->getParent()) { $this->getParent()->onChange($this->getName()); } } }
/** * {@inheritdoc} */ public function setValue($values, $notify = TRUE) { parent::setValue($values, FALSE); }