You are here

protected function SolrFieldTypeListBuilder::generateSchemaExtraFieldsXml in Search API Multilingual Solr Search 8

2 calls to SolrFieldTypeListBuilder::generateSchemaExtraFieldsXml()
SolrFieldTypeListBuilder::getConfigZip in src/Controller/SolrFieldTypeListBuilder.php
SolrFieldTypeListBuilder::getSchemaExtraFieldsXml in src/Controller/SolrFieldTypeListBuilder.php

File

src/Controller/SolrFieldTypeListBuilder.php, line 223

Class

SolrFieldTypeListBuilder
Provides a listing of SolrFieldType.

Namespace

Drupal\search_api_solr_multilingual\Controller

Code

protected function generateSchemaExtraFieldsXml() {
  $target_solr_version = $this
    ->getBackend()
    ->getSolrConnector()
    ->getSolrVersion();
  $xml = $this
    ->getExtraFileHead($target_solr_version, 'fields');
  $indentation = '  ';
  if (version_compare($target_solr_version, '6.0.0', '>=')) {
    $indentation .= '  ';
  }

  /** @var \Drupal\search_api_solr_multilingual\SolrFieldTypeInterface $solr_field_type */
  foreach ($this
    ->load() as $solr_field_type) {
    if (!$solr_field_type
      ->isManagedSchema()) {
      foreach ($solr_field_type
        ->getDynamicFields() as $dynamic_field) {
        $xml .= $indentation . '<dynamicField ';
        foreach ($dynamic_field as $attribute => $value) {
          $xml .= $attribute . '="' . (is_bool($value) ? $value ? 'true' : 'false' : $value) . '" ';
        }
        $xml .= "/>\n";
      }
      if (version_compare($target_solr_version, '6.0.0', '>=')) {

        // On Solr 6 we're not in that "legacy mode" and inside an fields tag.
        foreach ($solr_field_type
          ->getCopyFields() as $copy_field) {
          $xml .= $indentation . '<copyField ';
          foreach ($copy_field as $attribute => $value) {
            $xml .= $attribute . '="' . (is_bool($value) ? $value ? 'true' : 'false' : $value) . '" ';
          }
          $xml .= "/>\n";
        }
      }
    }
  }
  $xml .= $this
    ->getExtraFileFoot($target_solr_version, 'fields');
  return $xml;
}