You are here

public function FullCalendar::fixCommaSeparatedValues in FullCalendar 8.4

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

Replace commas in quoted strings with _COMMA_.

This is to allow us split comma-separated values into arrays later.

Parameters

string $value: The comma-separates value.

Return value

string|string[] The string with any commas "," between quotes replaced with _COMMA_.

2 calls to FullCalendar::fixCommaSeparatedValues()
FullCalendar::convertKeyValuePairsToArray in src/Plugin/fullcalendar/type/FullCalendar.php
Split a key:value pair into array.
FullCalendar::preView in src/Plugin/fullcalendar/type/FullCalendar.php

File

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

Class

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

Namespace

Drupal\fullcalendar\Plugin\fullcalendar\type

Code

public function fixCommaSeparatedValues($value) {

  // Match and replace "," commas between single quotes.
  preg_match_all("/('[^',]+),([^']+')/", $value, $matches);
  if ($matches) {
    foreach ($matches[0] as $match) {
      $_match = str_replace(',', self::COMMA_REPLACEMENT, $match);
      $value = str_replace($match, $_match, $value);
    }
  }
  return $value;
}