You are here

public function SlickFormBase::typecastOptionset in Slick Carousel 8

Returns the typecast values.

Parameters

array $settings: An array of Optionset settings.

1 call to SlickFormBase::typecastOptionset()
SlickFormBase::submitForm in slick_ui/src/Form/SlickFormBase.php
This is the default entity object builder function. It is called before any other submit handler to build the new entity object to be used by the following submit handlers. At this point of the form workflow the entity is validated and the form state…

File

slick_ui/src/Form/SlickFormBase.php, line 289

Class

SlickFormBase
Provides base form for a slick instance configuration form.

Namespace

Drupal\slick_ui\Form

Code

public function typecastOptionset(array &$settings = []) {
  if (empty($settings)) {
    return;
  }
  $defaults = Slick::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 == 'edgeFriction') {
        $type = $settings[$name] == '1' ? 'integer' : 'float';
      }
      settype($settings[$name], $type);
    }
  }
}