You are here

protected static function TypogrifyFilter::settingsSerialize in Typogrify 8

Serialize array values.

There must be a better way to do this, but it looks as though trying to save an array-valued plugin setting fails. Our solution is to serialize the settings before saving and unserialize them before using.

Serialize $settings[$key] for each $key in $arraySettingsKeys.

Parameters

array &$settings: The array of plugin settings.

See also

settingsUnserialize()

1 call to TypogrifyFilter::settingsSerialize()
TypogrifyFilter::setConfiguration in src/Plugin/Filter/TypogrifyFilter.php
Sets the configuration for this plugin instance.

File

src/Plugin/Filter/TypogrifyFilter.php, line 76

Class

TypogrifyFilter
Provides a filter to restrict images to site.

Namespace

Drupal\typogrify\Plugin\Filter

Code

protected static function settingsSerialize(array &$settings) {
  foreach (static::$arraySettingsKeys as $key) {
    if (isset($settings[$key]) && is_array($settings[$key])) {
      $settings[$key] = serialize(array_filter($settings[$key]));
    }
  }
}