protected function WebformElementController::getMatchesFromOptionsRecursive in Webform 6.x
Same name and namespace in other branches
- 8.5 src/Controller/WebformElementController.php \Drupal\webform\Controller\WebformElementController::getMatchesFromOptionsRecursive()
Get matches from options recursive.
Parameters
string $q: String to filter option's label by.
array $options: An associative array of webform options.
array $matches: An associative array of autocomplete matches.
string $operator: Match operator either CONTAINS or STARTS_WITH.
1 call to WebformElementController::getMatchesFromOptionsRecursive()
- WebformElementController::getMatchesFromOptions in src/
Controller/ WebformElementController.php - Get matches from options.
File
- src/
Controller/ WebformElementController.php, line 196
Class
- WebformElementController
- Provides route responses for Webform elements.
Namespace
Drupal\webform\ControllerCode
protected function getMatchesFromOptionsRecursive($q, array $options, array &$matches, $operator = 'CONTAINS') {
foreach ($options as $label) {
if (is_array($label)) {
$this
->getMatchesFromOptionsRecursive($q, $label, $matches, $operator);
continue;
}
// Cast TranslatableMarkup to string.
$label = (string) $label;
if ($operator === 'STARTS_WITH' && stripos($label, $q) === 0) {
$matches[$label] = [
'value' => $label,
'label' => $label,
];
}
elseif (stripos($label, $q) !== FALSE) {
$matches[$label] = [
'value' => $label,
'label' => $label,
];
}
}
}