Example #1
0
 /**
  * Initializes the search component.
  *
  * Sets the sorting query parameters
  *
  */
 public function initializeSearchComponent()
 {
     if (!empty($this->searchConfiguration['query.']['sortBy'])) {
         $this->query->addQueryParameter('sort', $this->searchConfiguration['query.']['sortBy']);
     }
     $solrGetParameters = GeneralUtility::_GET('tx_solr');
     if (!empty($this->searchConfiguration['sorting']) && !empty($solrGetParameters['sort']) && preg_match('/^([a-z0-9_]+ (asc|desc)[, ]*)*([a-z0-9_]+ (asc|desc))+$/i', $solrGetParameters['sort'])) {
         $sortHelper = GeneralUtility::makeInstance('ApacheSolrForTypo3\\Solr\\Sorting', $this->searchConfiguration['sorting.']['options.']);
         $sortField = $sortHelper->getSortFieldFromUrlParameter($solrGetParameters['sort']);
         $this->query->setSorting($sortField);
     }
 }