public function SolrConnectorPluginBase::getContentFromExtractResult in Search API Solr 8.2
Same name and namespace in other branches
- 8.3 src/SolrConnector/SolrConnectorPluginBase.php \Drupal\search_api_solr\SolrConnector\SolrConnectorPluginBase::getContentFromExtractResult()
- 8 src/SolrConnector/SolrConnectorPluginBase.php \Drupal\search_api_solr\SolrConnector\SolrConnectorPluginBase::getContentFromExtractResult()
- 4.x src/SolrConnector/SolrConnectorPluginBase.php \Drupal\search_api_solr\SolrConnector\SolrConnectorPluginBase::getContentFromExtractResult()
Gets the content from an extract query result.
Parameters
\Solarium\QueryType\Extract\Result $result:
string $filepath:
Return value
string The extracted content as string.
Throws
\Drupal\search_api_solr\SearchApiSolrException
Overrides SolrConnectorInterface::getContentFromExtractResult
File
- src/
SolrConnector/ SolrConnectorPluginBase.php, line 968
Class
- SolrConnectorPluginBase
- Defines a base class for Solr connector plugins.
Namespace
Drupal\search_api_solr\SolrConnectorCode
public function getContentFromExtractResult(ExtractResult $result, $filepath) {
$response = $result
->getResponse();
$json_data = $response
->getBody();
$array_data = Json::decode($json_data);
if (isset($array_data[basename($filepath)])) {
// Solarium >= 4.1.0
return $array_data[basename($filepath)];
}
elseif (isset($array_data[$filepath])) {
// Solarium < 4.1.0
return $array_data[$filepath];
}
// In most (or every) cases when an error happens we won't reach that point,
// because a Solr exception is already pased through. Anyway, this exception
// will be thrown if the solarium library surprises us again. ;-)
throw new SearchApiSolrException('Unable to find extracted files within the Solr response body.');
}