You are here

public static function ElevateZoomPlus::typecast in ElevateZoom Plus 7

Returns the typecast values.

Parameters

array $settings: An array of Optionset settings.

Overrides SlickBase::typecast

File

src/Entity/ElevateZoomPlus.php, line 47

Class

ElevateZoomPlus
Defines the ElevateZoomPlus configuration entity.

Namespace

Drupal\elevatezoomplus\Entity

Code

public static function typecast(array &$settings = []) {
  if (empty($settings)) {
    return;
  }
  $defaults = self::defaultSettings();
  foreach ($defaults as $name => $value) {
    if (isset($settings[$name])) {

      // Seems double is ignored, and causes a missing schema, unlike float.
      $type = gettype($defaults[$name]);
      $type = $type == 'double' ? 'float' : $type;

      // Change float to integer if value is no longer float.
      if ($name == 'lensOpacity' || $name == 'tintOpacity') {
        $type = $settings[$name] == '0' || $settings[$name] == '1' ? 'integer' : 'float';
      }
      settype($settings[$name], $type);
    }
  }
}