/** * 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 ($this->configuration->getLoggingExceptions()) { GeneralUtility::devLog('exception while trying to ping the solr server', 'solr', 3, array($e->__toString())); } } return $solrAvailable; }
/** * The main method of the plugin * * @param string $content The plugin content * @param array $configuration The plugin configuration * @return string The content that is displayed on the website */ public function main($content, $configuration) { /** @noinspection PhpUnusedLocalVariableInspection */ $content = ''; try { $this->initialize($configuration); $this->preRender(); $actionResult = $this->performAction(); if ($this->getSearchResultSetService()->getIsSolrAvailable()) { $content = $this->render($actionResult); } else { $content = $this->renderError(); } $content = $this->postRender($content); } catch (\Exception $e) { if ($this->typoScriptConfiguration->getLoggingExceptions()) { GeneralUtility::devLog($e->getCode() . ': ' . $e->__toString(), 'solr', 3, (array) $e); } $this->initializeTemplateEngine(); $content = $this->renderException(); } return $this->baseWrap($content); }