Merge branch 'v8/bugfix/5163-mapping-confusion' into v8/dev
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Umbraco.Core.Mapping
|
||||
{
|
||||
@@ -7,6 +8,7 @@ namespace Umbraco.Core.Mapping
|
||||
/// </summary>
|
||||
public class MapperContext
|
||||
{
|
||||
private readonly UmbracoMapper _mapper;
|
||||
private IDictionary<string, object> _items;
|
||||
|
||||
/// <summary>
|
||||
@@ -14,14 +16,9 @@ namespace Umbraco.Core.Mapping
|
||||
/// </summary>
|
||||
public MapperContext(UmbracoMapper mapper)
|
||||
{
|
||||
Mapper = mapper;
|
||||
_mapper = mapper;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the mapper.
|
||||
/// </summary>
|
||||
public UmbracoMapper Mapper { get;}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the context has items.
|
||||
/// </summary>
|
||||
@@ -31,5 +28,90 @@ namespace Umbraco.Core.Mapping
|
||||
/// Gets the context items.
|
||||
/// </summary>
|
||||
public IDictionary<string, object> Items => _items ?? (_items = new Dictionary<string, object>());
|
||||
|
||||
#region Map
|
||||
|
||||
/// <summary>
|
||||
/// Maps a source object to a new target object.
|
||||
/// </summary>
|
||||
/// <typeparam name="TTarget">The target type.</typeparam>
|
||||
/// <param name="source">The source object.</param>
|
||||
/// <returns>The target object.</returns>
|
||||
public TTarget Map<TTarget>(object source)
|
||||
=> _mapper.Map<TTarget>(source, this);
|
||||
|
||||
// let's say this is a bad (dangerous) idea, and leave it out for now
|
||||
/*
|
||||
/// <summary>
|
||||
/// Maps a source object to a new target object.
|
||||
/// </summary>
|
||||
/// <typeparam name="TTarget">The target type.</typeparam>
|
||||
/// <param name="source">The source object.</param>
|
||||
/// <param name="f">A mapper context preparation method.</param>
|
||||
/// <returns>The target object.</returns>
|
||||
public TTarget Map<TTarget>(object source, Action<MapperContext> f)
|
||||
{
|
||||
f(this);
|
||||
return _mapper.Map<TTarget>(source, this);
|
||||
}
|
||||
*/
|
||||
|
||||
/// <summary>
|
||||
/// Maps a source object to a new target object.
|
||||
/// </summary>
|
||||
/// <typeparam name="TSource">The source type.</typeparam>
|
||||
/// <typeparam name="TTarget">The target type.</typeparam>
|
||||
/// <param name="source">The source object.</param>
|
||||
/// <returns>The target object.</returns>
|
||||
public TTarget Map<TSource, TTarget>(TSource source)
|
||||
=> _mapper.Map<TSource, TTarget>(source, this);
|
||||
|
||||
// let's say this is a bad (dangerous) idea, and leave it out for now
|
||||
/*
|
||||
/// <summary>
|
||||
/// Maps a source object to a new target object.
|
||||
/// </summary>
|
||||
/// <typeparam name="TSource">The source type.</typeparam>
|
||||
/// <typeparam name="TTarget">The target type.</typeparam>
|
||||
/// <param name="source">The source object.</param>
|
||||
/// <param name="f">A mapper context preparation method.</param>
|
||||
/// <returns>The target object.</returns>
|
||||
public TTarget Map<TSource, TTarget>(TSource source, Action<MapperContext> f)
|
||||
{
|
||||
f(this);
|
||||
return _mapper.Map<TSource, TTarget>(source, this);
|
||||
}
|
||||
*/
|
||||
|
||||
/// <summary>
|
||||
/// Maps a source object to an existing target object.
|
||||
/// </summary>
|
||||
/// <typeparam name="TSource">The source type.</typeparam>
|
||||
/// <typeparam name="TTarget">The target type.</typeparam>
|
||||
/// <param name="source">The source object.</param>
|
||||
/// <param name="target">The target object.</param>
|
||||
/// <returns>The target object.</returns>
|
||||
public TTarget Map<TSource, TTarget>(TSource source, TTarget target)
|
||||
=> _mapper.Map(source, target, this);
|
||||
|
||||
// let's say this is a bad (dangerous) idea, and leave it out for now
|
||||
/*
|
||||
/// <summary>
|
||||
/// Maps a source object to an existing target object.
|
||||
/// </summary>
|
||||
/// <typeparam name="TSource">The source type.</typeparam>
|
||||
/// <typeparam name="TTarget">The target type.</typeparam>
|
||||
/// <param name="source">The source object.</param>
|
||||
/// <param name="target">The target object.</param>
|
||||
/// <param name="f">A mapper context preparation method.</param>
|
||||
/// <returns>The target object.</returns>
|
||||
public TTarget Map<TSource, TTarget>(TSource source, TTarget target, Action<MapperContext> f)
|
||||
{
|
||||
f(this);
|
||||
return _mapper.Map(source, target, this);
|
||||
}
|
||||
*/
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,19 +34,19 @@ namespace Umbraco.Web.Models.Mapping
|
||||
_localizedTextService = localizedTextService;
|
||||
}
|
||||
|
||||
public UserProfile GetOwner(IContentBase source, UmbracoMapper mapper)
|
||||
public UserProfile GetOwner(IContentBase source, MapperContext context)
|
||||
{
|
||||
var profile = source.GetCreatorProfile(_userService);
|
||||
return profile == null ? null : mapper.Map<IProfile, UserProfile>(profile);
|
||||
return profile == null ? null : context.Map<IProfile, UserProfile>(profile);
|
||||
}
|
||||
|
||||
public UserProfile GetCreator(IContent source, UmbracoMapper mapper)
|
||||
public UserProfile GetCreator(IContent source, MapperContext context)
|
||||
{
|
||||
var profile = source.GetWriterProfile(_userService);
|
||||
return profile == null ? null : mapper.Map<IProfile, UserProfile>(profile);
|
||||
return profile == null ? null : context.Map<IProfile, UserProfile>(profile);
|
||||
}
|
||||
|
||||
public ContentTypeBasic GetContentType(IContentBase source, UmbracoMapper mapper)
|
||||
public ContentTypeBasic GetContentType(IContentBase source, MapperContext context)
|
||||
{
|
||||
// TODO: We can resolve the UmbracoContext from the IValueResolver options!
|
||||
// OMG
|
||||
@@ -54,7 +54,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
&& Composing.Current.UmbracoContext.Security.CurrentUser.AllowedSections.Any(x => x.Equals(Constants.Applications.Settings)))
|
||||
{
|
||||
var contentType = _contentTypeBaseServiceProvider.GetContentTypeOf(source);
|
||||
var contentTypeBasic = mapper.Map<IContentTypeComposition, ContentTypeBasic>(contentType);
|
||||
var contentTypeBasic = context.Map<IContentTypeComposition, ContentTypeBasic>(contentType);
|
||||
|
||||
return contentTypeBasic;
|
||||
}
|
||||
@@ -98,4 +98,4 @@ namespace Umbraco.Web.Models.Mapping
|
||||
return apps;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,8 +64,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
// Umbraco.Code.MapAll
|
||||
private static void Map(IContent source, ContentPropertyCollectionDto target, MapperContext context)
|
||||
{
|
||||
// must pass the context through
|
||||
target.Properties = source.Properties.Select(p => context.Mapper.Map<ContentPropertyDto>(p, context));
|
||||
target.Properties = source.Properties.Select(context.Map<ContentPropertyDto>);
|
||||
}
|
||||
|
||||
// Umbraco.Code.MapAll -AllowPreview -Errors -PersistedContent
|
||||
@@ -76,7 +75,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
target.ContentApps = _commonMapper.GetContentApps(source);
|
||||
target.ContentTypeAlias = source.ContentType.Alias;
|
||||
target.ContentTypeName = _localizedTextService.UmbracoDictionaryTranslate(source.ContentType.Name);
|
||||
target.DocumentType = _commonMapper.GetContentType(source, context.Mapper);
|
||||
target.DocumentType = _commonMapper.GetContentType(source, context);
|
||||
target.Icon = source.ContentType.Icon;
|
||||
target.Id = source.Id;
|
||||
target.IsBlueprint = source.Blueprint;
|
||||
@@ -84,7 +83,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
target.IsContainer = source.ContentType.IsContainer;
|
||||
target.IsElement = source.ContentType.IsElement;
|
||||
target.Key = source.Key;
|
||||
target.Owner = _commonMapper.GetOwner(source, context.Mapper);
|
||||
target.Owner = _commonMapper.GetOwner(source, context);
|
||||
target.ParentId = source.ParentId;
|
||||
target.Path = source.Path;
|
||||
target.SortOrder = source.SortOrder;
|
||||
@@ -94,12 +93,12 @@ namespace Umbraco.Web.Models.Mapping
|
||||
target.TreeNodeUrl = _commonMapper.GetTreeNodeUrl<ContentTreeController>(source);
|
||||
target.Udi = Udi.Create(source.Blueprint ? Constants.UdiEntityType.DocumentBlueprint : Constants.UdiEntityType.Document, source.Key);
|
||||
target.UpdateDate = source.UpdateDate;
|
||||
target.Updater = _commonMapper.GetCreator(source, context.Mapper);
|
||||
target.Updater = _commonMapper.GetCreator(source, context);
|
||||
target.Urls = GetUrls(source);
|
||||
target.Variants = _contentVariantMapper.Map(source, context);
|
||||
|
||||
target.ContentDto = new ContentPropertyCollectionDto();
|
||||
target.ContentDto.Properties = source.Properties.Select(context.Mapper.Map<ContentPropertyDto>);
|
||||
target.ContentDto.Properties = source.Properties.Select(context.Map<ContentPropertyDto>);
|
||||
}
|
||||
|
||||
// Umbraco.Code.MapAll -Segment -Language
|
||||
@@ -125,17 +124,16 @@ namespace Umbraco.Web.Models.Mapping
|
||||
target.Id = source.Id;
|
||||
target.Key = source.Key;
|
||||
target.Name = GetName(source, context);
|
||||
target.Owner = _commonMapper.GetOwner(source, context.Mapper);
|
||||
target.Owner = _commonMapper.GetOwner(source, context);
|
||||
target.ParentId = source.ParentId;
|
||||
target.Path = source.Path;
|
||||
// must pass the context through
|
||||
target.Properties = source.Properties.Select(p => context.Mapper.Map<ContentPropertyBasic>(p, context));
|
||||
target.Properties = source.Properties.Select(context.Map<ContentPropertyBasic>);
|
||||
target.SortOrder = source.SortOrder;
|
||||
target.State = _basicStateMapper.Map(source, context);
|
||||
target.Trashed = source.Trashed;
|
||||
target.Udi = Udi.Create(source.Blueprint ? Constants.UdiEntityType.DocumentBlueprint : Constants.UdiEntityType.Document, source.Key);
|
||||
target.UpdateDate = GetUpdateDate(source, context);
|
||||
target.Updater = _commonMapper.GetCreator(source, context.Mapper);
|
||||
target.Updater = _commonMapper.GetCreator(source, context);
|
||||
target.VariesByCulture = source.ContentType.VariesByCulture();
|
||||
}
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
// no MapAll - take care
|
||||
private void Map(DocumentTypeSave source, IContentType target, MapperContext context)
|
||||
{
|
||||
MapSaveToTypeBase<DocumentTypeSave, PropertyTypeBasic>(source, target, context.Mapper);
|
||||
MapSaveToTypeBase<DocumentTypeSave, PropertyTypeBasic>(source, target, context);
|
||||
MapComposition(source, target, alias => _contentTypeService.Get(alias));
|
||||
|
||||
target.AllowedTemplates = source.AllowedTemplates
|
||||
@@ -93,14 +93,14 @@ namespace Umbraco.Web.Models.Mapping
|
||||
// no MapAll - take care
|
||||
private void Map(MediaTypeSave source, IMediaType target, MapperContext context)
|
||||
{
|
||||
MapSaveToTypeBase<MediaTypeSave, PropertyTypeBasic>(source, target, context.Mapper);
|
||||
MapSaveToTypeBase<MediaTypeSave, PropertyTypeBasic>(source, target, context);
|
||||
MapComposition(source, target, alias => _mediaTypeService.Get(alias));
|
||||
}
|
||||
|
||||
// no MapAll - take care
|
||||
private void Map(MemberTypeSave source, IMemberType target, MapperContext context)
|
||||
{
|
||||
MapSaveToTypeBase<MemberTypeSave, MemberPropertyTypeBasic>(source, target, context.Mapper);
|
||||
MapSaveToTypeBase<MemberTypeSave, MemberPropertyTypeBasic>(source, target, context);
|
||||
MapComposition(source, target, alias => _memberTypeService.Get(alias));
|
||||
|
||||
foreach (var propertyType in source.Groups.SelectMany(x => x.Properties))
|
||||
@@ -122,10 +122,10 @@ namespace Umbraco.Web.Models.Mapping
|
||||
target.AllowCultureVariant = source.VariesByCulture();
|
||||
|
||||
//sync templates
|
||||
target.AllowedTemplates = source.AllowedTemplates.Select(context.Mapper.Map<EntityBasic>).ToArray();
|
||||
target.AllowedTemplates = source.AllowedTemplates.Select(context.Map<EntityBasic>).ToArray();
|
||||
|
||||
if (source.DefaultTemplate != null)
|
||||
target.DefaultTemplate = context.Mapper.Map<EntityBasic>(source.DefaultTemplate);
|
||||
target.DefaultTemplate = context.Map<EntityBasic>(source.DefaultTemplate);
|
||||
|
||||
//default listview
|
||||
target.ListViewEditorName = Constants.Conventions.DataTypes.ListViewPrefix + "Content";
|
||||
@@ -237,7 +237,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
// no MapAll - take care
|
||||
private void Map(DocumentTypeSave source, DocumentTypeDisplay target, MapperContext context)
|
||||
{
|
||||
MapTypeToDisplayBase<DocumentTypeSave, PropertyTypeBasic, DocumentTypeDisplay, PropertyTypeDisplay>(source, target, context.Mapper);
|
||||
MapTypeToDisplayBase<DocumentTypeSave, PropertyTypeBasic, DocumentTypeDisplay, PropertyTypeDisplay>(source, target, context);
|
||||
|
||||
//sync templates
|
||||
var destAllowedTemplateAliases = target.AllowedTemplates.Select(x => x.Alias);
|
||||
@@ -250,7 +250,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
{
|
||||
var template = templates.SingleOrDefault(t => t.Alias == x);
|
||||
return template != null
|
||||
? context.Mapper.Map<EntityBasic>(template)
|
||||
? context.Map<EntityBasic>(template)
|
||||
: null;
|
||||
})
|
||||
.WhereNotNull()
|
||||
@@ -263,7 +263,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
if (target.DefaultTemplate == null || source.DefaultTemplate != target.DefaultTemplate.Alias)
|
||||
{
|
||||
var template = _fileService.GetTemplate(source.DefaultTemplate);
|
||||
target.DefaultTemplate = template == null ? null : context.Mapper.Map<EntityBasic>(template);
|
||||
target.DefaultTemplate = template == null ? null : context.Map<EntityBasic>(template);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -275,13 +275,13 @@ namespace Umbraco.Web.Models.Mapping
|
||||
// no MapAll - take care
|
||||
private void Map(MediaTypeSave source, MediaTypeDisplay target, MapperContext context)
|
||||
{
|
||||
MapTypeToDisplayBase<MediaTypeSave, PropertyTypeBasic, MediaTypeDisplay, PropertyTypeDisplay>(source, target, context.Mapper);
|
||||
MapTypeToDisplayBase<MediaTypeSave, PropertyTypeBasic, MediaTypeDisplay, PropertyTypeDisplay>(source, target, context);
|
||||
}
|
||||
|
||||
// no MapAll - take care
|
||||
private void Map(MemberTypeSave source, MemberTypeDisplay target, MapperContext context)
|
||||
{
|
||||
MapTypeToDisplayBase<MemberTypeSave, MemberPropertyTypeBasic, MemberTypeDisplay, MemberPropertyTypeDisplay>(source, target, context.Mapper);
|
||||
MapTypeToDisplayBase<MemberTypeSave, MemberPropertyTypeBasic, MemberTypeDisplay, MemberPropertyTypeDisplay>(source, target, context);
|
||||
}
|
||||
|
||||
// Umbraco.Code.MapAll -CreateDate -UpdateDate -DeleteDate -Key -PropertyTypes
|
||||
@@ -312,7 +312,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
target.Name = source.Name;
|
||||
target.SortOrder = source.SortOrder;
|
||||
|
||||
target.Properties = source.Properties.Select(context.Mapper.Map<PropertyTypeDisplay>);
|
||||
target.Properties = source.Properties.Select(context.Map<PropertyTypeDisplay>);
|
||||
}
|
||||
|
||||
// Umbraco.Code.MapAll -ContentTypeId -ParentTabContentTypes -ParentTabContentTypeNames
|
||||
@@ -325,7 +325,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
target.Name = source.Name;
|
||||
target.SortOrder = source.SortOrder;
|
||||
|
||||
target.Properties = source.Properties.Select(context.Mapper.Map<MemberPropertyTypeDisplay>);
|
||||
target.Properties = source.Properties.Select(context.Map<MemberPropertyTypeDisplay>);
|
||||
}
|
||||
|
||||
// Umbraco.Code.MapAll -Editor -View -Config -ContentTypeId -ContentTypeName -Locked
|
||||
@@ -364,7 +364,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
// Umbraco.Code.MapAll -CreatorId -Level -SortOrder
|
||||
// Umbraco.Code.MapAll -CreateDate -UpdateDate -DeleteDate
|
||||
// Umbraco.Code.MapAll -ContentTypeComposition (done by AfterMapSaveToType)
|
||||
private static void MapSaveToTypeBase<TSource, TSourcePropertyType>(TSource source, IContentTypeComposition target, UmbracoMapper mapper)
|
||||
private static void MapSaveToTypeBase<TSource, TSourcePropertyType>(TSource source, IContentTypeComposition target, MapperContext context)
|
||||
where TSource : ContentTypeSave<TSourcePropertyType>
|
||||
where TSourcePropertyType : PropertyTypeBasic
|
||||
{
|
||||
@@ -420,12 +420,12 @@ namespace Umbraco.Web.Models.Mapping
|
||||
foreach (var sourceGroup in sourceGroups)
|
||||
{
|
||||
// get the dest group
|
||||
var destGroup = MapSaveGroup(sourceGroup, destOrigGroups, mapper);
|
||||
var destGroup = MapSaveGroup(sourceGroup, destOrigGroups, context);
|
||||
|
||||
// handle local properties
|
||||
var destProperties = sourceGroup.Properties
|
||||
.Where(x => x.Inherited == false)
|
||||
.Select(x => MapSaveProperty(x, destOrigProperties, mapper))
|
||||
.Select(x => MapSaveProperty(x, destOrigProperties, context))
|
||||
.ToArray();
|
||||
|
||||
// if the group has no local properties, skip it, ie sort-of garbage-collect
|
||||
@@ -453,7 +453,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
// handle local properties
|
||||
var destProperties = genericPropertiesGroup.Properties
|
||||
.Where(x => x.Inherited == false)
|
||||
.Select(x => MapSaveProperty(x, destOrigProperties, mapper))
|
||||
.Select(x => MapSaveProperty(x, destOrigProperties, context))
|
||||
.ToArray();
|
||||
|
||||
// ensure no duplicate alias, then assign the generic properties collection
|
||||
@@ -523,7 +523,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
}
|
||||
|
||||
// no MapAll - relies on the non-generic method
|
||||
private void MapTypeToDisplayBase<TSource, TSourcePropertyType, TTarget, TTargetPropertyType>(TSource source, TTarget target, UmbracoMapper mapper)
|
||||
private void MapTypeToDisplayBase<TSource, TSourcePropertyType, TTarget, TTargetPropertyType>(TSource source, TTarget target, MapperContext context)
|
||||
where TSource : ContentTypeSave<TSourcePropertyType>
|
||||
where TSourcePropertyType : PropertyTypeBasic
|
||||
where TTarget : ContentTypeCompositionDisplay<TTargetPropertyType>
|
||||
@@ -531,7 +531,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
{
|
||||
MapTypeToDisplayBase(source, target);
|
||||
|
||||
target.Groups = source.Groups.Select(mapper.Map<PropertyGroupDisplay<TTargetPropertyType>>);
|
||||
target.Groups = source.Groups.Select(context.Map<PropertyGroupDisplay<TTargetPropertyType>>);
|
||||
}
|
||||
|
||||
private IEnumerable<string> MapLockedCompositions(IContentTypeComposition source)
|
||||
@@ -580,7 +580,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
return Udi.Create(udiType, source.Key);
|
||||
}
|
||||
|
||||
private static PropertyGroup MapSaveGroup<TPropertyType>(PropertyGroupBasic<TPropertyType> sourceGroup, IEnumerable<PropertyGroup> destOrigGroups, UmbracoMapper mapper)
|
||||
private static PropertyGroup MapSaveGroup<TPropertyType>(PropertyGroupBasic<TPropertyType> sourceGroup, IEnumerable<PropertyGroup> destOrigGroups, MapperContext context)
|
||||
where TPropertyType : PropertyTypeBasic
|
||||
{
|
||||
PropertyGroup destGroup;
|
||||
@@ -591,7 +591,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
destGroup = destOrigGroups.FirstOrDefault(x => x.Id == sourceGroup.Id);
|
||||
if (destGroup != null)
|
||||
{
|
||||
mapper.Map(sourceGroup, destGroup);
|
||||
context.Map(sourceGroup, destGroup);
|
||||
return destGroup;
|
||||
}
|
||||
|
||||
@@ -602,11 +602,11 @@ namespace Umbraco.Web.Models.Mapping
|
||||
// insert a new group, or update an existing group that has
|
||||
// been deleted in the meantime and we need to re-create
|
||||
// map/create
|
||||
destGroup = mapper.Map<PropertyGroup>(sourceGroup);
|
||||
destGroup = context.Map<PropertyGroup>(sourceGroup);
|
||||
return destGroup;
|
||||
}
|
||||
|
||||
private static PropertyType MapSaveProperty(PropertyTypeBasic sourceProperty, IEnumerable<PropertyType> destOrigProperties, UmbracoMapper mapper)
|
||||
private static PropertyType MapSaveProperty(PropertyTypeBasic sourceProperty, IEnumerable<PropertyType> destOrigProperties, MapperContext context)
|
||||
{
|
||||
PropertyType destProperty;
|
||||
if (sourceProperty.Id > 0)
|
||||
@@ -616,7 +616,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
destProperty = destOrigProperties.FirstOrDefault(x => x.Id == sourceProperty.Id);
|
||||
if (destProperty != null)
|
||||
{
|
||||
mapper.Map(sourceProperty, destProperty);
|
||||
context.Map(sourceProperty, destProperty);
|
||||
return destProperty;
|
||||
}
|
||||
|
||||
@@ -627,7 +627,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
// insert a new property, or update an existing property that has
|
||||
// been deleted in the meantime and we need to re-create
|
||||
// map/create
|
||||
destProperty = mapper.Map<PropertyType>(sourceProperty);
|
||||
destProperty = context.Map<PropertyType>(sourceProperty);
|
||||
return destProperty;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,14 +25,14 @@ namespace Umbraco.Web.Models.Mapping
|
||||
if (!source.ContentType.VariesByCulture())
|
||||
{
|
||||
//this is invariant so just map the IContent instance to ContentVariationDisplay
|
||||
result.Add(context.Mapper.Map<ContentVariantDisplay>(source));
|
||||
result.Add(context.Map<ContentVariantDisplay>(source));
|
||||
}
|
||||
else
|
||||
{
|
||||
var allLanguages = _localizationService.GetAllLanguages().OrderBy(x => x.Id).ToList();
|
||||
if (allLanguages.Count == 0) return Enumerable.Empty<ContentVariantDisplay>(); //this should never happen
|
||||
|
||||
var langs = context.Mapper.Map<IEnumerable<Language>>(allLanguages, context).ToList();
|
||||
var langs = context.Map<IEnumerable<Language>>(allLanguages).ToList();
|
||||
|
||||
//create a variant for each language, then we'll populate the values
|
||||
var variants = langs.Select(x =>
|
||||
@@ -40,7 +40,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
//We need to set the culture in the mapping context since this is needed to ensure that the correct property values
|
||||
//are resolved during the mapping
|
||||
context.SetCulture(x.IsoCode);
|
||||
return context.Mapper.Map<ContentVariantDisplay>(source, context);
|
||||
return context.Map<ContentVariantDisplay>(source);
|
||||
}).ToList();
|
||||
|
||||
for (int i = 0; i < langs.Count; i++)
|
||||
|
||||
@@ -36,9 +36,9 @@ namespace Umbraco.Web.Models.Mapping
|
||||
mapper.Define<IDataEditor, DataTypeBasic>((source, context) => new DataTypeBasic(), Map);
|
||||
mapper.Define<IDataType, DataTypeBasic>((source, context) => new DataTypeBasic(), Map);
|
||||
mapper.Define<IDataType, DataTypeDisplay>((source, context) => new DataTypeDisplay(), Map);
|
||||
mapper.Define<IDataType, IEnumerable<DataTypeConfigurationFieldDisplay>>((source, context) => MapPreValues(source, mapper));
|
||||
mapper.Define<IDataType, IEnumerable<DataTypeConfigurationFieldDisplay>>(MapPreValues);
|
||||
mapper.Define<DataTypeSave, IDataType>((source, context) => new DataType(_propertyEditors[source.EditorAlias]) { CreateDate = DateTime.Now },Map);
|
||||
mapper.Define<IDataEditor, IEnumerable<DataTypeConfigurationFieldDisplay>>((source, context) => MapPreValues(source, mapper));
|
||||
mapper.Define<IDataEditor, IEnumerable<DataTypeConfigurationFieldDisplay>>(MapPreValues);
|
||||
}
|
||||
|
||||
// Umbraco.Code.MapAll
|
||||
@@ -93,14 +93,14 @@ namespace Umbraco.Web.Models.Mapping
|
||||
// Umbraco.Code.MapAll -HasPrevalues
|
||||
private void Map(IDataType source, DataTypeDisplay target, MapperContext context)
|
||||
{
|
||||
target.AvailableEditors = MapAvailableEditors(source, context.Mapper);
|
||||
target.AvailableEditors = MapAvailableEditors(source, context);
|
||||
target.Id = source.Id;
|
||||
target.IsSystemDataType = SystemIds.Contains(source.Id);
|
||||
target.Key = source.Key;
|
||||
target.Name = source.Name;
|
||||
target.ParentId = source.ParentId;
|
||||
target.Path = source.Path;
|
||||
target.PreValues = MapPreValues(source, context.Mapper);
|
||||
target.PreValues = MapPreValues(source, context);
|
||||
target.SelectedEditor = source.EditorAlias.IsNullOrWhiteSpace() ? null : source.EditorAlias;
|
||||
target.Trashed = source.Trashed;
|
||||
target.Udi = Udi.Create(Constants.UdiEntityType.DataType, source.Key);
|
||||
@@ -124,16 +124,16 @@ namespace Umbraco.Web.Models.Mapping
|
||||
target.ParentId = source.ParentId;
|
||||
}
|
||||
|
||||
private IEnumerable<PropertyEditorBasic> MapAvailableEditors(IDataType source, UmbracoMapper mapper)
|
||||
private IEnumerable<PropertyEditorBasic> MapAvailableEditors(IDataType source, MapperContext context)
|
||||
{
|
||||
var contentSection = Current.Configs.Settings().Content;
|
||||
return _propertyEditors
|
||||
.Where(x => !x.IsDeprecated || contentSection.ShowDeprecatedPropertyEditors || source.EditorAlias == x.Alias)
|
||||
.OrderBy(x => x.Name)
|
||||
.Select(mapper.Map<PropertyEditorBasic>);
|
||||
.Select(context.Map<PropertyEditorBasic>);
|
||||
}
|
||||
|
||||
private IEnumerable<DataTypeConfigurationFieldDisplay> MapPreValues(IDataType dataType, UmbracoMapper mapper)
|
||||
private IEnumerable<DataTypeConfigurationFieldDisplay> MapPreValues(IDataType dataType, MapperContext context)
|
||||
{
|
||||
// in v7 it was apparently fine to have an empty .EditorAlias here, in which case we would map onto
|
||||
// an empty fields list, which made no sense since there would be nothing to map to - and besides,
|
||||
@@ -143,7 +143,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
throw new InvalidOperationException($"Could not find a property editor with alias \"{dataType.EditorAlias}\".");
|
||||
|
||||
var configurationEditor = editor.GetConfigurationEditor();
|
||||
var fields = configurationEditor.Fields.Select(mapper.Map<DataTypeConfigurationFieldDisplay>).ToArray();
|
||||
var fields = configurationEditor.Fields.Select(context.Map<DataTypeConfigurationFieldDisplay>).ToArray();
|
||||
var configurationDictionary = configurationEditor.ToConfigurationEditor(dataType.Configuration);
|
||||
|
||||
MapConfigurationFields(fields, configurationDictionary);
|
||||
@@ -181,7 +181,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
return ValueTypes.ToStorageType(valueType);
|
||||
}
|
||||
|
||||
private IEnumerable<DataTypeConfigurationFieldDisplay> MapPreValues(IDataEditor source, UmbracoMapper mapper)
|
||||
private IEnumerable<DataTypeConfigurationFieldDisplay> MapPreValues(IDataEditor source, MapperContext context)
|
||||
{
|
||||
// this is a new data type, initialize default configuration
|
||||
// get the configuration editor,
|
||||
@@ -190,7 +190,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
|
||||
var configurationEditor = source.GetConfigurationEditor();
|
||||
|
||||
var fields = configurationEditor.Fields.Select(mapper.Map<DataTypeConfigurationFieldDisplay>).ToArray();
|
||||
var fields = configurationEditor.Fields.Select(context.Map<DataTypeConfigurationFieldDisplay>).ToArray();
|
||||
|
||||
var defaultConfiguration = configurationEditor.DefaultConfiguration;
|
||||
if (defaultConfiguration != null)
|
||||
|
||||
@@ -26,8 +26,8 @@ namespace Umbraco.Web.Models.Mapping
|
||||
mapper.Define<IContentTypeComposition, EntityBasic>((source, context) => new EntityBasic(), Map);
|
||||
mapper.Define<EntitySlim, SearchResultEntity>((source, context) => new SearchResultEntity(), Map);
|
||||
mapper.Define<ISearchResult, SearchResultEntity>((source, context) => new SearchResultEntity(), Map);
|
||||
mapper.Define<ISearchResults, IEnumerable<SearchResultEntity>>((source, context) => source.Select(context.Mapper.Map<SearchResultEntity>).ToList());
|
||||
mapper.Define<IEnumerable<ISearchResult>, IEnumerable<SearchResultEntity>>((source, context) => source.Select(context.Mapper.Map<SearchResultEntity>).ToList());
|
||||
mapper.Define<ISearchResults, IEnumerable<SearchResultEntity>>((source, context) => source.Select(context.Map<SearchResultEntity>).ToList());
|
||||
mapper.Define<IEnumerable<ISearchResult>, IEnumerable<SearchResultEntity>>((source, context) => source.Select(context.Map<SearchResultEntity>).ToList());
|
||||
}
|
||||
|
||||
// Umbraco.Code.MapAll -Alias
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
if (!(target is List<Language> list))
|
||||
throw new NotSupportedException($"{nameof(target)} must be a List<Language>.");
|
||||
|
||||
var temp = source.Select(context.Mapper.Map<ILanguage, Language>).ToList();
|
||||
var temp = source.Select(context.Map<ILanguage, Language>).ToList();
|
||||
|
||||
//Put the default language first in the list & then sort rest by a-z
|
||||
var defaultLang = temp.SingleOrDefault(x => x.IsDefault);
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
public void DefineMaps(UmbracoMapper mapper)
|
||||
{
|
||||
mapper.Define<IMacro, EntityBasic>((source, context) => new EntityBasic(), Map);
|
||||
mapper.Define<IMacro, IEnumerable<MacroParameter>>((source, context) => source.Properties.Values.Select(context.Mapper.Map<MacroParameter>).ToList());
|
||||
mapper.Define<IMacro, IEnumerable<MacroParameter>>((source, context) => source.Properties.Values.Select(context.Map<MacroParameter>).ToList());
|
||||
mapper.Define<IMacroProperty, MacroParameter>((source, context) => new MacroParameter(), Map);
|
||||
}
|
||||
|
||||
|
||||
@@ -42,14 +42,14 @@ namespace Umbraco.Web.Models.Mapping
|
||||
// Umbraco.Code.MapAll
|
||||
private static void Map(IMedia source, ContentPropertyCollectionDto target, MapperContext context)
|
||||
{
|
||||
target.Properties = source.Properties.Select(context.Mapper.Map<ContentPropertyDto>);
|
||||
target.Properties = source.Properties.Select(context.Map<ContentPropertyDto>);
|
||||
}
|
||||
|
||||
// Umbraco.Code.MapAll -Properties -Errors -Edited -Updater -Alias -IsContainer
|
||||
private void Map(IMedia source, MediaItemDisplay target, MapperContext context)
|
||||
{
|
||||
target.ContentApps = _commonMapper.GetContentApps(source);
|
||||
target.ContentType = _commonMapper.GetContentType(source, context.Mapper);
|
||||
target.ContentType = _commonMapper.GetContentType(source, context);
|
||||
target.ContentTypeAlias = source.ContentType.Alias;
|
||||
target.ContentTypeName = source.ContentType.Name;
|
||||
target.CreateDate = source.CreateDate;
|
||||
@@ -59,7 +59,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
target.Key = source.Key;
|
||||
target.MediaLink = string.Join(",", source.GetUrls(Current.Configs.Settings().Content, _logger));
|
||||
target.Name = source.Name;
|
||||
target.Owner = _commonMapper.GetOwner(source, context.Mapper);
|
||||
target.Owner = _commonMapper.GetOwner(source, context);
|
||||
target.ParentId = source.ParentId;
|
||||
target.Path = source.Path;
|
||||
target.SortOrder = source.SortOrder;
|
||||
@@ -81,10 +81,10 @@ namespace Umbraco.Web.Models.Mapping
|
||||
target.Id = source.Id;
|
||||
target.Key = source.Key;
|
||||
target.Name = source.Name;
|
||||
target.Owner = _commonMapper.GetOwner(source, context.Mapper);
|
||||
target.Owner = _commonMapper.GetOwner(source, context);
|
||||
target.ParentId = source.ParentId;
|
||||
target.Path = source.Path;
|
||||
target.Properties = source.Properties.Select(context.Mapper.Map<ContentPropertyBasic>);
|
||||
target.Properties = source.Properties.Select(context.Map<ContentPropertyBasic>);
|
||||
target.SortOrder = source.SortOrder;
|
||||
target.State = null;
|
||||
target.Trashed = source.Trashed;
|
||||
|
||||
@@ -45,9 +45,9 @@ namespace Umbraco.Web.Models.Mapping
|
||||
private void Map(MembershipUser source, MemberDisplay target, MapperContext context)
|
||||
{
|
||||
//first convert to IMember
|
||||
var member = context.Mapper.Map<IMember>(source);
|
||||
var member = context.Map<IMember>(source);
|
||||
//then convert to MemberDisplay
|
||||
context.Mapper.Map<IMember, MemberDisplay>(member);
|
||||
context.Map<IMember, MemberDisplay>(member);
|
||||
}
|
||||
|
||||
// TODO: SD: I can't remember why this mapping is here?
|
||||
@@ -86,7 +86,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
target.MemberProviderFieldMapping = GetMemberProviderFieldMapping();
|
||||
target.MembershipScenario = GetMembershipScenario();
|
||||
target.Name = source.Name;
|
||||
target.Owner = _commonMapper.GetOwner(source, context.Mapper);
|
||||
target.Owner = _commonMapper.GetOwner(source, context);
|
||||
target.ParentId = source.ParentId;
|
||||
target.Path = source.Path;
|
||||
target.SortOrder = source.SortOrder;
|
||||
@@ -108,10 +108,10 @@ namespace Umbraco.Web.Models.Mapping
|
||||
target.Id = int.MaxValue;
|
||||
target.Key = source.Key;
|
||||
target.Name = source.Name;
|
||||
target.Owner = _commonMapper.GetOwner(source, context.Mapper);
|
||||
target.Owner = _commonMapper.GetOwner(source, context);
|
||||
target.ParentId = source.ParentId;
|
||||
target.Path = source.Path;
|
||||
target.Properties = context.Mapper.Map<IEnumerable<ContentPropertyBasic>>(source.Properties);
|
||||
target.Properties = context.Map<IEnumerable<ContentPropertyBasic>>(source.Properties);
|
||||
target.SortOrder = source.SortOrder;
|
||||
target.State = null;
|
||||
target.Udi = Udi.Create(Constants.UdiEntityType.Member, source.Key);
|
||||
@@ -149,7 +149,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
// Umbraco.Code.MapAll
|
||||
private static void Map(IMember source, ContentPropertyCollectionDto target, MapperContext context)
|
||||
{
|
||||
target.Properties = source.Properties.Select(context.Mapper.Map<ContentPropertyDto>);
|
||||
target.Properties = source.Properties.Select(context.Map<ContentPropertyDto>);
|
||||
}
|
||||
|
||||
private MembershipScenario GetMembershipScenario()
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
{
|
||||
IgnoreProperties = ignoreProperties ?? throw new ArgumentNullException(nameof(ignoreProperties));
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns a collection of custom generic properties that exist on the generic properties tab
|
||||
/// </summary>
|
||||
@@ -105,8 +105,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
/// <returns></returns>
|
||||
protected virtual List<ContentPropertyDisplay> MapProperties(IContentBase content, List<Property> properties, MapperContext context)
|
||||
{
|
||||
// must pass the context through
|
||||
return properties.OrderBy(x => x.PropertyType.SortOrder).Select(x => context.Mapper.Map<ContentPropertyDisplay>(x, context)).ToList();
|
||||
return properties.OrderBy(x => x.PropertyType.SortOrder).Select(context.Map<ContentPropertyDisplay>).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -146,7 +146,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
target.Name = source.Name;
|
||||
target.ParentId = -1;
|
||||
target.Path = "-1," + source.Id;
|
||||
MapUserGroupBasic(target, source.AllowedSections, source.StartContentId, source.StartMediaId, context.Mapper);
|
||||
MapUserGroupBasic(target, source.AllowedSections, source.StartContentId, source.StartMediaId, context);
|
||||
}
|
||||
|
||||
// Umbraco.Code.MapAll -ContentStartNode -MediaStartNode -Sections -Notifications
|
||||
@@ -161,7 +161,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
target.ParentId = -1;
|
||||
target.Path = "-1," + source.Id;
|
||||
target.UserCount = source.UserCount;
|
||||
MapUserGroupBasic(target, source.AllowedSections, source.StartContentId, source.StartMediaId, context.Mapper);
|
||||
MapUserGroupBasic(target, source.AllowedSections, source.StartContentId, source.StartMediaId, context);
|
||||
}
|
||||
|
||||
// Umbraco.Code.MapAll -Udi -Trashed -AdditionalData -AssignedPermissions
|
||||
@@ -210,12 +210,12 @@ namespace Umbraco.Web.Models.Mapping
|
||||
target.Path = "-1," + source.Id;
|
||||
target.UserCount = source.UserCount;
|
||||
|
||||
MapUserGroupBasic(target, source.AllowedSections, source.StartContentId, source.StartMediaId, context.Mapper);
|
||||
MapUserGroupBasic(target, source.AllowedSections, source.StartContentId, source.StartMediaId, context);
|
||||
|
||||
//Important! Currently we are never mapping to multiple UserGroupDisplay objects but if we start doing that
|
||||
// this will cause an N+1 and we'll need to change how this works.
|
||||
var users = _userService.GetAllInGroup(source.Id);
|
||||
target.Users = context.Mapper.Map<IEnumerable<UserBasic>>(users);
|
||||
target.Users = context.Map<IEnumerable<UserBasic>>(users);
|
||||
|
||||
//Deal with assigned permissions:
|
||||
|
||||
@@ -244,7 +244,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
{
|
||||
var contentPermissions = allContentPermissions[entity.Id];
|
||||
|
||||
var assignedContentPermissions = context.Mapper.Map<AssignedContentPermissions>(entity);
|
||||
var assignedContentPermissions = context.Map<AssignedContentPermissions>(entity);
|
||||
assignedContentPermissions.AssignedPermissions = AssignedUserGroupPermissions.ClonePermissions(target.DefaultPermissions);
|
||||
|
||||
//since there is custom permissions assigned to this node for this group, we need to clear all of the default permissions
|
||||
@@ -267,8 +267,8 @@ namespace Umbraco.Web.Models.Mapping
|
||||
{
|
||||
target.AvailableCultures = _textService.GetSupportedCultures().ToDictionary(x => x.Name, x => x.DisplayName);
|
||||
target.Avatars = source.GetUserAvatarUrls(_appCaches.RuntimeCache);
|
||||
target.CalculatedStartContentIds = GetStartNodes(source.CalculateContentStartNodeIds(_entityService), UmbracoObjectTypes.Document, "content/contentRoot", context.Mapper);
|
||||
target.CalculatedStartMediaIds = GetStartNodes(source.CalculateMediaStartNodeIds(_entityService), UmbracoObjectTypes.Media, "media/mediaRoot", context.Mapper);
|
||||
target.CalculatedStartContentIds = GetStartNodes(source.CalculateContentStartNodeIds(_entityService), UmbracoObjectTypes.Document, "content/contentRoot", context);
|
||||
target.CalculatedStartMediaIds = GetStartNodes(source.CalculateMediaStartNodeIds(_entityService), UmbracoObjectTypes.Media, "media/mediaRoot", context);
|
||||
target.CreateDate = source.CreateDate;
|
||||
target.Culture = source.GetUserCulture(_textService, _globalSettings).ToString();
|
||||
target.Email = source.Email;
|
||||
@@ -283,10 +283,10 @@ namespace Umbraco.Web.Models.Mapping
|
||||
target.Navigation = CreateUserEditorNavigation();
|
||||
target.ParentId = -1;
|
||||
target.Path = "-1," + source.Id;
|
||||
target.StartContentIds = GetStartNodes(source.StartContentIds.ToArray(), UmbracoObjectTypes.Document, "content/contentRoot", context.Mapper);
|
||||
target.StartMediaIds = GetStartNodes(source.StartMediaIds.ToArray(), UmbracoObjectTypes.Media, "media/mediaRoot", context.Mapper);
|
||||
target.StartContentIds = GetStartNodes(source.StartContentIds.ToArray(), UmbracoObjectTypes.Document, "content/contentRoot", context);
|
||||
target.StartMediaIds = GetStartNodes(source.StartMediaIds.ToArray(), UmbracoObjectTypes.Media, "media/mediaRoot", context);
|
||||
target.UpdateDate = source.UpdateDate;
|
||||
target.UserGroups = source.Groups.Select(context.Mapper.Map<UserGroupBasic>);
|
||||
target.UserGroups = source.Groups.Select(context.Map<UserGroupBasic>);
|
||||
target.Username = source.Username;
|
||||
target.UserState = source.UserState;
|
||||
}
|
||||
@@ -307,7 +307,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
target.Name = source.Name;
|
||||
target.ParentId = -1;
|
||||
target.Path = "-1," + source.Id;
|
||||
target.UserGroups = source.Groups.Select(context.Mapper.Map<UserGroupBasic>);
|
||||
target.UserGroups = source.Groups.Select(context.Map<UserGroupBasic>);
|
||||
target.Username = source.Username;
|
||||
target.UserState = source.UserState;
|
||||
}
|
||||
@@ -333,18 +333,18 @@ namespace Umbraco.Web.Models.Mapping
|
||||
|
||||
// helpers
|
||||
|
||||
private void MapUserGroupBasic(UserGroupBasic target, IEnumerable<string> sourceAllowedSections, int? sourceStartContentId, int? sourceStartMediaId, UmbracoMapper mapper)
|
||||
private void MapUserGroupBasic(UserGroupBasic target, IEnumerable<string> sourceAllowedSections, int? sourceStartContentId, int? sourceStartMediaId, MapperContext context)
|
||||
{
|
||||
var allSections = _sectionService.GetSections();
|
||||
target.Sections = allSections.Where(x => sourceAllowedSections.Contains(x.Alias)).Select(mapper.Map<Section>);
|
||||
target.Sections = allSections.Where(x => sourceAllowedSections.Contains(x.Alias)).Select(context.Map<Section>);
|
||||
|
||||
if (sourceStartMediaId > 0)
|
||||
target.MediaStartNode = mapper.Map<EntityBasic>(_entityService.Get(sourceStartMediaId.Value, UmbracoObjectTypes.Media));
|
||||
target.MediaStartNode = context.Map<EntityBasic>(_entityService.Get(sourceStartMediaId.Value, UmbracoObjectTypes.Media));
|
||||
else if (sourceStartMediaId == -1)
|
||||
target.MediaStartNode = CreateRootNode(_textService.Localize("media/mediaRoot"));
|
||||
|
||||
if (sourceStartContentId > 0)
|
||||
target.ContentStartNode = mapper.Map<EntityBasic>(_entityService.Get(sourceStartContentId.Value, UmbracoObjectTypes.Document));
|
||||
target.ContentStartNode = context.Map<EntityBasic>(_entityService.Get(sourceStartContentId.Value, UmbracoObjectTypes.Document));
|
||||
else if (sourceStartContentId == -1)
|
||||
target.ContentStartNode = CreateRootNode(_textService.Localize("content/contentRoot"));
|
||||
|
||||
@@ -377,7 +377,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
private static string MapContentTypeIcon(EntitySlim entity)
|
||||
=> entity is ContentEntitySlim contentEntity ? contentEntity.ContentTypeIcon : null;
|
||||
|
||||
private IEnumerable<EntityBasic> GetStartNodes(int[] startNodeIds, UmbracoObjectTypes objectType, string localizedKey, UmbracoMapper mapper)
|
||||
private IEnumerable<EntityBasic> GetStartNodes(int[] startNodeIds, UmbracoObjectTypes objectType, string localizedKey, MapperContext context)
|
||||
{
|
||||
if (startNodeIds.Length <= 0)
|
||||
return Enumerable.Empty<EntityBasic>();
|
||||
@@ -387,7 +387,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
startNodes.Add(CreateRootNode(_textService.Localize(localizedKey)));
|
||||
|
||||
var mediaItems = _entityService.GetAll(objectType, startNodeIds);
|
||||
startNodes.AddRange(mapper.Map<IEnumerable<EntityBasic>>(mediaItems));
|
||||
startNodes.AddRange(context.Map<IEnumerable<EntityBasic>>(mediaItems));
|
||||
return startNodes;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user