You are here

public function Data::ensureStringKey in Translation Management Tool 8

Converts keys array to string key.

There are three conventions for data keys in use. This function accepts each of it and ensures a string key.

Parameters

array|string $key: The key can be either be an array containing the keys of a nested array hierarchy path or a string.

string $delimiter: Delimiter to be use in the keys string. Default is ']['.

Return value

string Keys string.

File

src/Data.php, line 183

Class

Data
All data-related functions.

Namespace

Drupal\tmgmt

Code

public function ensureStringKey($key, $delimiter = Data::TMGMT_ARRAY_DELIMITER) {
  if (is_array($key)) {
    $key = implode($delimiter, $key);
  }
  return $key;
}