Skip to content

Commit aa746c9

Browse files
committed
Updated the base engine class
Signed-off-by: Jan Henckens <jan@henckens.be>
1 parent ab3774d commit aa746c9

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

src/engines/Engine.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ abstract class Engine
1212
/** @var ScoutIndex */
1313
public $scoutIndex;
1414

15-
abstract public function __construct(ScoutIndex $scoutIndex, SearchClient $algolia);
15+
abstract public function __construct(ScoutIndex $scoutIndex, ?int $siteId = null);
1616

1717
abstract public function update($models);
1818

src/models/Settings.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,26 @@ public function getApplicationId(?int $siteId = null): string
125125
{
126126
$siteHandle = $siteId ? Craft::$app->getSites()->getSiteById($siteId)->handle : null;
127127
$value = ConfigHelper::localizedValue($this->application_id, $siteHandle);
128-
return App::parseEnv($value);
128+
$parsedValue = App::parseEnv($value);
129+
130+
if (empty($parsedValue)) {
131+
throw new Exception("Scout application_id is empty for site " . ($siteHandle ?: 'default') . " (siteId: $siteId). Check your Scout plugin settings.");
132+
}
133+
134+
return $parsedValue;
129135
}
130136

131137
public function getAdminApiKey(?int $siteId = null): string
132138
{
133139
$siteHandle = $siteId ? Craft::$app->getSites()->getSiteById($siteId)->handle : null;
134140
$value = ConfigHelper::localizedValue($this->admin_api_key, $siteHandle);
135-
return App::parseEnv($value);
141+
$parsedValue = App::parseEnv($value);
142+
143+
if (empty($parsedValue)) {
144+
throw new Exception("Scout admin_api_key is empty for site " . ($siteHandle ?: 'default') . " (siteId: $siteId). Check your Scout plugin settings.");
145+
}
146+
147+
return $parsedValue;
136148
}
137149

138150
public function getSearchApiKey(?int $siteId = null): string

0 commit comments

Comments
 (0)