Changes api to GetData
This commit is contained in:
@@ -10,10 +10,9 @@ namespace Umbraco.Core.Models.Blocks
|
||||
[DataContract(Name = "blockListLayout", Namespace = "")]
|
||||
public class BlockListLayoutReference : IBlockElement<IPublishedElement>
|
||||
{
|
||||
public BlockListLayoutReference(Udi udi, IPublishedElement data, IPublishedElement settings)
|
||||
public BlockListLayoutReference(Udi udi, IPublishedElement settings)
|
||||
{
|
||||
Udi = udi ?? throw new ArgumentNullException(nameof(udi));
|
||||
Data = data ?? throw new ArgumentNullException(nameof(data));
|
||||
Settings = settings; // can be null
|
||||
}
|
||||
|
||||
@@ -29,13 +28,5 @@ namespace Umbraco.Core.Models.Blocks
|
||||
[DataMember(Name = "settings")]
|
||||
public IPublishedElement Settings { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The data item referenced
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This is ignored from serialization since it is just a reference to the actual data element
|
||||
/// </remarks>
|
||||
[IgnoreDataMember]
|
||||
public IPublishedElement Data { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using Umbraco.Core.Models.PublishedContent;
|
||||
|
||||
@@ -22,6 +23,17 @@ namespace Umbraco.Core.Models.Blocks
|
||||
[DataMember(Name = "layout")]
|
||||
public IEnumerable<BlockListLayoutReference> Layout { get; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns the data item associated with the layout udi reference
|
||||
/// </summary>
|
||||
/// <param name="udi"></param>
|
||||
/// <returns></returns>
|
||||
public IPublishedElement GetData(Udi udi)
|
||||
{
|
||||
if (!(udi is GuidUdi guidUdi))
|
||||
return null;
|
||||
return Data.FirstOrDefault(x => x.Key == guidUdi.Guid);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user