Ejemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function addResults(ResultSetInterface $results)
 {
     // @todo Create getter and setter methods for the search ID.
     $search_id = $results->getQuery()->getOption('search id', '');
     $request = $this->getCurrentRequest();
     if (!isset($this->results[$request])) {
         $this->results[$request] = array($search_id => $results);
     } else {
         // It's not possible to directly assign array values to an array inside of
         // a \SplObjectStorage object. So we have to first retrieve the array,
         // then add the results to it, then store it again.
         $cache = $this->results[$request];
         $cache[$search_id] = $results;
         $this->results[$request] = $cache;
     }
 }
Ejemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function postprocessSearchResults(ResultSetInterface $results)
 {
     if (!$results->getResultCount() || !($keys = $this->getKeywords($results->getQuery()))) {
         return;
     }
     $result_items = $results->getResultItems();
     if ($this->configuration['excerpt']) {
         $this->addExcerpts($result_items, $keys);
     }
     if ($this->configuration['highlight'] != 'never') {
         $highlighted_fields = $this->highlightFields($result_items, $keys);
         if ($highlighted_fields) {
             // Maybe the backend or some other processor has already set highlighted
             // field values.
             foreach ($results->getExtraData('highlighted_fields', array()) as $item_id => $old_highlighting) {
                 $highlighted_fields += array($item_id => array());
                 $highlighted_fields[$item_id] += $old_highlighting;
             }
             $results->setExtraData('highlighted_fields', $highlighted_fields);
         }
     }
 }