Skip to content

Commit

Permalink
Remove IContentDefinitionHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeAlhayek committed Oct 23, 2024
1 parent 5d7a605 commit 358a586
Show file tree
Hide file tree
Showing 6 changed files with 137 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public override void ConfigureServices(IServiceCollection services)
services.AddScoped<IContentDisplayDriver, DashboardContentDisplayDriver>();

services.AddDataMigration<Migrations>();
services.AddScoped<IContentDefinitionHandler, DashboardPartContentTypeDefinitionHandler>();
services.AddScoped<IContentDefinitionEventHandler, DashboardPartContentTypeDefinitionHandler>();
}

public override void Configure(IApplicationBuilder builder, IEndpointRouteBuilder routes, IServiceProvider serviceProvider)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -75,39 +75,51 @@ private async ValueTask<IEnumerable<IndexAlias>> 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();
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class ContentDefinitionManager : IContentDefinitionManager
private const string CacheKey = nameof(ContentDefinitionManager);

private readonly IContentDefinitionStore _contentDefinitionStore;
private readonly IEnumerable<IContentDefinitionHandler> _handlers;
private readonly IEnumerable<IContentDefinitionEventHandler> _handlers;
private readonly ILogger _logger;
private readonly IMemoryCache _memoryCache;

Expand All @@ -27,7 +27,7 @@ public class ContentDefinitionManager : IContentDefinitionManager

public ContentDefinitionManager(
IContentDefinitionStore contentDefinitionStore,
IEnumerable<IContentDefinitionHandler> handlers,
IEnumerable<IContentDefinitionEventHandler> handlers,
ILogger<ContentDefinitionManager> logger,
IMemoryCache memoryCache)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace OrchardCore.ContentTypes.Events;

public abstract class ContentDefinitionHandlerBase : IContentDefinitionHandler
public abstract class ContentDefinitionHandlerBase : IContentDefinitionEventHandler
{
public virtual void BuildingContentPartDefinition(BuildingContentPartDefinitionContext context)
{
Expand All @@ -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)
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
}
}

This file was deleted.

0 comments on commit 358a586

Please sign in to comment.