Skip to content

Commit 0962051

Browse files
author
Mikolaj Misiurewicz
committed
fix(debug): Removed internal constant present in new solr Symfony Debug Panel. Added optional configuration for the value.
1 parent d794e83 commit 0962051

File tree

4 files changed

+40
-2
lines changed

4 files changed

+40
-2
lines changed

src/DataCollector/SolrDataCollector.php

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
namespace Markup\NeedleBundle\DataCollector;
55

66
use Psr\Log\LoggerInterface;
7+
use Psr\Log\NullLogger;
78
use Solarium\Core\Client\Endpoint as SolariumEndpoint;
89
use Solarium\Core\Client\Request as SolariumRequest;
910
use Solarium\Core\Client\Response as SolariumResponse;
@@ -56,11 +57,31 @@ class SolrDataCollector extends SolariumPlugin implements DataCollectorInterface
5657
*/
5758
protected $logger;
5859

60+
/**
61+
* @var string
62+
*/
63+
protected $solrDashboardDomain;
64+
65+
/**
66+
* SolrDataCollector constructor.
67+
* @param array|null $options
68+
*/
69+
public function __construct($options = null)
70+
{
71+
$this->logger = new NullLogger();
72+
parent::__construct($options);
73+
}
74+
5975
public function setLogger(LoggerInterface $logger): void
6076
{
6177
$this->logger = $logger;
6278
}
6379

80+
public function setSolrDashboardDomain(string $solrDashboardDomain): void
81+
{
82+
$this->solrDashboardDomain = $solrDashboardDomain;
83+
}
84+
6485
/**
6586
* Parse the solr queries logged and save for use in debugging activities.
6687
*
@@ -173,7 +194,7 @@ protected function log(
173194
): void {
174195
$requestUri = str_replace(
175196
'://localhost:',
176-
'://gant-dev-solr.usemarkup.com:',
197+
sprintf('://%s:', $this->solrDashboardDomain),
177198
$endpoint->getBaseUri().$request->getUri()
178199
);
179200

src/DependencyInjection/Configuration.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,20 @@ public function getConfigTreeBuilder()
145145
->end()
146146
->end()
147147
->end()
148+
->arrayNode('solr')
149+
->addDefaultsIfNotSet()
150+
->children()
151+
->arrayNode('debug')
152+
->addDefaultsIfNotSet()
153+
->children()
154+
->scalarNode('solr_dashboard_domain')
155+
->info('Used in Symfony Profiler to redirect to solr dashboard from the solr debug panel')
156+
->defaultValue('localhost')
157+
->end()
158+
->end()
159+
->end()
160+
->end()
161+
->end()
148162
->end();
149163

150164
return $treeBuilder;

src/DependencyInjection/MarkupNeedleExtension.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,5 +269,8 @@ private function loadBackendSpecificServices(array $config, ContainerBuilder $co
269269

270270
$corpusIndexProvider = $container->getDefinition(CorpusIndexProvider::class);
271271
$corpusIndexProvider->setArgument('$prefix', $config['elasticsearch']['index_prefix']);
272+
273+
$definition = $container->findDefinition('solarium.data_collector');
274+
$definition->addMethodCall('setSolrDashboardDomain', [$config['solr']['debug']['solr_dashboard_domain']]);
272275
}
273276
}

src/Resources/config/services.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,4 +170,4 @@ services:
170170
- name: 'monolog.logger'
171171
channel: 'solr'
172172
calls:
173-
- [ 'setLogger', [ '@logger' ] ]
173+
- [ 'setLogger', [ '@?logger' ] ]

0 commit comments

Comments
 (0)