Split config and index creator to allow to override only config not whole index creator

This commit is contained in:
arkadiuszbiel
2019-10-04 16:41:29 +02:00
parent 3be2a98bd3
commit c0fa66799f
5 changed files with 55 additions and 21 deletions

View File

@@ -29,6 +29,7 @@ namespace Umbraco.Web.Search
composition.Register<MediaIndexPopulator>(Lifetime.Singleton);
composition.Register<IndexRebuilder>(Lifetime.Singleton);
composition.RegisterUnique<IUmbracoIndexConfig, UmbracoUmbracoIndexConfig>();
composition.RegisterUnique<IUmbracoIndexesCreator, UmbracoIndexesCreator>();
composition.RegisterUnique<IPublishedContentValueSetBuilder>(factory =>
new ContentValueSetBuilder(

View File

@@ -19,18 +19,20 @@ namespace Umbraco.Web.Search
public UmbracoIndexesCreator(IProfilingLogger profilingLogger,
ILocalizationService languageService,
IPublicAccessService publicAccessService,
IMemberService memberService)
IMemberService memberService, IUmbracoIndexConfig umbracoIndexConfig)
{
ProfilingLogger = profilingLogger ?? throw new System.ArgumentNullException(nameof(profilingLogger));
LanguageService = languageService ?? throw new System.ArgumentNullException(nameof(languageService));
PublicAccessService = publicAccessService ?? throw new System.ArgumentNullException(nameof(publicAccessService));
MemberService = memberService ?? throw new System.ArgumentNullException(nameof(memberService));
UmbracoIndexConfig = umbracoIndexConfig;
}
protected IProfilingLogger ProfilingLogger { get; }
protected ILocalizationService LanguageService { get; }
protected IPublicAccessService PublicAccessService { get; }
protected IMemberService MemberService { get; }
protected IUmbracoIndexConfig UmbracoIndexConfig { get; }
/// <summary>
/// Creates the Umbraco indexes
@@ -55,7 +57,7 @@ namespace Umbraco.Web.Search
new CultureInvariantWhitespaceAnalyzer(),
ProfilingLogger,
LanguageService,
GetContentValueSetValidator());
UmbracoIndexConfig.GetContentValueSetValidator());
return index;
}
@@ -68,7 +70,7 @@ namespace Umbraco.Web.Search
new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_30),
ProfilingLogger,
LanguageService,
GetPublishedContentValueSetValidator());
UmbracoIndexConfig.GetPublishedContentValueSetValidator());
return index;
}
@@ -80,28 +82,11 @@ namespace Umbraco.Web.Search
CreateFileSystemLuceneDirectory(Constants.UmbracoIndexes.MembersIndexPath),
new CultureInvariantWhitespaceAnalyzer(),
ProfilingLogger,
GetMemberValueSetValidator());
UmbracoIndexConfig.GetMemberValueSetValidator());
return index;
}
public virtual IContentValueSetValidator GetContentValueSetValidator()
{
return new ContentValueSetValidator(false, true, PublicAccessService);
}
public virtual IContentValueSetValidator GetPublishedContentValueSetValidator()
{
return new ContentValueSetValidator(true, false, PublicAccessService);
}
/// <summary>
/// Returns the <see cref="IValueSetValidator"/> for the member indexer
/// </summary>
/// <returns></returns>
public virtual IValueSetValidator GetMemberValueSetValidator()
{
return new MemberValueSetValidator();
}
}
}