AB3329 - Added Content picker references

This commit is contained in:
Bjarke Berg
2019-10-28 13:57:55 +01:00
parent 35ebc13774
commit f2e02ea05e

View File

@@ -1,6 +1,7 @@
using System.Collections.Generic;
using Umbraco.Core;
using Umbraco.Core.Logging;
using Umbraco.Core.Models.Editors;
using Umbraco.Core.PropertyEditors;
namespace Umbraco.Web.PropertyEditors
@@ -25,5 +26,23 @@ namespace Umbraco.Web.PropertyEditors
{
return new ContentPickerConfigurationEditor();
}
protected override IDataValueEditor CreateValueEditor() => new ContentPickerPropertyValueEditor(Attribute);
internal class ContentPickerPropertyValueEditor : DataValueEditor, IDataValueReference
{
public ContentPickerPropertyValueEditor(DataEditorAttribute attribute) : base(attribute)
{
}
public IEnumerable<UmbracoEntityReference> GetReferences(object value)
{
if (value == null) yield break;
var asString = value is string str ? str : value.ToString();
yield return new UmbracoEntityReference(Udi.Parse(asString));
}
}
}
}