コード例 #1
0
ファイル: Search.php プロジェクト: romaincanon/ext-solr
 /**
  * Sends a ping to the solr server to see whether it is available.
  *
  * @return boolean Returns TRUE on successful ping.
  * @throws	Exception	Throws an exception in case ping was not successful.
  */
 public function ping()
 {
     $solrAvailable = FALSE;
     try {
         if (!$this->solr->ping()) {
             throw new Exception('Solr Server not responding.', 1237475791);
         }
         $solrAvailable = TRUE;
     } catch (Exception $e) {
         if ($GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_solr.']['logging.']['exceptions']) {
             GeneralUtility::devLog('exception while trying to ping the solr server', 'solr', 3, array($e->__toString()));
         }
     }
     return $solrAvailable;
 }
コード例 #2
0
 /**
  * Allows to provide a Solr server connection other than the one
  * initialized by the constructor.
  *
  * @param Tx_Solr_SolrService $solrConnection Solr connection
  * @throws Exception if the Solr server cannot be reached
  */
 public function setSolrConnection(Tx_Solr_SolrService $solrConnection)
 {
     if (!$solrConnection->ping()) {
         throw new Exception('Could not connect to Solr server.', 1323946472);
     }
     $this->solrConnection = $solrConnection;
 }