Skip to content

Commit

Permalink
Algolia Module Installer updated to be according to Integration standard
Browse files Browse the repository at this point in the history
  • Loading branch information
bkapustik committed Feb 12, 2024
1 parent c15a155 commit 9329d82
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
9 changes: 5 additions & 4 deletions src/Kentico.Xperience.Algolia/Admin/AlgoliaAdminModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace Kentico.Xperience.Algolia.Admin;
internal class AlgoliaAdminModule : AdminModule
{
private IAlgoliaConfigurationStorageService storageService = null!;
private IServiceProvider serviceProvider = null!;
private AlgoliaModuleInstaller installer = null!;

public AlgoliaAdminModule() : base(nameof(AlgoliaAdminModule)) { }

Expand All @@ -25,15 +25,16 @@ protected override void OnInit(ModuleInitParameters parameters)
base.OnInit(parameters);
RegisterClientModule("kentico", "xperience-integrations-algolia");

serviceProvider = parameters.Services;
storageService = serviceProvider.GetRequiredService<IAlgoliaConfigurationStorageService>();
var services = parameters.Services;

installer = services.GetRequiredService<AlgoliaModuleInstaller>();
storageService = services.GetRequiredService<IAlgoliaConfigurationStorageService>();

ApplicationEvents.PostStart.Execute += InitializeModule;
}

private void InitializeModule(object? sender, EventArgs e)
{
var installer = serviceProvider.GetRequiredService<AlgoliaModuleInstaller>();
installer.Install();

AlgoliaIndexStore.SetIndicies(storageService);
Expand Down
9 changes: 6 additions & 3 deletions src/Kentico.Xperience.Algolia/AlgoliaSearchModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,12 @@ protected override void OnInit(ModuleInitParameters parameters)
{
base.OnInit();

algoliaTaskLogger = Service.Resolve<IAlgoliaTaskLogger>();
appSettingsService = Service.Resolve<IAppSettingsService>();
conversionService = Service.Resolve<IConversionService>();
var services = parameters.Services;

algoliaTaskLogger = services.GetRequiredService<IAlgoliaTaskLogger>();
appSettingsService = services.GetRequiredService<IAppSettingsService>();
conversionService = services.GetRequiredService<IConversionService>();


WebPageEvents.Publish.Execute += HandleEvent;
WebPageEvents.Delete.Execute += HandleEvent;
Expand Down

0 comments on commit 9329d82

Please sign in to comment.