From 9329d822739b6892ba1e08802923fcf13b6cd962 Mon Sep 17 00:00:00 2001 From: bkapustik <82807109+bkapustik@users.noreply.github.com> Date: Mon, 12 Feb 2024 13:00:42 +0100 Subject: [PATCH] Algolia Module Installer updated to be according to Integration standard --- .../Admin/AlgoliaAdminModule.cs | 9 +++++---- src/Kentico.Xperience.Algolia/AlgoliaSearchModule.cs | 9 ++++++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/Kentico.Xperience.Algolia/Admin/AlgoliaAdminModule.cs b/src/Kentico.Xperience.Algolia/Admin/AlgoliaAdminModule.cs index 9481eb9..c2a16d0 100644 --- a/src/Kentico.Xperience.Algolia/Admin/AlgoliaAdminModule.cs +++ b/src/Kentico.Xperience.Algolia/Admin/AlgoliaAdminModule.cs @@ -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)) { } @@ -25,15 +25,16 @@ protected override void OnInit(ModuleInitParameters parameters) base.OnInit(parameters); RegisterClientModule("kentico", "xperience-integrations-algolia"); - serviceProvider = parameters.Services; - storageService = serviceProvider.GetRequiredService(); + var services = parameters.Services; + + installer = services.GetRequiredService(); + storageService = services.GetRequiredService(); ApplicationEvents.PostStart.Execute += InitializeModule; } private void InitializeModule(object? sender, EventArgs e) { - var installer = serviceProvider.GetRequiredService(); installer.Install(); AlgoliaIndexStore.SetIndicies(storageService); diff --git a/src/Kentico.Xperience.Algolia/AlgoliaSearchModule.cs b/src/Kentico.Xperience.Algolia/AlgoliaSearchModule.cs index 042380e..15c9ea9 100644 --- a/src/Kentico.Xperience.Algolia/AlgoliaSearchModule.cs +++ b/src/Kentico.Xperience.Algolia/AlgoliaSearchModule.cs @@ -35,9 +35,12 @@ protected override void OnInit(ModuleInitParameters parameters) { base.OnInit(); - algoliaTaskLogger = Service.Resolve(); - appSettingsService = Service.Resolve(); - conversionService = Service.Resolve(); + var services = parameters.Services; + + algoliaTaskLogger = services.GetRequiredService(); + appSettingsService = services.GetRequiredService(); + conversionService = services.GetRequiredService(); + WebPageEvents.Publish.Execute += HandleEvent; WebPageEvents.Delete.Execute += HandleEvent;