diff --git a/src/Umbraco.Web/Editors/ContentController.cs b/src/Umbraco.Web/Editors/ContentController.cs
index cb6e56cb13..6358656d00 100644
--- a/src/Umbraco.Web/Editors/ContentController.cs
+++ b/src/Umbraco.Web/Editors/ContentController.cs
@@ -81,7 +81,8 @@ namespace Umbraco.Web.Editors
///
///
///
- [EnsureUserPermissionForContent("id")]
+ [OutgoingEditorModelEvent]
+ [EnsureUserPermissionForContent("id")]
public ContentItemDisplay GetById(int id)
{
var foundContent = GetObjectFromRequest(() => Services.ContentService.GetById(id));
@@ -116,6 +117,7 @@ namespace Umbraco.Web.Editors
/// If this is a container type, we'll remove the umbContainerView tab for a new item since
/// it cannot actually list children if it doesn't exist yet.
///
+ [OutgoingEditorModelEvent]
public ContentItemDisplay GetEmpty(string contentTypeAlias, int parentId)
{
var contentType = Services.ContentTypeService.GetContentType(contentTypeAlias);
diff --git a/src/Umbraco.Web/Editors/EditorModelEventManager.cs b/src/Umbraco.Web/Editors/EditorModelEventManager.cs
new file mode 100644
index 0000000000..0414bc0cdd
--- /dev/null
+++ b/src/Umbraco.Web/Editors/EditorModelEventManager.cs
@@ -0,0 +1,85 @@
+using System;
+using System.Web.Http.Filters;
+using Umbraco.Core.Events;
+using Umbraco.Web.Models.ContentEditing;
+
+namespace Umbraco.Web.Editors
+{
+ public abstract class EditorModelEventArgs : EventArgs
+ {
+ protected EditorModelEventArgs(object model, UmbracoContext umbracoContext)
+ {
+ Model = model;
+ UmbracoContext = umbracoContext;
+ }
+
+ public object Model { get; private set; }
+ public UmbracoContext UmbracoContext { get; private set; }
+ }
+
+ public sealed class EditorModelEventArgs : EditorModelEventArgs
+ {
+ public EditorModelEventArgs(T model, UmbracoContext umbracoContext)
+ : base(model, umbracoContext)
+ {
+ Model = model;
+ }
+
+ public new T Model { get; private set; }
+ }
+
+ ///
+ /// Used to emit events for editor models in the back office
+ ///
+ public sealed class EditorModelEventManager
+ {
+ public static event TypedEventHandler> SendingContentModel;
+ public static event TypedEventHandler> SendingMediaModel;
+ public static event TypedEventHandler> SendingMemberModel;
+
+ private static void OnSendingContentModel(HttpActionExecutedContext sender, EditorModelEventArgs e)
+ {
+ var handler = SendingContentModel;
+ if (handler != null) handler(sender, e);
+ }
+
+ private static void OnSendingMediaModel(HttpActionExecutedContext sender, EditorModelEventArgs e)
+ {
+ var handler = SendingMediaModel;
+ if (handler != null) handler(sender, e);
+ }
+
+ private static void OnSendingMemberModel(HttpActionExecutedContext sender, EditorModelEventArgs e)
+ {
+ var handler = SendingMemberModel;
+ if (handler != null) handler(sender, e);
+ }
+
+ ///
+ /// Based on the type, emit's a specific event
+ ///
+ ///
+ ///
+ internal static void EmitEvent(HttpActionExecutedContext sender, EditorModelEventArgs e)
+ {
+ var contentItemDisplay = e.Model as ContentItemDisplay;
+ if (contentItemDisplay != null)
+ {
+ OnSendingContentModel(sender, (EditorModelEventArgs) e);
+ }
+
+ var mediaItemDisplay = e.Model as MediaItemDisplay;
+ if (mediaItemDisplay != null)
+ {
+ OnSendingMediaModel(sender, (EditorModelEventArgs)e);
+ }
+
+ var memberItemDisplay = e.Model as MemberDisplay;
+ if (memberItemDisplay != null)
+ {
+ OnSendingMemberModel(sender, (EditorModelEventArgs)e);
+ }
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/src/Umbraco.Web/Editors/MediaController.cs b/src/Umbraco.Web/Editors/MediaController.cs
index a2637e68e8..e84aaadce5 100644
--- a/src/Umbraco.Web/Editors/MediaController.cs
+++ b/src/Umbraco.Web/Editors/MediaController.cs
@@ -63,13 +63,14 @@ namespace Umbraco.Web.Editors
: base(umbracoContext)
{
}
-
+
///
/// Gets an empty content item for the
///
///
///
///
+ [OutgoingEditorModelEvent]
public MediaItemDisplay GetEmpty(string contentTypeAlias, int parentId)
{
var contentType = Services.ContentTypeService.GetMediaType(contentTypeAlias);
@@ -92,6 +93,7 @@ namespace Umbraco.Web.Editors
///
///
///
+ [OutgoingEditorModelEvent]
[EnsureUserPermissionForMedia("id")]
public MediaItemDisplay GetById(int id)
{
diff --git a/src/Umbraco.Web/Editors/MemberController.cs b/src/Umbraco.Web/Editors/MemberController.cs
index 0788ba43eb..f03cda1bba 100644
--- a/src/Umbraco.Web/Editors/MemberController.cs
+++ b/src/Umbraco.Web/Editors/MemberController.cs
@@ -145,6 +145,7 @@ namespace Umbraco.Web.Editors
///
///
///
+ [OutgoingEditorModelEvent]
public MemberDisplay GetByKey(Guid key)
{
MembershipUser foundMembershipMember;
@@ -196,6 +197,7 @@ namespace Umbraco.Web.Editors
///
///
///
+ [OutgoingEditorModelEvent]
public MemberDisplay GetEmpty(string contentTypeAlias = null)
{
IMember emptyContent;
diff --git a/src/Umbraco.Web/Models/PublishedContentModels.cs b/src/Umbraco.Web/Models/PublishedContentModels.cs
deleted file mode 100644
index d6d3cd9973..0000000000
--- a/src/Umbraco.Web/Models/PublishedContentModels.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Umbraco.Web.PublishedContentModels
-{
- class Empty
- {
- }
-}
diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj
index 2ae1436d58..ac3fb00af2 100644
--- a/src/Umbraco.Web/Umbraco.Web.csproj
+++ b/src/Umbraco.Web/Umbraco.Web.csproj
@@ -319,6 +319,7 @@
+
@@ -686,6 +687,7 @@
+
diff --git a/src/Umbraco.Web/WebApi/Filters/OutgoingEditorModelEventAttribute.cs b/src/Umbraco.Web/WebApi/Filters/OutgoingEditorModelEventAttribute.cs
new file mode 100644
index 0000000000..3c74f15b8d
--- /dev/null
+++ b/src/Umbraco.Web/WebApi/Filters/OutgoingEditorModelEventAttribute.cs
@@ -0,0 +1,38 @@
+using System;
+using System.Net.Http;
+using System.Web.Http.Filters;
+using Umbraco.Core;
+using Umbraco.Web.Editors;
+using Umbraco.Web.Models.ContentEditing;
+
+namespace Umbraco.Web.WebApi.Filters
+{
+ ///
+ /// Used to emit outgoing editor model events
+ ///
+ internal sealed class OutgoingEditorModelEventAttribute : ActionFilterAttribute
+ {
+ public override void OnActionExecuted(HttpActionExecutedContext actionExecutedContext)
+ {
+ if (actionExecutedContext.Response == null) return;
+
+ var user = UmbracoContext.Current.Security.CurrentUser;
+ if (user == null) return;
+
+ var objectContent = actionExecutedContext.Response.Content as ObjectContent;
+ if (objectContent != null)
+ {
+ var model = objectContent.Value;
+
+ if (model != null)
+ {
+ EditorModelEventManager.EmitEvent(actionExecutedContext, new EditorModelEventArgs(
+ (dynamic)model,
+ UmbracoContext.Current));
+ }
+ }
+
+ base.OnActionExecuted(actionExecutedContext);
+ }
+ }
+}
\ No newline at end of file