Skip to content
Snippets Groups Projects
Commit 77cf1321 authored by Daniel Cimorra's avatar Daniel Cimorra
Browse files

feat: allow the URL of the shard to be overwritten

Refs: #3388738
parent 08092959
No related branches found
No related tags found
1 merge request!2feat: allow the URL of the shard to be overwritten
......@@ -34,11 +34,11 @@ class ShardDocument extends SolrDocument {
'#title' => $this->t('Solrconfig.xml file'),
'#description' => $this->t('The file from which the shard property will be read'),
];
$form['instance_url'] = [
'#type' => 'textfield',
'#default_value' => $this->configuration['instance_url'],
'#title' => $this->t('URL variable.'),
'#description' => $this->t('Replacement variable for the URL of the solr instance'),
$form['override_shard_url'] = [
'#type' => 'checkbox',
'#default_value' => $this->configuration['override_shard_url'],
'#title' => $this->t('Override shard URL.'),
'#description' => $this->t('If the shard URL is a substitution variable (like ${solr.instance.url}), it is necessary to overwrite it in order to prevent each of the configured instances from being inaccessible.'),
];
return $form + parent::buildConfigurationForm($form, $form_state);
......
......@@ -110,13 +110,17 @@ class ShardFieldManager extends SolrFieldManager {
return NULL;
}
protected function getInstanceUrl(IndexInterface $index) {
protected function shardIsOverriden(IndexInterface $index) {
if ($index->getDatasources()) {
return $index->getDatasource('solr_document')
->getConfiguration()['instance_url'];
$configuration = $index->getDatasource('solr_document')
->getConfiguration();
if (isset($configuration['override_shard_url'])) {
return (bool) $configuration['override_shard_url'];
}
}
return NULL;
return FALSE;
}
/**
......@@ -136,7 +140,7 @@ class ShardFieldManager extends SolrFieldManager {
$shards = $this->getShardServers($index);
$server = $index->getServerInstance();
if ($this->getInstanceUrl($index) !== NULL) {
if ($this->shardIsOverriden($index) !== FALSE) {
$config = $index->getServerInstance()->getBackend()->getConfiguration()['connector_config'];
foreach ($shards as $key => $shard) {
$parsed = parse_url($shard);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment