You are here

public static function Tags::encode in Service Container 7.2

Same name and namespace in other branches
  1. 7 lib/Drupal/Component/Utility/Tags.php \Drupal\Component\Utility\Tags::encode()

Encodes a tag string, taking care of special cases like commas and quotes.

Parameters

string $tag: A tag string.

Return value

string The encoded string.

1 call to Tags::encode()
Tags::implode in lib/Drupal/Component/Utility/Tags.php
Implodes an array of tags into a string.

File

lib/Drupal/Component/Utility/Tags.php, line 56
Contains \Drupal\Component\Utility\Tags.

Class

Tags
Defines a class that can explode and implode tags.

Namespace

Drupal\Component\Utility

Code

public static function encode($tag) {
  if (strpos($tag, ',') !== FALSE || strpos($tag, '"') !== FALSE) {
    return '"' . str_replace('"', '""', $tag) . '"';
  }
  return $tag;
}