public function SolrConfigSetController::streamConfigZip in Search API Solr 4.x
Same name and namespace in other branches
- 8.3 src/Controller/SolrConfigSetController.php \Drupal\search_api_solr\Controller\SolrConfigSetController::streamConfigZip()
Streams a zip archive containing a complete Solr configuration.
Parameters
\Drupal\search_api\ServerInterface $search_api_server: The Search API server entity.
Return value
\Symfony\Component\HttpFoundation\Response The HTTP response object.
Throws
\Drupal\search_api\SearchApiException
1 string reference to 'SolrConfigSetController::streamConfigZip'
File
- src/
Controller/ SolrConfigSetController.php, line 394
Class
- SolrConfigSetController
- Provides different listings of SolrFieldType.
Namespace
Drupal\search_api_solr\ControllerCode
public function streamConfigZip(ServerInterface $search_api_server) : Response {
$this
->setServer($search_api_server);
try {
$archive_options = new Archive();
$archive_options
->setSendHttpHeaders(TRUE);
@ob_clean();
// If you are using nginx as a webserver, it will try to buffer the
// response. We have to disable this with a custom header.
// @see https://github.com/maennchen/ZipStream-PHP/wiki/nginx
header('X-Accel-Buffering: no');
$zip = $this
->getConfigZip($archive_options);
$zip
->finish();
@ob_end_flush();
exit;
} catch (SearchApiSolrConflictingEntitiesException $e) {
$this
->messenger()
->addError($this
->t('Some enabled parts of the configuration conflict with others: @conflicts', [
'@conflicts' => new FormattableMarkup($e, []),
]));
} catch (\Exception $e) {
watchdog_exception('search_api', $e);
$this
->messenger()
->addError($this
->t('An error occurred during the creation of the config.zip. Look at the logs for details.'));
}
return new RedirectResponse($search_api_server
->toUrl('canonical')
->toString());
}