mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-19 01:57:55 +08:00
Creating a new Updating/Updated event
--HG-- branch : autoroute
This commit is contained in:
@@ -525,7 +525,15 @@ namespace Orchard.ContentManagement {
|
||||
}
|
||||
|
||||
public dynamic UpdateEditor(IContent content, IUpdateModel updater, string groupId = "") {
|
||||
return _contentDisplay.Value.UpdateEditor(content, updater, groupId);
|
||||
var context = new UpdateContentContext(content.ContentItem);
|
||||
|
||||
Handlers.Invoke(handler => handler.Updating(context), Logger);
|
||||
|
||||
var result = _contentDisplay.Value.UpdateEditor(content, updater, groupId);
|
||||
|
||||
Handlers.Invoke(handler => handler.Updated(context), Logger);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public IContentQuery<ContentItem> Query() {
|
||||
|
@@ -37,6 +37,14 @@ namespace Orchard.ContentManagement.Handlers {
|
||||
Filters.Add(new InlineStorageFilter<TPart> { OnLoaded = handler });
|
||||
}
|
||||
|
||||
protected void OnUpdating<TPart>(Action<UpdateContentContext, TPart> handler) where TPart : class, IContent {
|
||||
Filters.Add(new InlineStorageFilter<TPart> { OnUpdating = handler });
|
||||
}
|
||||
|
||||
protected void OnUpdated<TPart>(Action<UpdateContentContext, TPart> handler) where TPart : class, IContent {
|
||||
Filters.Add(new InlineStorageFilter<TPart> { OnUpdated = handler });
|
||||
}
|
||||
|
||||
protected void OnVersioning<TPart>(Action<VersionContentContext, TPart, TPart> handler) where TPart : class, IContent {
|
||||
Filters.Add(new InlineStorageFilter<TPart> { OnVersioning = handler });
|
||||
}
|
||||
@@ -99,6 +107,8 @@ namespace Orchard.ContentManagement.Handlers {
|
||||
public Action<CreateContentContext, TPart> OnCreated { get; set; }
|
||||
public Action<LoadContentContext, TPart> OnLoading { get; set; }
|
||||
public Action<LoadContentContext, TPart> OnLoaded { get; set; }
|
||||
public Action<UpdateContentContext, TPart> OnUpdating { get; set; }
|
||||
public Action<UpdateContentContext, TPart> OnUpdated { get; set; }
|
||||
public Action<VersionContentContext, TPart, TPart> OnVersioning { get; set; }
|
||||
public Action<VersionContentContext, TPart, TPart> OnVersioned { get; set; }
|
||||
public Action<PublishContentContext, TPart> OnPublishing { get; set; }
|
||||
@@ -127,6 +137,12 @@ namespace Orchard.ContentManagement.Handlers {
|
||||
protected override void Loaded(LoadContentContext context, TPart instance) {
|
||||
if (OnLoaded != null) OnLoaded(context, instance);
|
||||
}
|
||||
protected override void Updating(UpdateContentContext context, TPart instance) {
|
||||
if (OnUpdating != null) OnUpdating(context, instance);
|
||||
}
|
||||
protected override void Updated(UpdateContentContext context, TPart instance) {
|
||||
if (OnUpdated != null) OnUpdated(context, instance);
|
||||
}
|
||||
protected override void Versioning(VersionContentContext context, TPart existing, TPart building) {
|
||||
if (OnVersioning != null) OnVersioning(context, existing, building);
|
||||
}
|
||||
@@ -223,6 +239,18 @@ namespace Orchard.ContentManagement.Handlers {
|
||||
Loaded(context);
|
||||
}
|
||||
|
||||
void IContentHandler.Updating(UpdateContentContext context) {
|
||||
foreach (var filter in Filters.OfType<IContentStorageFilter>())
|
||||
filter.Updating(context);
|
||||
Updating(context);
|
||||
}
|
||||
|
||||
void IContentHandler.Updated(UpdateContentContext context) {
|
||||
foreach (var filter in Filters.OfType<IContentStorageFilter>())
|
||||
filter.Updated(context);
|
||||
Updated(context);
|
||||
}
|
||||
|
||||
void IContentHandler.Versioning(VersionContentContext context) {
|
||||
foreach (var filter in Filters.OfType<IContentStorageFilter>())
|
||||
filter.Versioning(context);
|
||||
@@ -331,6 +359,9 @@ namespace Orchard.ContentManagement.Handlers {
|
||||
protected virtual void Loading(LoadContentContext context) { }
|
||||
protected virtual void Loaded(LoadContentContext context) { }
|
||||
|
||||
protected virtual void Updating(UpdateContentContext context) { }
|
||||
protected virtual void Updated(UpdateContentContext context) { }
|
||||
|
||||
protected virtual void Versioning(VersionContentContext context) { }
|
||||
protected virtual void Versioned(VersionContentContext context) { }
|
||||
|
||||
|
@@ -7,7 +7,9 @@
|
||||
public virtual void Created(CreateContentContext context) {}
|
||||
public virtual void Loading(LoadContentContext context) {}
|
||||
public virtual void Loaded(LoadContentContext context) {}
|
||||
public virtual void Versioning(VersionContentContext context) {}
|
||||
public virtual void Updating(UpdateContentContext context) { }
|
||||
public virtual void Updated(UpdateContentContext context) { }
|
||||
public virtual void Versioning(VersionContentContext context) { }
|
||||
public virtual void Versioned(VersionContentContext context) {}
|
||||
public virtual void Publishing(PublishContentContext context) {}
|
||||
public virtual void Published(PublishContentContext context) {}
|
||||
|
@@ -7,6 +7,8 @@
|
||||
void Created(CreateContentContext context);
|
||||
void Loading(LoadContentContext context);
|
||||
void Loaded(LoadContentContext context);
|
||||
void Updating(UpdateContentContext context);
|
||||
void Updated(UpdateContentContext context);
|
||||
void Versioning(VersionContentContext context);
|
||||
void Versioned(VersionContentContext context);
|
||||
void Publishing(PublishContentContext context);
|
||||
|
@@ -6,6 +6,8 @@ namespace Orchard.ContentManagement.Handlers {
|
||||
void Created(CreateContentContext context);
|
||||
void Loading(LoadContentContext context);
|
||||
void Loaded(LoadContentContext context);
|
||||
void Updating(UpdateContentContext context);
|
||||
void Updated(UpdateContentContext context);
|
||||
void Versioning(VersionContentContext context);
|
||||
void Versioned(VersionContentContext context);
|
||||
void Publishing(PublishContentContext context);
|
||||
|
@@ -7,6 +7,8 @@ namespace Orchard.ContentManagement.Handlers {
|
||||
protected virtual void Created(CreateContentContext context, TPart instance) { }
|
||||
protected virtual void Loading(LoadContentContext context, TPart instance) { }
|
||||
protected virtual void Loaded(LoadContentContext context, TPart instance) { }
|
||||
protected virtual void Updating(UpdateContentContext context, TPart instance) { }
|
||||
protected virtual void Updated(UpdateContentContext context, TPart instance) { }
|
||||
protected virtual void Versioning(VersionContentContext context, TPart existing, TPart building) { }
|
||||
protected virtual void Versioned(VersionContentContext context, TPart existing, TPart building) { }
|
||||
protected virtual void Publishing(PublishContentContext context, TPart instance) { }
|
||||
@@ -49,6 +51,16 @@ namespace Orchard.ContentManagement.Handlers {
|
||||
Loaded(context, context.ContentItem.As<TPart>());
|
||||
}
|
||||
|
||||
void IContentStorageFilter.Updating(UpdateContentContext context) {
|
||||
if (context.ContentItem.Is<TPart>())
|
||||
Updating(context, context.ContentItem.As<TPart>());
|
||||
}
|
||||
|
||||
void IContentStorageFilter.Updated(UpdateContentContext context) {
|
||||
if (context.ContentItem.Is<TPart>())
|
||||
Updated(context, context.ContentItem.As<TPart>());
|
||||
}
|
||||
|
||||
void IContentStorageFilter.Versioning(VersionContentContext context) {
|
||||
if (context.ExistingContentItem.Is<TPart>() || context.BuildingContentItem.Is<TPart>())
|
||||
Versioning(context, context.ExistingContentItem.As<TPart>(), context.BuildingContentItem.As<TPart>());
|
||||
|
@@ -0,0 +1,11 @@
|
||||
using Orchard.ContentManagement.Records;
|
||||
|
||||
namespace Orchard.ContentManagement.Handlers {
|
||||
public class UpdateContentContext : ContentContextBase {
|
||||
public UpdateContentContext(ContentItem contentItem) : base(contentItem) {
|
||||
UpdatingItemVersionRecord = contentItem.VersionRecord;
|
||||
}
|
||||
|
||||
public ContentItemVersionRecord UpdatingItemVersionRecord { get; set; }
|
||||
}
|
||||
}
|
@@ -166,6 +166,7 @@
|
||||
<Compile Include="ContentManagement\ContentPartBehavior.cs" />
|
||||
<Compile Include="ContentManagement\DefaultHqlQuery.cs" />
|
||||
<Compile Include="ContentManagement\FuncDictionary.cs" />
|
||||
<Compile Include="ContentManagement\Handlers\UpdateContentContext.cs" />
|
||||
<Compile Include="ContentManagement\IHqlExpression.cs" />
|
||||
<Compile Include="ContentManagement\IHqlQuery.cs" />
|
||||
<Compile Include="ContentManagement\Handlers\DescribeMembersContext.cs" />
|
||||
|
Reference in New Issue
Block a user