| 
														
															@@ -93,6 +93,8 @@ class EdlpSearchController extends ControllerBase { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     $response = new JsonResponse($this->matches); 
														 | 
														
														 | 
														
															     $response = new JsonResponse($this->matches); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     return $response; 
														 | 
														
														 | 
														
															     return $response; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    // dpm($this->matches, 'matches'); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    // 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     // return array( 
														 | 
														
														 | 
														
															     // return array( 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     //   "#markup" => "autocomplete" 
														 | 
														
														 | 
														
															     //   "#markup" => "autocomplete" 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     // ); 
														 | 
														
														 | 
														
															     // ); 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -132,32 +134,45 @@ class EdlpSearchController extends ControllerBase { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															       $query->keys($this->keys); 
														 | 
														
														 | 
														
															       $query->keys($this->keys); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     } 
														 | 
														
														 | 
														
															     } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    // select the field in which search will be performed 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    $query->setFulltextFields(array($this->field_name)); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    if(null !== $this->field_synonyms){ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+      // select the taxo field AND the synonym field in which search will be performed 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+      $query->setFulltextFields(array($this->field_name, $this->field_synonyms)); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    }else{ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+      // OR select the unique taxo field in which search will be performed 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+      $query->setFulltextFields(array($this->field_name)); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															     $result = $query->execute(); 
														 | 
														
														 | 
														
															     $result = $query->execute(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     $items = $result->getResultItems(); 
														 | 
														
														 | 
														
															     $items = $result->getResultItems(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															     $this->matches = []; 
														 | 
														
														 | 
														
															     $this->matches = []; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     foreach ($items as $item) { 
														 | 
														
														 | 
														
															     foreach ($items as $item) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+      // get the field from item 
														 | 
													
												
											
												
													
														| 
														 | 
														
															       try { 
														 | 
														
														 | 
														
															       try { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         /** @var \Drupal\Core\Entity\EntityInterface $entity */ 
														 | 
														
														 | 
														
															         /** @var \Drupal\Core\Entity\EntityInterface $entity */ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         $fields = $item->getField($this->field_name)->getValues(); 
														 | 
														
														 | 
														
															         $fields = $item->getField($this->field_name)->getValues(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															       }catch (SearchApiException $e) { 
														 | 
														
														 | 
														
															       }catch (SearchApiException $e) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        // if error on getinfg the field, skip item 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         continue; 
														 | 
														
														 | 
														
															         continue; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															       } 
														 | 
														
														 | 
														
															       } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+      // if no fields returned, skip item 
														 | 
													
												
											
												
													
														| 
														 | 
														
															       if (!$fields) { 
														 | 
														
														 | 
														
															       if (!$fields) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         continue; 
														 | 
														
														 | 
														
															         continue; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															       } 
														 | 
														
														 | 
														
															       } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+      // get field content 
														 | 
													
												
											
												
													
														| 
														 | 
														
															       $field_text = $fields[0]->getText(); 
														 | 
														
														 | 
														
															       $field_text = $fields[0]->getText(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+      // if content already in matches, skip item 
														 | 
													
												
											
												
													
														| 
														 | 
														
															       if( in_array($field_text, $this->matches) ){ 
														 | 
														
														 | 
														
															       if( in_array($field_text, $this->matches) ){ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         continue; 
														 | 
														
														 | 
														
															         continue; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															       } 
														 | 
														
														 | 
														
															       } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+      // add the item to the return list 
														 | 
													
												
											
												
													
														| 
														 | 
														
															       $this->matches[] = $field_text; 
														 | 
														
														 | 
														
															       $this->matches[] = $field_text; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+      // do not return more than 14 items 
														 | 
													
												
											
												
													
														| 
														 | 
														
															       if(count($this->matches) > 14){ 
														 | 
														
														 | 
														
															       if(count($this->matches) > 14){ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         break; 
														 | 
														
														 | 
														
															         break; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															       } 
														 | 
														
														 | 
														
															       } 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -169,8 +184,12 @@ class EdlpSearchController extends ControllerBase { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   * getRequestArgs 
														 | 
														
														 | 
														
															   * getRequestArgs 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   */ 
														 | 
														
														 | 
														
															   */ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   private function getRequestAutocompleteArgs(){ 
														 | 
														
														 | 
														
															   private function getRequestAutocompleteArgs(){ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    // args are provided by form definition with autocomplete_route_parameters 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     // dpm($this->request); 
														 | 
														
														 | 
														
															     // dpm($this->request); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     $this->field_name = $this->request->query->get('field_name'); 
														 | 
														
														 | 
														
															     $this->field_name = $this->request->query->get('field_name'); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    // if($this->request->query->get('field_synonyms')){ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+      $this->field_synonyms = $this->request->query->get('field_synonyms'); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    // } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     $this->keys = $this->request->query->get('q'); 
														 | 
														
														 | 
														
															     $this->keys = $this->request->query->get('q'); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   } 
														 | 
														
														 | 
														
															   } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 |