You are here

protected function ImageZoomFormatter::settingsToArray in Image Zoom 8.2

Convert a settings string to an array.

2 calls to ImageZoomFormatter::settingsToArray()
ImageZoomFormatter::viewElements in src/Plugin/Field/FieldFormatter/ImageZoomFormatter.php
Builds a renderable array for a field value.
ImageZoomGalleryFormatter::viewElements in modules/imagezoom_gallery/src/Plugin/Field/FieldFormatter/ImageZoomGalleryFormatter.php
Builds a renderable array for a field value.

File

src/Plugin/Field/FieldFormatter/ImageZoomFormatter.php, line 261

Class

ImageZoomFormatter
Image Zoom field formatter for Image fields.

Namespace

Drupal\imagezoom\Plugin\Field\FieldFormatter

Code

protected function settingsToArray($string) {
  $settings = [];
  if (!empty($string)) {
    $array = explode("\n", $string);
    foreach ($array as $option) {
      $parts = explode(':', $option);
      if (count($parts) == 2) {
        $key = trim($parts[0]);
        $value = trim($parts[1]);
        $settings[$key] = $value;
      }
    }
  }
  return $settings;
}