You are here

public function FullCalendar::convertKeyValuePairsToArray in FullCalendar 8.5

Same name and namespace in other branches
  1. 8.2 src/Plugin/fullcalendar/type/FullCalendar.php \Drupal\fullcalendar\Plugin\fullcalendar\type\FullCalendar::convertKeyValuePairsToArray()
  2. 8.4 src/Plugin/fullcalendar/type/FullCalendar.php \Drupal\fullcalendar\Plugin\fullcalendar\type\FullCalendar::convertKeyValuePairsToArray()

Split a key:value pair into array.

Parameters

string $value: A string with key:value pairs.

Return value

array Associative array of values.

1 call to FullCalendar::convertKeyValuePairsToArray()
FullCalendar::preView in src/Plugin/fullcalendar/type/FullCalendar.php

File

src/Plugin/fullcalendar/type/FullCalendar.php, line 1167

Class

FullCalendar
Plugin annotation @FullcalendarOption( id = "fullcalendar", module = "fullcalendar", js = TRUE, weight = "-20" )

Namespace

Drupal\fullcalendar\Plugin\fullcalendar\type

Code

public function convertKeyValuePairsToArray($value) {
  if (strpos($value, self::COMMA_REPLACEMENT) === FALSE) {
    $value = $this
      ->fixCommaSeparatedValues($value);
  }
  $items = explode(',', $value);
  $items = array_map('trim', $items);
  $array = [];
  foreach ($items as $item) {
    list($key, $value) = explode(':', $item);
    $array['key'] = $key;
    $array['value'] = str_replace("'", '', str_replace(self::COMMA_REPLACEMENT, ',', $value));
  }
  return $array;
}