public function CommandHelper::getServerConfigCommand in Search API Solr 8.2
Gets the config far a Solr search server.
Parameters
string $server_id: The ID of the server.
string $file_name: The file name of the config zip that should be created.
string $solr_version: The targeted Solr version.
Throws
\Drupal\search_api\SearchApiException
File
- src/
Utility/ CommandHelper.php, line 57
Class
- CommandHelper
- Provides functionality to be used by CLI tools.
Namespace
Drupal\search_api_solr\UtilityCode
public function getServerConfigCommand($server_id, $file_name, $solr_version = NULL) {
/** @var \Drupal\search_api_solr\Controller\SolrFieldTypeListBuilder $list_builder */
$list_builder = $this->entityTypeManager
->getListBuilder('solr_field_type');
$server = Server::load($server_id);
if ($solr_version) {
$config = $server
->getBackendConfig();
// Temporarily switch the Solr version but don't save!
$config['connector_config']['solr_version'] = $solr_version;
$server
->setBackendConfig($config);
}
$list_builder
->setServer($server);
@ob_end_clean();
ob_start();
$zip = $list_builder
->getConfigZip();
$zip
->finish();
file_put_contents($file_name, ob_get_clean());
}