diff --git a/src/OrchardCore.Modules/OrchardCore.AdminDashboard/Startup.cs b/src/OrchardCore.Modules/OrchardCore.AdminDashboard/Startup.cs index fe2b3c48103..2c8044282b4 100644 --- a/src/OrchardCore.Modules/OrchardCore.AdminDashboard/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.AdminDashboard/Startup.cs @@ -43,7 +43,7 @@ public override void ConfigureServices(IServiceCollection services) services.AddScoped(); services.AddDataMigration(); - services.AddScoped(); + services.AddScoped(); } public override void Configure(IApplicationBuilder builder, IEndpointRouteBuilder routes, IServiceProvider serviceProvider) diff --git a/src/OrchardCore/OrchardCore.ContentManagement.GraphQL/Queries/Types/DynamicContentFieldsIndexAliasProvider.cs b/src/OrchardCore/OrchardCore.ContentManagement.GraphQL/Queries/Types/DynamicContentFieldsIndexAliasProvider.cs index d998b172211..2c491c4456c 100644 --- a/src/OrchardCore/OrchardCore.ContentManagement.GraphQL/Queries/Types/DynamicContentFieldsIndexAliasProvider.cs +++ b/src/OrchardCore/OrchardCore.ContentManagement.GraphQL/Queries/Types/DynamicContentFieldsIndexAliasProvider.cs @@ -7,7 +7,7 @@ namespace OrchardCore.ContentManagement.GraphQL.Queries.Types; -public class DynamicContentFieldsIndexAliasProvider : IIndexAliasProvider, IContentDefinitionEventHandler +public class DynamicContentFieldsIndexAliasProvider : ContentDefinitionHandlerBase, IIndexAliasProvider { private static readonly string _cacheKey = nameof(DynamicContentFieldsIndexAliasProvider); @@ -75,39 +75,51 @@ private async ValueTask> GetAliasesInternalAsync() return aliases; } - private void InvalidateInternalAsync() => _memoryCache.Remove(_cacheKey); + private void InvalidateInternal() + => _memoryCache.Remove(_cacheKey); - public void ContentFieldAttached(ContentFieldAttachedContext context) => InvalidateInternalAsync(); + public override void ContentFieldAttached(ContentFieldAttachedContext context) + => InvalidateInternal(); - public void ContentFieldDetached(ContentFieldDetachedContext context) => InvalidateInternalAsync(); + public override void ContentFieldDetached(ContentFieldDetachedContext context) + => InvalidateInternal(); - public void ContentPartAttached(ContentPartAttachedContext context) => InvalidateInternalAsync(); + public override void ContentPartAttached(ContentPartAttachedContext context) + => InvalidateInternal(); - public void ContentPartCreated(ContentPartCreatedContext context) => InvalidateInternalAsync(); + public override void ContentPartCreated(ContentPartCreatedContext context) + => InvalidateInternal(); - public void ContentPartDetached(ContentPartDetachedContext context) => InvalidateInternalAsync(); + public override void ContentPartDetached(ContentPartDetachedContext context) + => InvalidateInternal(); - public void ContentPartImported(ContentPartImportedContext context) => InvalidateInternalAsync(); + public override void ContentPartImported(ContentPartImportedContext context) + => InvalidateInternal(); - public void ContentPartImporting(ContentPartImportingContext context) { } + public override void ContentPartRemoved(ContentPartRemovedContext context) + => InvalidateInternal(); - public void ContentPartRemoved(ContentPartRemovedContext context) => InvalidateInternalAsync(); + public override void ContentTypeCreated(ContentTypeCreatedContext context) + => InvalidateInternal(); - public void ContentTypeCreated(ContentTypeCreatedContext context) => InvalidateInternalAsync(); + public override void ContentTypeImported(ContentTypeImportedContext context) + => InvalidateInternal(); - public void ContentTypeImported(ContentTypeImportedContext context) => InvalidateInternalAsync(); + public override void ContentTypeRemoved(ContentTypeRemovedContext context) + => InvalidateInternal(); - public void ContentTypeImporting(ContentTypeImportingContext context) { } + public override void ContentTypeUpdated(ContentTypeUpdatedContext context) + => InvalidateInternal(); - public void ContentTypeRemoved(ContentTypeRemovedContext context) => InvalidateInternalAsync(); + public override void ContentPartUpdated(ContentPartUpdatedContext context) + => InvalidateInternal(); - public void ContentTypeUpdated(ContentTypeUpdatedContext context) => InvalidateInternalAsync(); + public override void ContentTypePartUpdated(ContentTypePartUpdatedContext context) + => InvalidateInternal(); - public void ContentPartUpdated(ContentPartUpdatedContext context) => InvalidateInternalAsync(); + public override void ContentFieldUpdated(ContentFieldUpdatedContext context) + => InvalidateInternal(); - public void ContentTypePartUpdated(ContentTypePartUpdatedContext context) => InvalidateInternalAsync(); - - public void ContentFieldUpdated(ContentFieldUpdatedContext context) => InvalidateInternalAsync(); - - public void ContentPartFieldUpdated(ContentPartFieldUpdatedContext context) => InvalidateInternalAsync(); + public override void ContentPartFieldUpdated(ContentPartFieldUpdatedContext context) + => InvalidateInternal(); } diff --git a/src/OrchardCore/OrchardCore.ContentManagement/ContentDefinitionManager.cs b/src/OrchardCore/OrchardCore.ContentManagement/ContentDefinitionManager.cs index 47402fbd4d5..8476a34905d 100644 --- a/src/OrchardCore/OrchardCore.ContentManagement/ContentDefinitionManager.cs +++ b/src/OrchardCore/OrchardCore.ContentManagement/ContentDefinitionManager.cs @@ -15,7 +15,7 @@ public class ContentDefinitionManager : IContentDefinitionManager private const string CacheKey = nameof(ContentDefinitionManager); private readonly IContentDefinitionStore _contentDefinitionStore; - private readonly IEnumerable _handlers; + private readonly IEnumerable _handlers; private readonly ILogger _logger; private readonly IMemoryCache _memoryCache; @@ -27,7 +27,7 @@ public class ContentDefinitionManager : IContentDefinitionManager public ContentDefinitionManager( IContentDefinitionStore contentDefinitionStore, - IEnumerable handlers, + IEnumerable handlers, ILogger logger, IMemoryCache memoryCache) { diff --git a/src/OrchardCore/OrchardCore.ContentTypes.Abstractions/Events/ContentDefinitionHandlerBase.cs b/src/OrchardCore/OrchardCore.ContentTypes.Abstractions/Events/ContentDefinitionHandlerBase.cs index 6958fbc37e4..46af7ce3a11 100644 --- a/src/OrchardCore/OrchardCore.ContentTypes.Abstractions/Events/ContentDefinitionHandlerBase.cs +++ b/src/OrchardCore/OrchardCore.ContentTypes.Abstractions/Events/ContentDefinitionHandlerBase.cs @@ -1,6 +1,6 @@ namespace OrchardCore.ContentTypes.Events; -public abstract class ContentDefinitionHandlerBase : IContentDefinitionHandler +public abstract class ContentDefinitionHandlerBase : IContentDefinitionEventHandler { public virtual void BuildingContentPartDefinition(BuildingContentPartDefinitionContext context) { @@ -17,4 +17,72 @@ public virtual void BuildingContentType(BuildingContentTypeContext context) public virtual void BuildingContentTypePart(BuildingContentTypePartContext context) { } + + public virtual void ContentFieldAttached(ContentFieldAttachedContext context) + { + } + + public virtual void ContentFieldDetached(ContentFieldDetachedContext context) + { + } + + public virtual void ContentFieldUpdated(ContentFieldUpdatedContext context) + { + } + + public virtual void ContentPartAttached(ContentPartAttachedContext context) + { + } + + public virtual void ContentPartCreated(ContentPartCreatedContext context) + { + } + + public virtual void ContentPartDetached(ContentPartDetachedContext context) + { + } + + public virtual void ContentPartFieldUpdated(ContentPartFieldUpdatedContext context) + { + } + + public virtual void ContentPartImported(ContentPartImportedContext context) + { + } + + public virtual void ContentPartImporting(ContentPartImportingContext context) + { + } + + public virtual void ContentPartRemoved(ContentPartRemovedContext context) + { + } + + public virtual void ContentPartUpdated(ContentPartUpdatedContext context) + { + } + + public virtual void ContentTypeCreated(ContentTypeCreatedContext context) + { + } + + public virtual void ContentTypeImported(ContentTypeImportedContext context) + { + } + + public virtual void ContentTypeImporting(ContentTypeImportingContext context) + { + } + + public virtual void ContentTypePartUpdated(ContentTypePartUpdatedContext context) + { + } + + public virtual void ContentTypeRemoved(ContentTypeRemovedContext context) + { + } + + public virtual void ContentTypeUpdated(ContentTypeUpdatedContext context) + { + } } diff --git a/src/OrchardCore/OrchardCore.ContentTypes.Abstractions/Events/IContentDefinitionEventHandler.cs b/src/OrchardCore/OrchardCore.ContentTypes.Abstractions/Events/IContentDefinitionEventHandler.cs index b711a15dafd..416cf44c4cf 100644 --- a/src/OrchardCore/OrchardCore.ContentTypes.Abstractions/Events/IContentDefinitionEventHandler.cs +++ b/src/OrchardCore/OrchardCore.ContentTypes.Abstractions/Events/IContentDefinitionEventHandler.cs @@ -3,20 +3,52 @@ namespace OrchardCore.ContentTypes.Events; public interface IContentDefinitionEventHandler { void ContentTypeCreated(ContentTypeCreatedContext context); + void ContentTypeUpdated(ContentTypeUpdatedContext context); + void ContentTypeRemoved(ContentTypeRemovedContext context); + void ContentTypeImporting(ContentTypeImportingContext context); + void ContentTypeImported(ContentTypeImportedContext context); + void ContentPartCreated(ContentPartCreatedContext context); + void ContentPartUpdated(ContentPartUpdatedContext context); + void ContentPartRemoved(ContentPartRemovedContext context); + void ContentPartAttached(ContentPartAttachedContext context); + void ContentPartDetached(ContentPartDetachedContext context); + void ContentPartImporting(ContentPartImportingContext context); + void ContentPartImported(ContentPartImportedContext context); + void ContentTypePartUpdated(ContentTypePartUpdatedContext context); + void ContentFieldAttached(ContentFieldAttachedContext context); + void ContentFieldUpdated(ContentFieldUpdatedContext context); + void ContentFieldDetached(ContentFieldDetachedContext context); + void ContentPartFieldUpdated(ContentPartFieldUpdatedContext context); + + void BuildingContentType(BuildingContentTypeContext context) + { + } + + void BuildingContentTypePart(BuildingContentTypePartContext context) + { + } + + void BuildingContentPartField(BuildingContentPartFieldContext context) + { + } + + void BuildingContentPartDefinition(BuildingContentPartDefinitionContext context) + { + } } diff --git a/src/OrchardCore/OrchardCore.ContentTypes.Abstractions/Events/IContentDefinitionHandler.cs b/src/OrchardCore/OrchardCore.ContentTypes.Abstractions/Events/IContentDefinitionHandler.cs deleted file mode 100644 index 8ea38800627..00000000000 --- a/src/OrchardCore/OrchardCore.ContentTypes.Abstractions/Events/IContentDefinitionHandler.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace OrchardCore.ContentTypes.Events; - -public interface IContentDefinitionHandler -{ - void BuildingContentType(BuildingContentTypeContext context); - - void BuildingContentTypePart(BuildingContentTypePartContext context); - - void BuildingContentPartField(BuildingContentPartFieldContext context); - - void BuildingContentPartDefinition(BuildingContentPartDefinitionContext context); -}