From 80218246683bbb9c10eebf1f8972187b0d1dd1b9 Mon Sep 17 00:00:00 2001 From: Sebastien Ros Date: Mon, 4 Mar 2019 15:28:23 -0800 Subject: [PATCH] Revert "Fixing taxonomy recipes (#3253)" This reverts commit f82cf1dab225decff7c6f89a0c97fe5c3ad8e947. --- .../OrchardCore.Taxonomies/Indexing/TaxonomyIndex.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/OrchardCore.Modules/OrchardCore.Taxonomies/Indexing/TaxonomyIndex.cs b/src/OrchardCore.Modules/OrchardCore.Taxonomies/Indexing/TaxonomyIndex.cs index 10362b3b664..c061d7efd4c 100644 --- a/src/OrchardCore.Modules/OrchardCore.Taxonomies/Indexing/TaxonomyIndex.cs +++ b/src/OrchardCore.Modules/OrchardCore.Taxonomies/Indexing/TaxonomyIndex.cs @@ -1,5 +1,7 @@ +using System; using System.Collections.Generic; using System.Linq; +using Microsoft.Extensions.DependencyInjection; using Newtonsoft.Json.Linq; using OrchardCore.ContentManagement; using OrchardCore.ContentManagement.Metadata; @@ -23,12 +25,13 @@ public class TaxonomyIndex : MapIndex public class TaxonomyIndexProvider : IndexProvider, IScopedIndexProvider { + private readonly IServiceProvider _serviceProvider; private readonly HashSet _ignoredTypes = new HashSet(); private IContentDefinitionManager _contentDefinitionManager; - public TaxonomyIndexProvider(IContentDefinitionManager contentDefinitionManager) + public TaxonomyIndexProvider(IServiceProvider serviceProvider) { - _contentDefinitionManager = contentDefinitionManager; + _serviceProvider = serviceProvider; } public override void Describe(DescribeContext context) @@ -47,6 +50,9 @@ public override void Describe(DescribeContext context) return null; } + // Lazy initialization because of ISession cyclic dependency + _contentDefinitionManager = _contentDefinitionManager ?? _serviceProvider.GetRequiredService(); + // Search for Taxonomy fields var fieldDefinitions = _contentDefinitionManager .GetTypeDefinition(contentItem.ContentType)