Skip to content

Commit 11cd620

Browse files
committed
🐛 Test for debug module before adding the Elasticsearch panel
✨ Give an proper id the the Elasticsearch Debug module panel so that clicking the the ES button in the debug module opens the Elasticsearch tab Fixes #12
1 parent cc26dfc commit 11cd620

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

src/Elasticsearch.php

+15-11
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
use yii\elasticsearch\DebugPanel;
3838
use yii\elasticsearch\Exception;
3939
use yii\queue\ExecEvent;
40+
use yii\debug\Module as DebugModule;
4041

4142
/**
4243
* @property services\Elasticsearch service
@@ -204,18 +205,21 @@ function () {
204205
);
205206
}
206207

207-
if (YII_DEBUG) {
208-
// Add the Elasticsearch panel to the Yii debug bar
209-
Event::on(
210-
Application::class,
211-
Application::EVENT_BEFORE_REQUEST,
212-
function () {
213-
/** @var \yii\debug\Module $debugModule */
214-
$debugModule = Craft::$app->getModule('debug');
215-
$debugModule->panels['elasticsearch'] = new DebugPanel(['module' => $debugModule]);
208+
// Add the Elasticsearch panel to the Yii debug bar
209+
Event::on(
210+
Application::class,
211+
Application::EVENT_BEFORE_REQUEST,
212+
function () {
213+
/** @var DebugModule|null $debugModule */
214+
$debugModule = Craft::$app->getModule('debug');
215+
if ($debugModule) {
216+
$debugModule->panels['elasticsearch'] = new DebugPanel([
217+
'id' => 'elasticsearch',
218+
'module' => $debugModule,
219+
]);
216220
}
217-
);
218-
}
221+
}
222+
);
219223

220224
// Register variables
221225
Event::on(

0 commit comments

Comments
 (0)