U4-9935 UmbracoHelper doesn't have querying methods for handling UDI
This commit is contained in:
23
src/Umbraco.Web/PublishedContentQueryExtensions.cs
Normal file
23
src/Umbraco.Web/PublishedContentQueryExtensions.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user