Skip to content
This repository was archived by the owner on Jun 18, 2018. It is now read-only.

Commit cf57430

Browse files
authored
Merge pull request #110 from True-People/develop
Call the model factory to support typed models when used.
2 parents 886fbc5 + 506c26f commit cf57430

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/Our.Umbraco.NestedContent/Extensions/PublishedPropertyTypeExtensions.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,23 @@ public static object ConvertPropertyToNestedContent(this PublishedPropertyType p
9393
var pcr = UmbracoContext.Current.PublishedContentRequest;
9494
var containerNode = pcr != null && pcr.HasPublishedContent ? pcr.PublishedContent : null;
9595

96-
processedValue.Add(new DetachedPublishedContent(
96+
// Create the model based on our implementation of IPublishedContent
97+
IPublishedContent content = new DetachedPublishedContent(
9798
nameObj == null ? null : nameObj.ToString(),
9899
publishedContentType,
99100
properties.ToArray(),
100101
containerNode,
101102
i,
102-
preview));
103+
preview);
104+
105+
if (PublishedContentModelFactoryResolver.HasCurrent)
106+
{
107+
// Let the current model factory create a typed model to wrap our model
108+
content = PublishedContentModelFactoryResolver.Current.Factory.CreateModel(content);
109+
}
110+
111+
// Add the (typed) model as a result
112+
processedValue.Add(content);
103113
}
104114

105115
if (propertyType.IsSingleNestedContentProperty())

0 commit comments

Comments
 (0)