Raise SendingContentModel event for each element type in blocklist (#10869)
Co-authored-by: Nikolaj <nel@umbraco.dk>
This commit is contained in:
@@ -1,10 +1,8 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Net.Http;
|
||||
using System.Web.Http.Filters;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Web.Composing;
|
||||
using Umbraco.Web.Editors;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
|
||||
namespace Umbraco.Web.WebApi.Filters
|
||||
{
|
||||
@@ -23,18 +21,37 @@ namespace Umbraco.Web.WebApi.Filters
|
||||
if (actionExecutedContext.Response.Content is ObjectContent objectContent)
|
||||
{
|
||||
var model = objectContent.Value;
|
||||
|
||||
if (model != null)
|
||||
{
|
||||
var args = new EditorModelEventArgs(
|
||||
model,
|
||||
Current.UmbracoContext);
|
||||
EditorModelEventManager.EmitEvent(actionExecutedContext, args);
|
||||
objectContent.Value = args.Model;
|
||||
if (model is IDictionary modelDict)
|
||||
{
|
||||
foreach (var entity in modelDict)
|
||||
{
|
||||
if (entity is DictionaryEntry entry)
|
||||
{
|
||||
var args = CreateArgs(entry.Value);
|
||||
EditorModelEventManager.EmitEvent(actionExecutedContext, args);
|
||||
entry.Value = args.Model;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var args = CreateArgs(model);
|
||||
EditorModelEventManager.EmitEvent(actionExecutedContext, args);
|
||||
objectContent.Value = args.Model;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
base.OnActionExecuted(actionExecutedContext);
|
||||
}
|
||||
|
||||
private EditorModelEventArgs CreateArgs(object model)
|
||||
{
|
||||
return new EditorModelEventArgs(
|
||||
model,
|
||||
Current.UmbracoContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user