SolrFieldTypeController.php in Search API Multilingual Solr Search 8
File
src/Controller/SolrFieldTypeController.php
View source
<?php
namespace Drupal\search_api_solr_multilingual\Controller;
use Drupal\Core\Controller\ControllerBase;
use Drupal\search_api\ServerInterface;
use Symfony\Component\HttpFoundation\Response;
use ZipStream\Exception as ZipStreamException;
class SolrFieldTypeController extends ControllerBase {
public function listing(ServerInterface $search_api_server) {
return $this
->getListBuilder($search_api_server)
->render();
}
public function getSchemaExtraTypesXml(ServerInterface $search_api_server) {
$response = new Response();
$response
->setContent(\Drupal::service('renderer')
->render($this
->getListBuilder($search_api_server)
->getSchemaExtraTypesXml()));
return $response;
}
public function getSchemaExtraFieldsXml(ServerInterface $search_api_server) {
$response = new Response();
$response
->setContent(\Drupal::service('renderer')
->render($this
->getListBuilder($search_api_server)
->getSchemaExtraFieldsXml()));
return $response;
}
public function getConfigZip(ServerInterface $search_api_server) {
ob_clean();
try {
$zip = $this
->getListBuilder($search_api_server)
->getConfigZip();
$zip
->finish();
ob_end_flush();
exit;
} catch (ZipStreamException $e) {
watchdog_exception('search_api_solr_multilingual', $e);
$this
->messenger()
->addError($this
->t('An error occured during the creation of the config.zip. Look at the logs for details.'));
}
return [];
}
protected function getListBuilder(ServerInterface $search_api_server) {
$list_builder = $this
->entityTypeManager()
->getListBuilder('solr_field_type');
$list_builder
->setServer($search_api_server);
return $list_builder;
}
}