mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-07-31 21:15:28 +08:00
#19934: Fixing taxonomy fields usage in autoroute
The Loaded event was not called when creating a new content item, hence the lazy loader was not initialized Work Item: 19934
This commit is contained in:
parent
dd852c3317
commit
3aeed0ff0f
@ -29,8 +29,9 @@ namespace Orchard.Taxonomies.Handlers {
|
||||
OnRemoved<TermsPart>((context, part) => RecalculateCount(taxonomyService, part));
|
||||
|
||||
// Tells how to load the field terms on demand, when a content item it loaded or when it has been created
|
||||
OnInitialized<TermsPart>((context, part) => InitializerTermsLoader(part));
|
||||
OnLoaded<TermsPart>((context, part) => InitializerTermsLoader(part));
|
||||
OnCreated<TermsPart>((context, part) => InitializerTermsLoader(part));
|
||||
OnUpdated<TermsPart>((context, part) => InitializerTermsLoader(part));
|
||||
|
||||
OnIndexing<TermsPart>(
|
||||
(context, part) => {
|
||||
|
@ -117,6 +117,7 @@ namespace Orchard.ContentManagement {
|
||||
};
|
||||
|
||||
Handlers.Invoke(handler => handler.Initializing(context3), Logger);
|
||||
Handlers.Invoke(handler => handler.Initialized(context3), Logger);
|
||||
|
||||
// composite result is returned
|
||||
return context3.ContentItem;
|
||||
|
@ -21,6 +21,10 @@ namespace Orchard.ContentManagement.Handlers {
|
||||
Filters.Add(new InlineStorageFilter<TPart> { OnInitializing = handler });
|
||||
}
|
||||
|
||||
protected void OnInitialized<TPart>(Action<InitializingContentContext, TPart> handler) where TPart : class, IContent {
|
||||
Filters.Add(new InlineStorageFilter<TPart> { OnInitialized = handler });
|
||||
}
|
||||
|
||||
protected void OnCreating<TPart>(Action<CreateContentContext, TPart> handler) where TPart : class, IContent {
|
||||
Filters.Add(new InlineStorageFilter<TPart> { OnCreating = handler });
|
||||
}
|
||||
@ -103,6 +107,7 @@ namespace Orchard.ContentManagement.Handlers {
|
||||
class InlineStorageFilter<TPart> : StorageFilterBase<TPart> where TPart : class, IContent {
|
||||
public Action<ActivatedContentContext, TPart> OnActivated { get; set; }
|
||||
public Action<InitializingContentContext, TPart> OnInitializing { get; set; }
|
||||
public Action<InitializingContentContext, TPart> OnInitialized { get; set; }
|
||||
public Action<CreateContentContext, TPart> OnCreating { get; set; }
|
||||
public Action<CreateContentContext, TPart> OnCreated { get; set; }
|
||||
public Action<LoadContentContext, TPart> OnLoading { get; set; }
|
||||
@ -125,6 +130,9 @@ namespace Orchard.ContentManagement.Handlers {
|
||||
protected override void Initializing(InitializingContentContext context, TPart instance) {
|
||||
if (OnInitializing != null) OnInitializing(context, instance);
|
||||
}
|
||||
protected override void Initialized(InitializingContentContext context, TPart instance) {
|
||||
if (OnInitialized != null) OnInitialized(context, instance);
|
||||
}
|
||||
protected override void Creating(CreateContentContext context, TPart instance) {
|
||||
if (OnCreating != null) OnCreating(context, instance);
|
||||
}
|
||||
@ -215,6 +223,12 @@ namespace Orchard.ContentManagement.Handlers {
|
||||
Initializing(context);
|
||||
}
|
||||
|
||||
void IContentHandler.Initialized(InitializingContentContext context) {
|
||||
foreach (var filter in Filters.OfType<IContentStorageFilter>())
|
||||
filter.Initialized(context);
|
||||
Initialized(context);
|
||||
}
|
||||
|
||||
void IContentHandler.Creating(CreateContentContext context) {
|
||||
foreach (var filter in Filters.OfType<IContentStorageFilter>())
|
||||
filter.Creating(context);
|
||||
@ -352,6 +366,7 @@ namespace Orchard.ContentManagement.Handlers {
|
||||
protected virtual void Activated(ActivatedContentContext context) { }
|
||||
|
||||
protected virtual void Initializing(InitializingContentContext context) { }
|
||||
protected virtual void Initialized(InitializingContentContext context) { }
|
||||
|
||||
protected virtual void Creating(CreateContentContext context) { }
|
||||
protected virtual void Created(CreateContentContext context) { }
|
||||
|
@ -2,8 +2,9 @@
|
||||
public class ContentHandlerBase : IContentHandler {
|
||||
public virtual void Activating(ActivatingContentContext context) {}
|
||||
public virtual void Activated(ActivatedContentContext context) {}
|
||||
public virtual void Initializing(InitializingContentContext context) {}
|
||||
public virtual void Creating(CreateContentContext context) {}
|
||||
public virtual void Initializing(InitializingContentContext context) { }
|
||||
public virtual void Initialized(InitializingContentContext context) { }
|
||||
public virtual void Creating(CreateContentContext context) { }
|
||||
public virtual void Created(CreateContentContext context) {}
|
||||
public virtual void Loading(LoadContentContext context) {}
|
||||
public virtual void Loaded(LoadContentContext context) {}
|
||||
|
@ -3,6 +3,7 @@
|
||||
void Activating(ActivatingContentContext context);
|
||||
void Activated(ActivatedContentContext context);
|
||||
void Initializing(InitializingContentContext context);
|
||||
void Initialized(InitializingContentContext context);
|
||||
void Creating(CreateContentContext context);
|
||||
void Created(CreateContentContext context);
|
||||
void Loading(LoadContentContext context);
|
||||
|
@ -2,6 +2,7 @@ namespace Orchard.ContentManagement.Handlers {
|
||||
public interface IContentStorageFilter : IContentFilter {
|
||||
void Activated(ActivatedContentContext context);
|
||||
void Initializing(InitializingContentContext context);
|
||||
void Initialized(InitializingContentContext context);
|
||||
void Creating(CreateContentContext context);
|
||||
void Created(CreateContentContext context);
|
||||
void Loading(LoadContentContext context);
|
||||
|
@ -2,7 +2,9 @@ namespace Orchard.ContentManagement.Handlers {
|
||||
public abstract class StorageFilterBase<TPart> : IContentStorageFilter where TPart : class, IContent {
|
||||
|
||||
protected virtual void Activated(ActivatedContentContext context, TPart instance) { }
|
||||
protected virtual void Activating(ActivatingContentContext context, TPart instance) { }
|
||||
protected virtual void Initializing(InitializingContentContext context, TPart instance) { }
|
||||
protected virtual void Initialized(InitializingContentContext context, TPart instance) { }
|
||||
protected virtual void Creating(CreateContentContext context, TPart instance) { }
|
||||
protected virtual void Created(CreateContentContext context, TPart instance) { }
|
||||
protected virtual void Loading(LoadContentContext context, TPart instance) { }
|
||||
@ -20,7 +22,6 @@ namespace Orchard.ContentManagement.Handlers {
|
||||
protected virtual void Indexing(IndexContentContext context, TPart instance) { }
|
||||
protected virtual void Indexed(IndexContentContext context, TPart instance) { }
|
||||
|
||||
|
||||
void IContentStorageFilter.Activated(ActivatedContentContext context) {
|
||||
if (context.ContentItem.Is<TPart>())
|
||||
Activated(context, context.ContentItem.As<TPart>());
|
||||
@ -31,6 +32,11 @@ namespace Orchard.ContentManagement.Handlers {
|
||||
Initializing(context, context.ContentItem.As<TPart>());
|
||||
}
|
||||
|
||||
void IContentStorageFilter.Initialized(InitializingContentContext context) {
|
||||
if (context.ContentItem.Is<TPart>())
|
||||
Initialized(context, context.ContentItem.As<TPart>());
|
||||
}
|
||||
|
||||
void IContentStorageFilter.Creating(CreateContentContext context) {
|
||||
if (context.ContentItem.Is<TPart>())
|
||||
Creating(context, context.ContentItem.As<TPart>());
|
||||
|
Loading…
Reference in New Issue
Block a user