U4-9935 UmbracoHelper doesn't have querying methods for handling UDI

This commit is contained in:
Shannon
2017-05-19 11:42:58 +10:00
parent 120cb964a5
commit 54967e0150
12 changed files with 256 additions and 140 deletions

View File

@@ -0,0 +1,23 @@
using System;
using Umbraco.Core;
using Umbraco.Core.Models;
namespace Umbraco.Web
{
public static class PublishedContentQueryExtensions
{
/// <summary>
/// Gets a content item from the cache
/// </summary>
/// <param name="contentQuery"></param>
/// <param name="id"></param>
/// <returns></returns>
public static IPublishedContent TypedContent(this ITypedPublishedContentQuery contentQuery, Udi id)
{
var guidUdi = id as GuidUdi;
if (guidUdi == null)
throw new InvalidOperationException("UDIs for content items must be " + typeof(GuidUdi));
return contentQuery.TypedContent(guidUdi.Guid);
}
}
}