2021-01-11 13:39:09 +11:00
|
|
|
using System.Collections.Generic;
|
2016-05-26 17:12:04 +02:00
|
|
|
using System.Linq;
|
2021-02-18 11:06:02 +01:00
|
|
|
using Umbraco.Cms.Core.PublishedCache;
|
|
|
|
|
using Umbraco.Cms.Core.Routing;
|
|
|
|
|
using Umbraco.Cms.Core.Services;
|
|
|
|
|
using Umbraco.Extensions;
|
2016-05-26 17:12:04 +02:00
|
|
|
|
2019-01-30 17:50:13 +11:00
|
|
|
namespace Umbraco.Tests.LegacyXmlPublishedCache
|
2016-05-26 17:12:04 +02:00
|
|
|
{
|
2018-04-24 13:07:18 +10:00
|
|
|
internal class DomainCache : IDomainCache
|
2016-05-26 17:12:04 +02:00
|
|
|
{
|
|
|
|
|
private readonly IDomainService _domainService;
|
|
|
|
|
|
2018-04-30 21:29:49 +02:00
|
|
|
public DomainCache(IDomainService domainService, IDefaultCultureAccessor defaultCultureAccessor)
|
2016-05-26 17:12:04 +02:00
|
|
|
{
|
|
|
|
|
_domainService = domainService;
|
2018-04-30 21:29:49 +02:00
|
|
|
DefaultCulture = defaultCultureAccessor.DefaultCulture;
|
2016-05-26 17:12:04 +02:00
|
|
|
}
|
|
|
|
|
|
2018-05-10 23:07:33 +10:00
|
|
|
/// <inheritdoc />
|
2021-01-11 13:39:09 +11:00
|
|
|
public IEnumerable<Domain> GetAll(bool includeWildcards) => _domainService.GetAll(includeWildcards)
|
2016-05-26 17:12:04 +02:00
|
|
|
.Where(x => x.RootContentId.HasValue && x.LanguageIsoCode.IsNullOrWhiteSpace() == false)
|
2021-01-11 13:39:09 +11:00
|
|
|
.Select(x => new Domain(x.Id, x.DomainName, x.RootContentId.Value, x.LanguageIsoCode, x.IsWildcard));
|
2016-05-26 17:12:04 +02:00
|
|
|
|
2018-05-10 23:07:33 +10:00
|
|
|
/// <inheritdoc />
|
2021-01-11 13:39:09 +11:00
|
|
|
public IEnumerable<Domain> GetAssigned(int documentId, bool includeWildcards = false) => _domainService.GetAssignedDomains(documentId, includeWildcards)
|
2016-05-26 17:12:04 +02:00
|
|
|
.Where(x => x.RootContentId.HasValue && x.LanguageIsoCode.IsNullOrWhiteSpace() == false)
|
2021-01-11 13:39:09 +11:00
|
|
|
.Select(x => new Domain(x.Id, x.DomainName, x.RootContentId.Value, x.LanguageIsoCode, x.IsWildcard));
|
2018-04-26 16:03:08 +02:00
|
|
|
|
2019-04-17 14:41:54 +02:00
|
|
|
/// <inheritdoc />
|
|
|
|
|
public bool HasAssigned(int documentId, bool includeWildcards = false)
|
|
|
|
|
=> documentId > 0 && GetAssigned(documentId, includeWildcards).Any();
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
2018-04-26 16:03:08 +02:00
|
|
|
public string DefaultCulture { get; }
|
2016-05-26 17:12:04 +02:00
|
|
|
}
|
|
|
|
|
}
|