V15: Implement not-implemented methods for media cache (#17524)
* Implement not-implemented methods for media cache * Fixed test --------- Co-authored-by: Bjarke Berg <mail@bergmania.dk>
This commit is contained in:
@@ -14,11 +14,22 @@ public sealed class DocumentCache : IPublishedContentCache
|
||||
{
|
||||
private readonly IDocumentCacheService _documentCacheService;
|
||||
private readonly IPublishedContentTypeCache _publishedContentTypeCache;
|
||||
private readonly IDocumentNavigationQueryService _documentNavigationQueryService;
|
||||
private readonly IDocumentUrlService _documentUrlService;
|
||||
private readonly Lazy<IPublishedUrlProvider> _publishedUrlProvider;
|
||||
|
||||
public DocumentCache(IDocumentCacheService documentCacheService, IPublishedContentTypeCache publishedContentTypeCache)
|
||||
public DocumentCache(
|
||||
IDocumentCacheService documentCacheService,
|
||||
IPublishedContentTypeCache publishedContentTypeCache,
|
||||
IDocumentNavigationQueryService documentNavigationQueryService,
|
||||
IDocumentUrlService documentUrlService,
|
||||
Lazy<IPublishedUrlProvider> publishedUrlProvider)
|
||||
{
|
||||
_documentCacheService = documentCacheService;
|
||||
_publishedContentTypeCache = publishedContentTypeCache;
|
||||
_documentNavigationQueryService = documentNavigationQueryService;
|
||||
_documentUrlService = documentUrlService;
|
||||
_publishedUrlProvider = publishedUrlProvider;
|
||||
}
|
||||
|
||||
public async Task<IPublishedContent?> GetByIdAsync(int id, bool? preview = null) => await _documentCacheService.GetByIdAsync(id, preview);
|
||||
@@ -65,21 +76,17 @@ public sealed class DocumentCache : IPublishedContentCache
|
||||
return GetById(guidUdi.Guid);
|
||||
}
|
||||
|
||||
[Obsolete("Scheduled for removal, use IDocumentNavigationQueryService instead in v17")]
|
||||
public IEnumerable<IPublishedContent> GetAtRoot(bool preview, string? culture = null)
|
||||
{
|
||||
IDocumentNavigationQueryService navigationService = StaticServiceProvider.Instance.GetRequiredService<IDocumentNavigationQueryService>();
|
||||
navigationService.TryGetRootKeys(out IEnumerable<Guid> rootKeys);
|
||||
_documentNavigationQueryService.TryGetRootKeys(out IEnumerable<Guid> rootKeys);
|
||||
|
||||
IEnumerable<IPublishedContent> rootContent = rootKeys.Select(key => GetById(preview, key)).WhereNotNull();
|
||||
return culture is null ? rootContent : rootContent.Where(x => x.IsInvariantOrHasCulture(culture));
|
||||
}
|
||||
|
||||
[Obsolete("Scheduled for removal, use IDocumentNavigationQueryService instead in v17")]
|
||||
public IEnumerable<IPublishedContent> GetAtRoot(string? culture = null)
|
||||
{
|
||||
IDocumentNavigationQueryService navigationService = StaticServiceProvider.Instance.GetRequiredService<IDocumentNavigationQueryService>();
|
||||
navigationService.TryGetRootKeys(out IEnumerable<Guid> rootKeys);
|
||||
_documentNavigationQueryService.TryGetRootKeys(out IEnumerable<Guid> rootKeys);
|
||||
|
||||
IEnumerable<IPublishedContent> rootContent = rootKeys.Select(key => GetById(key)).WhereNotNull();
|
||||
return culture is null ? rootContent : rootContent.Where(x => x.IsInvariantOrHasCulture(culture));
|
||||
@@ -89,7 +96,7 @@ public sealed class DocumentCache : IPublishedContentCache
|
||||
public bool HasContent(bool preview) => HasContent();
|
||||
|
||||
[Obsolete("Scheduled for removal in v17")]
|
||||
public bool HasContent() => StaticServiceProvider.Instance.GetRequiredService<IDocumentUrlService>().HasAny();
|
||||
public bool HasContent() => _documentUrlService.HasAny();
|
||||
|
||||
[Obsolete]
|
||||
public IEnumerable<IPublishedContent> GetByContentType(IPublishedContentType contentType)
|
||||
@@ -98,26 +105,23 @@ public sealed class DocumentCache : IPublishedContentCache
|
||||
[Obsolete("Use IPublishedUrlProvider.GetUrl instead, scheduled for removal in v17")]
|
||||
public IPublishedContent? GetByRoute(bool preview, string route, bool? hideTopLevelNode = null, string? culture = null)
|
||||
{
|
||||
IDocumentUrlService documentUrlService = StaticServiceProvider.Instance.GetRequiredService<IDocumentUrlService>();
|
||||
Guid? key = documentUrlService.GetDocumentKeyByRoute(route, culture, null, preview);
|
||||
Guid? key = _documentUrlService.GetDocumentKeyByRoute(route, culture, null, preview);
|
||||
return key is not null ? GetById(preview, key.Value) : null;
|
||||
}
|
||||
|
||||
[Obsolete("Use IPublishedUrlProvider.GetUrl instead, scheduled for removal in v17")]
|
||||
public IPublishedContent? GetByRoute(string route, bool? hideTopLevelNode = null, string? culture = null)
|
||||
{
|
||||
IDocumentUrlService documentUrlService = StaticServiceProvider.Instance.GetRequiredService<IDocumentUrlService>();
|
||||
Guid? key = documentUrlService.GetDocumentKeyByRoute(route, culture, null, false);
|
||||
Guid? key = _documentUrlService.GetDocumentKeyByRoute(route, culture, null, false);
|
||||
return key is not null ? GetById(key.Value) : null;
|
||||
}
|
||||
|
||||
[Obsolete("Use IPublishedUrlProvider.GetUrl instead, scheduled for removal in v17")]
|
||||
public string? GetRouteById(bool preview, int contentId, string? culture = null)
|
||||
{
|
||||
IPublishedUrlProvider publishedUrlProvider = StaticServiceProvider.Instance.GetRequiredService<IPublishedUrlProvider>();
|
||||
IPublishedContent? content = GetById(preview, contentId);
|
||||
|
||||
return content is not null ? publishedUrlProvider.GetUrl(content, UrlMode.Relative, culture) : null;
|
||||
return content is not null ? _publishedUrlProvider.Value.GetUrl(content, UrlMode.Relative, culture) : null;
|
||||
}
|
||||
|
||||
[Obsolete("Use IPublishedUrlProvider.GetUrl instead, scheduled for removal in v17")]
|
||||
|
||||
Reference in New Issue
Block a user