Skip to content

Commit

Permalink
Add message if sync settings fails
Browse files Browse the repository at this point in the history
  • Loading branch information
wilr committed Aug 2, 2021
1 parent 609f508 commit 564cfdb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/Service/AlgoliaService.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,12 @@ public function environmentizeIndex($indexName)
*
* This runs automatically on dev/build operations.
*/
public function syncSettings()
public function syncSettings(): bool
{
$config = $this->indexes;

if (!$config) {
return;
return false;
}

foreach ($config as $index => $data) {
Expand Down Expand Up @@ -177,9 +177,14 @@ function ($replica) {
if (Director::isDev()) {
throw $e;
}

return false;
}
}
}
}


return true;
}
}
7 changes: 6 additions & 1 deletion src/Tasks/AlgoliaConfigure.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ class AlgoliaConfigure extends BuildTask
public function run($request)
{
$service = Injector::inst()->get(AlgoliaService::class);
$service->syncSettings();

if ($service->syncSettings()) {
echo 'Success.' . PHP_EOL;
} else {
echo 'An error occurred while syncing the settings. Please check your error logs.'. PHP_EOL;
}

echo 'Done.';
}
Expand Down

0 comments on commit 564cfdb

Please sign in to comment.