protected function SuggestionSearchForm::multiLinks in Autocomplete Search Suggestions 8.2
Build a renderable array of language links.
Parameters
array $languages: An array of language objects.
Return value
array An array of renderable language links.
1 call to SuggestionSearchForm::multiLinks()
- SuggestionSearchForm::buildForm in src/
Form/ SuggestionSearchForm.php - The suggestion search form.
File
- src/
Form/ SuggestionSearchForm.php, line 235
Class
- SuggestionSearchForm
- Ngram search form.
Namespace
Drupal\suggestion\FormCode
protected function multiLinks(array $languages = []) {
$langcode = $this->langMgr
->getCurrentLanguage()
->getId();
$prototype = [
'#prefix' => '<li>',
'#suffix' => '</li>',
];
$form['suggestion_multi'] = [
'#type' => 'markup',
'#markup' => '',
'#prefix' => '<ul>',
'#suffix' => '</ul>',
'#weight' => 0,
];
foreach (array_keys($languages) as $id) {
if ($id != $langcode) {
$form['suggestion_multi']["language_{$id}"] = $prototype + Link::createFromRoute($languages[$id]
->getName(), 'suggestion.search', [], [
'language' => $languages[$id],
])
->toRenderable();
}
else {
$form['suggestion_multi']["language_{$id}"] = $prototype + [
'#markup' => $languages[$id]
->getName(),
];
}
}
return $form;
}