Ensure that all items passed to rendering are element types

This commit is contained in:
Kenn Jacobsen
2019-01-16 13:05:54 +01:00
parent 93f991b140
commit 4303b4eb80
2 changed files with 9 additions and 1 deletions

View File

@@ -31,6 +31,8 @@ namespace Umbraco.Core.Models.PublishedContent
_propertyTypes = propertyTypes.ToArray(); _propertyTypes = propertyTypes.ToArray();
IsElement = contentType.IsElement;
InitializeIndexes(); InitializeIndexes();
} }
@@ -166,6 +168,11 @@ namespace Umbraco.Core.Models.PublishedContent
return index >= 0 && index < _propertyTypes.Length ? _propertyTypes[index] : null; return index >= 0 && index < _propertyTypes.Length ? _propertyTypes[index] : null;
} }
/// <summary>
/// Gets a value indicating whether this content type is for an element.
/// </summary>
public bool IsElement { get; }
#endregion #endregion
} }
} }

View File

@@ -45,8 +45,9 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters
if (string.IsNullOrEmpty(elementTypeAlias)) if (string.IsNullOrEmpty(elementTypeAlias))
return null; return null;
// only convert element types - content types will cause an exception when PublishedModelFactory creates the model
var publishedContentType = _publishedSnapshotAccessor.PublishedSnapshot.Content.GetContentType(elementTypeAlias); var publishedContentType = _publishedSnapshotAccessor.PublishedSnapshot.Content.GetContentType(elementTypeAlias);
if (publishedContentType == null) if (publishedContentType == null || publishedContentType.IsElement == false)
return null; return null;
var propertyValues = sourceObject.ToObject<Dictionary<string, object>>(); var propertyValues = sourceObject.ToObject<Dictionary<string, object>>();