You are here

public function Number::setValue in SCSS Compiler 1.0.x

Same name in this branch
  1. 1.0.x src/Config/Schema/Number.php \Drupal\compiler_scss\Config\Schema\Number::setValue()
  2. 1.0.x src/Plugin/DataType/Number.php \Drupal\compiler_scss\Plugin\DataType\Number::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 Map::setValue

File

src/Plugin/DataType/Number.php, line 50

Class

Number
A data type used to represent a Sass number.

Namespace

Drupal\compiler_scss\Plugin\DataType

Code

public function setValue($value, $notify = TRUE) {
  if ($value instanceof IntermediateNumber) {
    $value = [
      'value' => $value
        ->value(),
      'unit' => $value
        ->unit(),
    ];
  }
  elseif (is_numeric($value)) {
    $value = [
      'value' => $value,
    ];
  }
  parent::setValue($value, $notify);
}