You are here

public static function ScssNumber::getAllowedUnits in SCSS Compiler 1.0.x

Get an associative array of allowed unit options, keyed by unit name.

Parameters

int|null $type: The type(s) of unit to retrieve. See the contsants in this class for all possible unit types. If null, all types are included (default: NULL).

Return value

\Drupal\Core\StringTranslation\TranslatableMarkup[string] An associative array of allowed unit options, keyed by unit name.

2 calls to ScssNumber::getAllowedUnits()
ScssNumber::getUnitOptions in src/Element/ScssNumber.php
Get an associative array of unit options for the supplied element.
ScssNumber::validateNumber in src/Element/ScssNumber.php
Validate a number element's value on form submission.

File

src/Element/ScssNumber.php, line 166

Class

ScssNumber
A form element to represent Sass numbers with a unit.

Namespace

Drupal\compiler_scss\Element

Code

public static function getAllowedUnits($type = NULL) {
  $groups = array_keys(self::$units);
  $type = is_int($type) ? $type : self::UNIT_ALL;
  if (empty(self::$units)) {
    self::initializeUnits();
  }
  $result = array_keys(self::$units);
  $result = array_reduce($result, function ($units, $group) use ($type) {
    return $units + (($type & $group) > 0 ? self::$units[$group] : []);
  }, []);
  return $result;
}