* Obsoletions related to Delivery API * Fix TypeLoader and TypeFinder tests * Remove obsolete and default implementations of IFileSource and IFileTypeCollection * More Delivery API related obsoletions * VariationContextAccessor related * ValueFactories obsoletion and fix references * ValueSetBuilders obsoletions * ValueConverters obsoletions * Other obsolete ctors and methods * Forgotten VariationContextAccessor obsoletion * More obsoletions * XPath related obsoletions * Revert XmlHelper changes * Delete RenamedRootNavigator and its tests * Fix test * XmlHelper obsoletion * Return null instead of GetXPathValue * Obsolete entire class instead * Remove XPath obsoletions from IPublishedCache * Remove XPath-related if-block that is no longer needed * Change obsolete msg for classes needed for NuCache * Moving classes to NuCache and making them internal * Remove more XPath-related obsoletions * Remove NavigableNavigator and its tests * Cleanup * Remove Xpath references from tests * Revert interface deletion in MediaCache * Using XOR operation Co-authored-by: Nuklon <Nuklon@users.noreply.github.com> --------- Co-authored-by: Nuklon <Nuklon@users.noreply.github.com>
75 lines
2.7 KiB
C#
75 lines
2.7 KiB
C#
using Microsoft.Extensions.DependencyInjection;
|
|
using Umbraco.Cms.Core.Models.PublishedContent;
|
|
using Umbraco.Extensions;
|
|
using StaticServiceProvider = Umbraco.Cms.Core.DependencyInjection.StaticServiceProvider;
|
|
|
|
namespace Umbraco.Cms.Core.PublishedCache;
|
|
|
|
public abstract class PublishedCacheBase : IPublishedCache
|
|
{
|
|
private readonly IVariationContextAccessor? _variationContextAccessor;
|
|
|
|
|
|
[Obsolete("Use ctor with all parameters. This will be removed in V15")]
|
|
public PublishedCacheBase(IVariationContextAccessor variationContextAccessor)
|
|
: this(variationContextAccessor, false)
|
|
{
|
|
}
|
|
|
|
[Obsolete("Use ctor with all parameters. This will be removed in V15")]
|
|
protected PublishedCacheBase(bool previewDefault)
|
|
: this(StaticServiceProvider.Instance.GetRequiredService<IVariationContextAccessor>(), previewDefault)
|
|
{
|
|
}
|
|
|
|
public PublishedCacheBase(IVariationContextAccessor variationContextAccessor, bool previewDefault)
|
|
{
|
|
_variationContextAccessor = variationContextAccessor;
|
|
PreviewDefault = previewDefault;
|
|
}
|
|
|
|
public bool PreviewDefault { get; }
|
|
|
|
public abstract IPublishedContent? GetById(bool preview, int contentId);
|
|
|
|
public IPublishedContent? GetById(int contentId)
|
|
=> GetById(PreviewDefault, contentId);
|
|
|
|
public abstract IPublishedContent? GetById(bool preview, Guid contentId);
|
|
|
|
public IPublishedContent? GetById(Guid contentId)
|
|
=> GetById(PreviewDefault, contentId);
|
|
|
|
public abstract IPublishedContent? GetById(bool preview, Udi contentId);
|
|
|
|
public IPublishedContent? GetById(Udi contentId)
|
|
=> GetById(PreviewDefault, contentId);
|
|
|
|
public abstract bool HasById(bool preview, int contentId);
|
|
|
|
public bool HasById(int contentId)
|
|
=> HasById(PreviewDefault, contentId);
|
|
|
|
public abstract IEnumerable<IPublishedContent> GetAtRoot(bool preview, string? culture = null);
|
|
|
|
public IEnumerable<IPublishedContent> GetAtRoot(string? culture = null) => GetAtRoot(PreviewDefault, culture);
|
|
|
|
public abstract bool HasContent(bool preview);
|
|
|
|
public bool HasContent() => HasContent(PreviewDefault);
|
|
|
|
public abstract IPublishedContentType? GetContentType(int id);
|
|
|
|
public abstract IPublishedContentType? GetContentType(string alias);
|
|
|
|
public abstract IPublishedContentType? GetContentType(Guid key);
|
|
|
|
public virtual IEnumerable<IPublishedContent> GetByContentType(IPublishedContentType contentType) =>
|
|
|
|
// this is probably not super-efficient, but works
|
|
// some cache implementation may want to override it, though
|
|
GetAtRoot()
|
|
.SelectMany(x => x.DescendantsOrSelf(_variationContextAccessor!))
|
|
.Where(x => x.ContentType.Id == contentType.Id);
|
|
}
|