Ensure entities type in content caches GetById(Udi)
This commit is contained in:
@@ -106,11 +106,19 @@ namespace Umbraco.Web.PublishedCache
|
||||
{
|
||||
var guidUdi = contentId as GuidUdi;
|
||||
if (guidUdi == null)
|
||||
throw new InvalidOperationException("UDIs for content items must be " + typeof(GuidUdi));
|
||||
throw new ArgumentException($"Udi must be of type {typeof(GuidUdi).Name}.", nameof(contentId));
|
||||
|
||||
if (guidUdi.EntityType != UdiEntityType)
|
||||
throw new ArgumentException($"Udi entity type must be \"{UdiEntityType}\".", nameof(contentId));
|
||||
|
||||
return GetById(preview, guidUdi.Guid);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the entity type.
|
||||
/// </summary>
|
||||
protected abstract string UdiEntityType { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets content at root.
|
||||
/// </summary>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Web.PublishedCache.XmlPublishedCache;
|
||||
|
||||
@@ -21,6 +22,8 @@ namespace Umbraco.Web.PublishedCache
|
||||
: base(umbracoContext, cache)
|
||||
{ }
|
||||
|
||||
protected override string UdiEntityType => Constants.UdiEntityType.Document;
|
||||
|
||||
public override IPublishedContent GetById(bool preview, Guid contentKey)
|
||||
{
|
||||
if (InnerCache is PublishedContentCache cc)
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Web.PublishedCache.XmlPublishedCache;
|
||||
|
||||
@@ -21,6 +22,8 @@ namespace Umbraco.Web.PublishedCache
|
||||
: base(umbracoContext, cache)
|
||||
{ }
|
||||
|
||||
protected override string UdiEntityType => Constants.UdiEntityType.Media;
|
||||
|
||||
public override IPublishedContent GetById(bool preview, Guid contentKey)
|
||||
{
|
||||
if (InnerCache is PublishedMediaCache cc)
|
||||
|
||||
Reference in New Issue
Block a user