You are here

function generate_option_settings in Editor Button Link 8

Builds the "optionSets" configuration part.

1 call to generate_option_settings()
editor_button_link_form_editor_link_dialog_alter in ./editor_button_link.module
Implements hook_form_FORM_ID_alter().

File

./editor_button_link.module, line 142
Button link styles.

Code

function generate_option_settings($options) {
  $options_set = [];

  // Early-return when empty.
  $options = trim($options);
  if (empty($options)) {
    return $options_set;
  }
  $options = str_replace([
    "\r\n",
    "\r",
  ], "\n", $options);
  foreach (explode("\n", $options) as $option) {
    $option = trim($option);

    // Ignore empty lines in between non-empty lines.
    if (empty($option)) {
      continue;
    }

    // Parse.
    list($selector, $label) = explode('|', $option);
    $options_set[trim($selector)] = trim($label);
  }
  return $options_set;
}