function _bootstrap_layouts_parse_attributes in Bootstrap Layouts 8.4
Same name and namespace in other branches
- 8.5 bootstrap_layouts.module \_bootstrap_layouts_parse_attributes()
Parses an attribute string saved in the UI.
Parameters
string $string: The attribute string to parse.
array $tokens: An associative array of token data to use.
Return value
array A parsed attributes array.
1 call to _bootstrap_layouts_parse_attributes()
- _bootstrap_layouts_preprocess_layout in ./
bootstrap_layouts.module - Internal preprocess callback.
File
- ./
bootstrap_layouts.module, line 47 - Contains bootstrap_layouts.module.
Code
function _bootstrap_layouts_parse_attributes($string = NULL, array $tokens = []) {
static $token;
if (!isset($token)) {
/** @var \Drupal\Core\Utility\Token $token */
$token = \Drupal::service('token');
}
$attributes = [];
if (!empty($string)) {
$parts = explode(',', $string);
foreach ($parts as $attribute) {
if (strpos($attribute, '|') !== FALSE) {
list($key, $value) = explode('|', $token
->replace($attribute, $tokens, [
'clear' => TRUE,
]));
$attributes[$key] = $value;
}
}
}
return $attributes;
}