public function Data::ensureArrayKey

Converts string keys to array keys.

There are three conventions for data keys in use. This function accepts each of it an ensures a array of keys.

Parameters

array|string $key: The key can be either be an array containing the keys of a nested array hierarchy path or a string with '][' or '|' as delimiter.

Return value

array Array of keys.

File

src/Data.php, line 157

Class

Data
All data-related functions.

Namespace

Drupal\tmgmt

Code

public function ensureArrayKey($key) {
  if (empty($key)) {
    return array();
  }
  if (!is_array($key)) {
    if (strstr($key, '|')) {
      $key = str_replace('|', static::TMGMT_ARRAY_DELIMITER, $key);
    }
    $key = explode(static::TMGMT_ARRAY_DELIMITER, $key);
  }
  return $key;
}