public static function Pattern::ensureVariant in UI Patterns 8
Make sure that we never pass through a value that is not a string.
This would prevent accidental assignments of a render array as variant which would break hook_ui_patterns_suggestions_alter().
Parameters
array $element: Render array.
Return value
array Render array.
File
- src/
Element/ Pattern.php, line 115
Class
- Pattern
- Renders a pattern element.
Namespace
Drupal\ui_patterns\ElementCode
public static function ensureVariant(array $element) {
if (!isset($element['#variant']) || !is_string($element['#variant'])) {
$element['#variant'] = '';
}
return $element;
}