You are here

public function LinkIconManager::extractAllowedValues in Link Icon 8

Returns extracted allowed title values.

Parameters

string $values: The link title allowed values.

bool $is_tooltip: If it is for tooltip title or regular link text.

Return value

array An array of allowed title values.

Overrides LinkIconManagerInterface::extractAllowedValues

File

src/LinkIconManager.php, line 56

Class

LinkIconManager
Provides LinkIconManager service.

Namespace

Drupal\linkicon

Code

public function extractAllowedValues($values, $is_tooltip = FALSE) {
  $allowed_values = [];
  if ($values) {
    $list = explode("\n", strip_tags($values));
    foreach ($list as $value) {
      if (strpos($value, "|") !== FALSE) {
        list($key, $title, $tooltip) = array_pad(array_map('trim', explode("|", $value, 3)), 3, NULL);
        $allowed_values[$key] = $is_tooltip && !empty($tooltip) ? $tooltip : $title;
      }
      else {
        $allowed_values[$value] = $value;
      }
    }
  }
  return $allowed_values;
}