search form : limit autocomplete by current language

This commit is contained in:
2018-05-15 15:27:56 +02:00
parent 49c7906e11
commit dc8a77b761
2 changed files with 5 additions and 2 deletions
@@ -35,7 +35,6 @@ class CorpusController extends ControllerBase {
$current_langcode = \Drupal::languageManager()->getCurrentLanguage()->getId(); $current_langcode = \Drupal::languageManager()->getCurrentLanguage()->getId();
$config = \Drupal::config('system.site'); $config = \Drupal::config('system.site');
$query = \Drupal::entityQuery('node') $query = \Drupal::entityQuery('node')
@@ -138,6 +138,9 @@ class EdlpSearchController extends ControllerBase {
->createInstance('direct'); ->createInstance('direct');
$query->setParseMode($parse_mode); $query->setParseMode($parse_mode);
$current_langcode = \Drupal::languageManager()->getCurrentLanguage()->getId();
$query->setLanguages(array($current_langcode));
// $query->range(0, 20); // $query->range(0, 20);
// workflow // workflow
@@ -163,7 +166,7 @@ class EdlpSearchController extends ControllerBase {
$result = $query->execute(); $result = $query->execute();
$items = $result->getResultItems(); $items = $result->getResultItems();
// dpm($items);
$this->matches = []; $this->matches = [];
foreach ($items as $item) { foreach ($items as $item) {
// get the field from item // get the field from item
@@ -179,6 +182,7 @@ class EdlpSearchController extends ControllerBase {
continue; continue;
} }
// dpm($fields);
// get field content // get field content
$field_text = $fields[0]->getText(); $field_text = $fields[0]->getText();