You are here

public function StockLevelProcessor::setValue in Commerce Stock 8

Sets the data value.

Parameters

mixed|null $value: The value to set in the format as documented for the data type or NULL to unset the data value.

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.

Throws

\InvalidArgumentException If the value input is inappropriate.

\Drupal\Core\TypedData\Exception\ReadOnlyException If the data is read-only.

Overrides TypedData::setValue

File

modules/field/src/StockLevelProcessor.php, line 37

Class

StockLevelProcessor
Processor used by the StockLevel field.

Namespace

Drupal\commerce_stock_field

Code

public function setValue($value, $notify = TRUE) {
  if (is_null($value)) {
    return;
  }
  $this->processedLevel = $value;

  // Make sure that subsequent getter calls do not try to compute the
  // stock level again.
  $this->valueComputed = TRUE;
}