You are here

public function SolrConfigSetController::getConfigZip in Search API Solr 4.x

Same name and namespace in other branches
  1. 8.3 src/Controller/SolrConfigSetController.php \Drupal\search_api_solr\Controller\SolrConfigSetController::getConfigZip()

Returns a ZipStream of all configuration files.

Parameters

\ZipStream\Option\Archive $archive_options: Archive options.

Return value

\ZipStream\ZipStream The ZipStream that contains all configuration files.

Throws

\Drupal\search_api\SearchApiException

\ZipStream\Exception\FileNotFoundException

\ZipStream\Exception\FileNotReadableException

1 call to SolrConfigSetController::getConfigZip()
SolrConfigSetController::streamConfigZip in src/Controller/SolrConfigSetController.php
Streams a zip archive containing a complete Solr configuration.

File

src/Controller/SolrConfigSetController.php, line 362

Class

SolrConfigSetController
Provides different listings of SolrFieldType.

Namespace

Drupal\search_api_solr\Controller

Code

public function getConfigZip(Archive $archive_options) : ZipStream {

  /** @var \Drupal\search_api_solr\SolrBackendInterface $backend */
  $backend = $this
    ->getBackend();
  $connector = $backend
    ->getSolrConnector();
  $solr_branch = $connector
    ->getSolrBranch($this->assumedMinimumVersion);
  $lucene_match_version = $connector
    ->getLuceneMatchVersion($this->assumedMinimumVersion ?: '');
  $zip = new ZipStream('solr_' . $solr_branch . '_config.zip', $archive_options);
  $files = $this
    ->getConfigFiles();
  foreach ($files as $name => $content) {
    $zip
      ->addFile($name, $content);
  }
  $connector
    ->alterConfigZip($zip, $lucene_match_version, $this->serverId);
  $this
    ->moduleHandler()
    ->alter('search_api_solr_config_zip', $zip, $lucene_match_version, $this->serverId);
  return $zip;
}