You are here

protected static function ScssNumber::getValue in SCSS Compiler 1.0.x

Attempt to extract the value of the supplied element.

The element's value must be a flat associative array with keys 'value' and 'unit' (int|float and string respectively), or an intermediate object of type \Drupal\compiler_scss\Type\Number.


array $element: The element for which to attempt to extract a value.

string|null $key: The key to retrieve from the element's value array or NULL to retrieve the entire array (default: NULL).

Return value

array|float|int|null|string The requested sub-value from the supplied element, or the entire element value if there was no specific key requested.

3 calls to ScssNumber::getValue()
ScssNumber::processNumber in src/Element/ScssNumber.php
Process the element before it gets rendered in the form.
ScssNumber::processUnitMultiple in src/Element/ScssNumber.php
Add a unit select element to the composite form element.
ScssNumber::validateNumber in src/Element/ScssNumber.php
Validate a number element's value on form submission.


src/Element/ScssNumber.php, line 268


A form element to represent Sass numbers with a unit.




protected static function getValue(array $element, ?string $key = NULL) {
  if (!in_array($key, [
  ], TRUE)) {
    throw new \InvalidArgumentException();
  $value = array_key_exists('#value', $element) ? $element['#value'] : [];
  if ($value instanceof IntermediateNumber) {
    $value = [
      'value' => $value
      'unit' => $value
  if (isset($key)) {
    if (is_array($value)) {
      $value = array_key_exists($key, $value) ? $value[$key] : NULL;
    else {
      $value = NULL;
  return $value;