Merge pull request #5246 from umbraco/v8/bugfix/5216-cache-getbyudi
Add GetById(Udi) to published caches
This commit is contained in:
@@ -238,6 +238,18 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
return GetNodePublishedContent(node, preview);
|
||||
}
|
||||
|
||||
public override IPublishedContent GetById(bool preview, Udi contentId)
|
||||
{
|
||||
var guidUdi = contentId as GuidUdi;
|
||||
if (guidUdi == null)
|
||||
throw new ArgumentException($"Udi must be of type {typeof(GuidUdi).Name}.", nameof(contentId));
|
||||
|
||||
if (guidUdi.EntityType != Constants.UdiEntityType.Document)
|
||||
throw new ArgumentException($"Udi entity type must be \"{Constants.UdiEntityType.Document}\".", nameof(contentId));
|
||||
|
||||
return GetById(preview, guidUdi.Guid);
|
||||
}
|
||||
|
||||
public override bool HasById(bool preview, int contentId)
|
||||
{
|
||||
var n = _snapshot.Get(contentId);
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Xml.XPath;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Cache;
|
||||
using Umbraco.Core.Models.PublishedContent;
|
||||
using Umbraco.Core.Xml;
|
||||
@@ -44,6 +45,20 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
return n?.PublishedModel;
|
||||
}
|
||||
|
||||
public override IPublishedContent GetById(bool preview, Udi contentId)
|
||||
{
|
||||
var guidUdi = contentId as GuidUdi;
|
||||
if (guidUdi == null)
|
||||
throw new ArgumentException($"Udi must be of type {typeof(GuidUdi).Name}.", nameof(contentId));
|
||||
|
||||
if (guidUdi.EntityType != Constants.UdiEntityType.Media)
|
||||
throw new ArgumentException($"Udi entity type must be \"{Constants.UdiEntityType.Media}\".", nameof(contentId));
|
||||
|
||||
// ignore preview, there's only draft for media
|
||||
var n = _snapshot.Get(guidUdi.Guid);
|
||||
return n?.PublishedModel;
|
||||
}
|
||||
|
||||
public override bool HasById(bool preview, int contentId)
|
||||
{
|
||||
var n = _snapshot.Get(contentId);
|
||||
|
||||
Reference in New Issue
Block a user