Published status filtering (#18281)
* Initial refactor (pending more tests) * Fix structural querying across changing publish states + add tests accordingly * Add tests to validate ancestor and descendant order * Remove axis querying from published status filtering --------- Co-authored-by: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com>
This commit is contained in:
@@ -25,9 +25,6 @@ public static class FriendlyPublishedContentExtensions
|
||||
private static IPublishedContentCache PublishedContentCache { get; } =
|
||||
StaticServiceProvider.Instance.GetRequiredService<IPublishedContentCache>();
|
||||
|
||||
private static IPublishedMediaCache PublishedMediaCache { get; } =
|
||||
StaticServiceProvider.Instance.GetRequiredService<IPublishedMediaCache>();
|
||||
|
||||
private static IDocumentNavigationQueryService DocumentNavigationQueryService { get; } =
|
||||
StaticServiceProvider.Instance.GetRequiredService<IDocumentNavigationQueryService>();
|
||||
|
||||
@@ -70,9 +67,6 @@ public static class FriendlyPublishedContentExtensions
|
||||
private static IMemberTypeService MemberTypeService { get; } =
|
||||
StaticServiceProvider.Instance.GetRequiredService<IMemberTypeService>();
|
||||
|
||||
private static IPublishStatusQueryService PublishStatusQueryService { get; } =
|
||||
StaticServiceProvider.Instance.GetRequiredService<IPublishStatusQueryService>();
|
||||
|
||||
private static INavigationQueryService GetNavigationQueryService(IPublishedContent content)
|
||||
{
|
||||
switch (content.ContentType.ItemType)
|
||||
@@ -84,17 +78,16 @@ public static class FriendlyPublishedContentExtensions
|
||||
default:
|
||||
throw new NotSupportedException("Unsupported content type.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static IPublishedCache GetPublishedCache(IPublishedContent content)
|
||||
private static IPublishedStatusFilteringService GetPublishedStatusFilteringService(IPublishedContent content)
|
||||
{
|
||||
switch (content.ContentType.ItemType)
|
||||
{
|
||||
case PublishedItemType.Content:
|
||||
return PublishedContentCache;
|
||||
return StaticServiceProvider.Instance.GetRequiredService<IPublishedContentStatusFilteringService>();
|
||||
case PublishedItemType.Media:
|
||||
return PublishedMediaCache;
|
||||
return StaticServiceProvider.Instance.GetRequiredService<IPublishedMediaStatusFilteringService>();
|
||||
default:
|
||||
throw new NotSupportedException("Unsupported content type.");
|
||||
}
|
||||
@@ -246,7 +239,7 @@ public static class FriendlyPublishedContentExtensions
|
||||
/// set to 1.
|
||||
/// </remarks>
|
||||
public static IPublishedContent Root(this IPublishedContent content)
|
||||
=> content.Root(VariationContextAccessor, GetPublishedCache(content), GetNavigationQueryService(content), PublishStatusQueryService);
|
||||
=> content.Root(GetNavigationQueryService(content), GetPublishedStatusFilteringService(content));
|
||||
|
||||
/// <summary>
|
||||
/// Gets the root content (ancestor or self at level 1) for the specified <paramref name="content" /> if it's of the
|
||||
@@ -265,7 +258,7 @@ public static class FriendlyPublishedContentExtensions
|
||||
/// </remarks>
|
||||
public static T? Root<T>(this IPublishedContent content)
|
||||
where T : class, IPublishedContent
|
||||
=> content.Root<T>(VariationContextAccessor, GetPublishedCache(content), GetNavigationQueryService(content), PublishStatusQueryService);
|
||||
=> content.Root<T>(GetNavigationQueryService(content), GetPublishedStatusFilteringService(content));
|
||||
|
||||
/// <summary>
|
||||
/// Gets the parent of the content item.
|
||||
@@ -275,7 +268,7 @@ public static class FriendlyPublishedContentExtensions
|
||||
/// <returns>The parent of content of the specified content type or <c>null</c>.</returns>
|
||||
public static T? Parent<T>(this IPublishedContent content)
|
||||
where T : class, IPublishedContent
|
||||
=> content.Parent<T>(GetPublishedCache(content), GetNavigationQueryService(content));
|
||||
=> content.Parent<T>(GetNavigationQueryService(content), GetPublishedStatusFilteringService(content));
|
||||
|
||||
/// <summary>
|
||||
/// Gets the parent of the content item.
|
||||
@@ -283,7 +276,7 @@ public static class FriendlyPublishedContentExtensions
|
||||
/// <param name="content">The content.</param>
|
||||
/// <returns>The parent of content or <c>null</c>.</returns>
|
||||
public static IPublishedContent? Parent(this IPublishedContent content)
|
||||
=> content.Parent<IPublishedContent>(GetPublishedCache(content), GetNavigationQueryService(content));
|
||||
=> content.Parent<IPublishedContent>(GetNavigationQueryService(content), GetPublishedStatusFilteringService(content));
|
||||
|
||||
/// <summary>
|
||||
/// Gets the ancestors of the content.
|
||||
@@ -292,7 +285,7 @@ public static class FriendlyPublishedContentExtensions
|
||||
/// <returns>The ancestors of the content, in down-top order.</returns>
|
||||
/// <remarks>Does not consider the content itself.</remarks>
|
||||
public static IEnumerable<IPublishedContent> Ancestors(this IPublishedContent content)
|
||||
=> content.Ancestors(VariationContextAccessor, GetPublishedCache(content), GetNavigationQueryService(content), PublishStatusQueryService);
|
||||
=> content.Ancestors(GetNavigationQueryService(content), GetPublishedStatusFilteringService(content));
|
||||
|
||||
/// <summary>
|
||||
/// Gets the content and its ancestors.
|
||||
@@ -300,7 +293,7 @@ public static class FriendlyPublishedContentExtensions
|
||||
/// <param name="content">The content.</param>
|
||||
/// <returns>The content and its ancestors, in down-top order.</returns>
|
||||
public static IEnumerable<IPublishedContent> AncestorsOrSelf(this IPublishedContent content)
|
||||
=> content.AncestorsOrSelf(VariationContextAccessor, GetPublishedCache(content), GetNavigationQueryService(content), PublishStatusQueryService);
|
||||
=> content.AncestorsOrSelf(GetNavigationQueryService(content), GetPublishedStatusFilteringService(content));
|
||||
|
||||
/// <summary>
|
||||
/// Gets the content and its ancestors, of a specified content type.
|
||||
@@ -311,7 +304,7 @@ public static class FriendlyPublishedContentExtensions
|
||||
/// <remarks>May or may not begin with the content itself, depending on its content type.</remarks>
|
||||
public static IEnumerable<T> AncestorsOrSelf<T>(this IPublishedContent content)
|
||||
where T : class, IPublishedContent
|
||||
=> content.AncestorsOrSelf<T>(VariationContextAccessor, GetPublishedCache(content), GetNavigationQueryService(content), PublishStatusQueryService);
|
||||
=> content.AncestorsOrSelf<T>(GetNavigationQueryService(content), GetPublishedStatusFilteringService(content));
|
||||
|
||||
/// <summary>
|
||||
/// Gets the ancestor of the content, i.e. its parent.
|
||||
@@ -319,7 +312,7 @@ public static class FriendlyPublishedContentExtensions
|
||||
/// <param name="content">The content.</param>
|
||||
/// <returns>The ancestor of the content.</returns>
|
||||
public static IPublishedContent? Ancestor(this IPublishedContent content)
|
||||
=> content.Ancestor(GetPublishedCache(content), GetNavigationQueryService(content));
|
||||
=> content.Ancestor(GetNavigationQueryService(content), GetPublishedStatusFilteringService(content));
|
||||
|
||||
/// <summary>
|
||||
/// Gets the nearest ancestor of the content, of a specified content type.
|
||||
@@ -330,7 +323,7 @@ public static class FriendlyPublishedContentExtensions
|
||||
/// <remarks>Does not consider the content itself. May return <c>null</c>.</remarks>
|
||||
public static T? Ancestor<T>(this IPublishedContent content)
|
||||
where T : class, IPublishedContent
|
||||
=> content.Ancestor<T>(VariationContextAccessor, GetPublishedCache(content), GetNavigationQueryService(content), PublishStatusQueryService);
|
||||
=> content.Ancestor<T>(GetNavigationQueryService(content), GetPublishedStatusFilteringService(content));
|
||||
|
||||
/// <summary>
|
||||
/// Gets the content or its nearest ancestor, of a specified content type.
|
||||
@@ -341,7 +334,7 @@ public static class FriendlyPublishedContentExtensions
|
||||
/// <remarks>May or may not return the content itself depending on its content type. May return <c>null</c>.</remarks>
|
||||
public static T? AncestorOrSelf<T>(this IPublishedContent content)
|
||||
where T : class, IPublishedContent
|
||||
=> content.AncestorOrSelf<T>(VariationContextAccessor, GetPublishedCache(content), GetNavigationQueryService(content), PublishStatusQueryService);
|
||||
=> content.AncestorOrSelf<T>(GetNavigationQueryService(content), GetPublishedStatusFilteringService(content));
|
||||
|
||||
/// <summary>
|
||||
/// Returns all DescendantsOrSelf of all content referenced
|
||||
@@ -358,7 +351,19 @@ public static class FriendlyPublishedContentExtensions
|
||||
/// </remarks>
|
||||
public static IEnumerable<IPublishedContent> DescendantsOrSelfOfType(
|
||||
this IEnumerable<IPublishedContent> parentNodes, string docTypeAlias, string? culture = null)
|
||||
=> parentNodes.DescendantsOrSelfOfType(VariationContextAccessor, GetPublishedCache(parentNodes.First()), GetNavigationQueryService(parentNodes.First()), PublishStatusQueryService, docTypeAlias, culture);
|
||||
{
|
||||
IPublishedContent[] parentNodesAsArray = parentNodes as IPublishedContent[] ?? parentNodes.ToArray();
|
||||
if (parentNodesAsArray.Length == 0)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
return parentNodesAsArray.DescendantsOrSelfOfType(
|
||||
GetNavigationQueryService(parentNodesAsArray.First()),
|
||||
GetPublishedStatusFilteringService(parentNodesAsArray.First()),
|
||||
docTypeAlias,
|
||||
culture);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns all DescendantsOrSelf of all content referenced
|
||||
@@ -376,77 +381,88 @@ public static class FriendlyPublishedContentExtensions
|
||||
this IEnumerable<IPublishedContent> parentNodes,
|
||||
string? culture = null)
|
||||
where T : class, IPublishedContent
|
||||
=> parentNodes.DescendantsOrSelf<T>(VariationContextAccessor, GetPublishedCache(parentNodes.First()), GetNavigationQueryService(parentNodes.First()), PublishStatusQueryService, culture);
|
||||
{
|
||||
IPublishedContent[] parentNodesAsArray = parentNodes as IPublishedContent[] ?? parentNodes.ToArray();
|
||||
if (parentNodesAsArray.Length == 0)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
return parentNodesAsArray.DescendantsOrSelf<T>(
|
||||
GetNavigationQueryService(parentNodesAsArray.First()),
|
||||
GetPublishedStatusFilteringService(parentNodesAsArray.First()),
|
||||
culture);
|
||||
}
|
||||
|
||||
public static IEnumerable<IPublishedContent> Descendants(this IPublishedContent content, string? culture = null)
|
||||
=> content.Descendants(VariationContextAccessor, GetPublishedCache(content), GetNavigationQueryService(content), PublishStatusQueryService, culture);
|
||||
=> content.Descendants(GetNavigationQueryService(content), GetPublishedStatusFilteringService(content), culture);
|
||||
|
||||
public static IEnumerable<IPublishedContent> Descendants(this IPublishedContent content, int level, string? culture = null)
|
||||
=> content.Descendants(VariationContextAccessor, GetPublishedCache(content), GetNavigationQueryService(content), PublishStatusQueryService, level, culture);
|
||||
=> content.Descendants(GetNavigationQueryService(content), GetPublishedStatusFilteringService(content), level, culture);
|
||||
|
||||
public static IEnumerable<IPublishedContent> DescendantsOfType(this IPublishedContent content, string contentTypeAlias, string? culture = null)
|
||||
=> content.DescendantsOfType(VariationContextAccessor, GetPublishedCache(content), GetNavigationQueryService(content), PublishStatusQueryService, contentTypeAlias, culture);
|
||||
=> content.DescendantsOfType(GetNavigationQueryService(content), GetPublishedStatusFilteringService(content), contentTypeAlias, culture);
|
||||
|
||||
public static IEnumerable<T> Descendants<T>(this IPublishedContent content, string? culture = null)
|
||||
where T : class, IPublishedContent
|
||||
=> content.Descendants<T>(VariationContextAccessor, GetPublishedCache(content), GetNavigationQueryService(content), PublishStatusQueryService, culture);
|
||||
=> content.Descendants<T>(GetNavigationQueryService(content), GetPublishedStatusFilteringService(content), culture);
|
||||
|
||||
public static IEnumerable<T> Descendants<T>(this IPublishedContent content, int level, string? culture = null)
|
||||
where T : class, IPublishedContent
|
||||
=> content.Descendants<T>(VariationContextAccessor, GetPublishedCache(content), GetNavigationQueryService(content), PublishStatusQueryService, level, culture);
|
||||
=> content.Descendants<T>(GetNavigationQueryService(content), GetPublishedStatusFilteringService(content), level, culture);
|
||||
|
||||
public static IEnumerable<IPublishedContent> DescendantsOrSelf(
|
||||
this IPublishedContent content,
|
||||
string? culture = null)
|
||||
=> content.DescendantsOrSelf(VariationContextAccessor, GetPublishedCache(content), GetNavigationQueryService(content), PublishStatusQueryService, culture);
|
||||
=> content.DescendantsOrSelf(GetNavigationQueryService(content), GetPublishedStatusFilteringService(content), culture);
|
||||
|
||||
public static IEnumerable<IPublishedContent> DescendantsOrSelf(this IPublishedContent content, int level, string? culture = null)
|
||||
=> content.DescendantsOrSelf(VariationContextAccessor, GetPublishedCache(content), GetNavigationQueryService(content), PublishStatusQueryService, level, culture);
|
||||
=> content.DescendantsOrSelf(GetNavigationQueryService(content), GetPublishedStatusFilteringService(content), level, culture);
|
||||
|
||||
public static IEnumerable<IPublishedContent> DescendantsOrSelfOfType(this IPublishedContent content, string contentTypeAlias, string? culture = null)
|
||||
=> content.DescendantsOrSelfOfType(VariationContextAccessor, GetPublishedCache(content), GetNavigationQueryService(content), PublishStatusQueryService, contentTypeAlias, culture);
|
||||
=> content.DescendantsOrSelfOfType(GetNavigationQueryService(content), GetPublishedStatusFilteringService(content), contentTypeAlias, culture);
|
||||
|
||||
public static IEnumerable<T> DescendantsOrSelf<T>(this IPublishedContent content, string? culture = null)
|
||||
where T : class, IPublishedContent
|
||||
=> content.DescendantsOrSelf<T>(VariationContextAccessor, GetPublishedCache(content), GetNavigationQueryService(content), PublishStatusQueryService, culture);
|
||||
=> content.DescendantsOrSelf<T>(GetNavigationQueryService(content), GetPublishedStatusFilteringService(content), culture);
|
||||
|
||||
public static IEnumerable<T> DescendantsOrSelf<T>(this IPublishedContent content, int level, string? culture = null)
|
||||
where T : class, IPublishedContent
|
||||
=> content.DescendantsOrSelf<T>(VariationContextAccessor, GetPublishedCache(content), GetNavigationQueryService(content), PublishStatusQueryService, level, culture);
|
||||
=> content.DescendantsOrSelf<T>(GetNavigationQueryService(content), GetPublishedStatusFilteringService(content), level, culture);
|
||||
|
||||
public static IPublishedContent? Descendant(this IPublishedContent content, string? culture = null)
|
||||
=> content.Descendant(VariationContextAccessor, GetPublishedCache(content), GetNavigationQueryService(content), PublishStatusQueryService, culture);
|
||||
=> content.Descendant(GetNavigationQueryService(content), GetPublishedStatusFilteringService(content), culture);
|
||||
|
||||
public static IPublishedContent? Descendant(this IPublishedContent content, int level, string? culture = null)
|
||||
=> content.Descendant(VariationContextAccessor, GetPublishedCache(content), GetNavigationQueryService(content), PublishStatusQueryService, level, culture);
|
||||
=> content.Descendant(GetNavigationQueryService(content), GetPublishedStatusFilteringService(content), level, culture);
|
||||
|
||||
public static IPublishedContent? DescendantOfType(this IPublishedContent content, string contentTypeAlias, string? culture = null)
|
||||
=> content.DescendantOfType(VariationContextAccessor, GetPublishedCache(content), GetNavigationQueryService(content), PublishStatusQueryService, contentTypeAlias, culture);
|
||||
=> content.DescendantOfType(GetNavigationQueryService(content), GetPublishedStatusFilteringService(content), contentTypeAlias, culture);
|
||||
|
||||
public static T? Descendant<T>(this IPublishedContent content, string? culture = null)
|
||||
where T : class, IPublishedContent
|
||||
=> content.Descendant<T>(VariationContextAccessor, GetPublishedCache(content), GetNavigationQueryService(content), PublishStatusQueryService, culture);
|
||||
=> content.Descendant<T>(GetNavigationQueryService(content), GetPublishedStatusFilteringService(content), culture);
|
||||
|
||||
public static T? Descendant<T>(this IPublishedContent content, int level, string? culture = null)
|
||||
where T : class, IPublishedContent
|
||||
=> content.Descendant<T>(VariationContextAccessor, GetPublishedCache(content), GetNavigationQueryService(content), PublishStatusQueryService, level, culture);
|
||||
=> content.Descendant<T>(GetNavigationQueryService(content), GetPublishedStatusFilteringService(content), level, culture);
|
||||
|
||||
public static IPublishedContent DescendantOrSelf(this IPublishedContent content, string? culture = null)
|
||||
=> content.DescendantOrSelf(VariationContextAccessor, PublishStatusQueryService, culture);
|
||||
=> content.DescendantOrSelf(GetNavigationQueryService(content), GetPublishedStatusFilteringService(content), culture);
|
||||
|
||||
public static IPublishedContent? DescendantOrSelf(this IPublishedContent content, int level, string? culture = null)
|
||||
=> content.DescendantOrSelf(VariationContextAccessor, GetPublishedCache(content), GetNavigationQueryService(content), PublishStatusQueryService, level, culture);
|
||||
=> content.DescendantOrSelf(GetNavigationQueryService(content), GetPublishedStatusFilteringService(content), level, culture);
|
||||
|
||||
public static IPublishedContent? DescendantOrSelfOfType(this IPublishedContent content, string contentTypeAlias, string? culture = null)
|
||||
=> content.DescendantOrSelfOfType(VariationContextAccessor, GetPublishedCache(content), GetNavigationQueryService(content), PublishStatusQueryService, contentTypeAlias, culture);
|
||||
=> content.DescendantOrSelfOfType(GetNavigationQueryService(content), GetPublishedStatusFilteringService(content), contentTypeAlias, culture);
|
||||
|
||||
public static T? DescendantOrSelf<T>(this IPublishedContent content, string? culture = null)
|
||||
where T : class, IPublishedContent
|
||||
=> content.DescendantOrSelf<T>(VariationContextAccessor, GetPublishedCache(content), GetNavigationQueryService(content), PublishStatusQueryService, culture);
|
||||
=> content.DescendantOrSelf<T>(GetNavigationQueryService(content), GetPublishedStatusFilteringService(content), culture);
|
||||
|
||||
public static T? DescendantOrSelf<T>(this IPublishedContent content, int level, string? culture = null)
|
||||
where T : class, IPublishedContent
|
||||
=> content.DescendantOrSelf<T>(VariationContextAccessor, GetPublishedCache(content), GetNavigationQueryService(content), PublishStatusQueryService, level, culture);
|
||||
=> content.DescendantOrSelf<T>(GetNavigationQueryService(content), GetPublishedStatusFilteringService(content), level, culture);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the children of the content item.
|
||||
@@ -474,7 +490,7 @@ public static class FriendlyPublishedContentExtensions
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
public static IEnumerable<IPublishedContent> Children(this IPublishedContent content, string? culture = null)
|
||||
=> content.Children(VariationContextAccessor, GetPublishedCache(content), GetNavigationQueryService(content), PublishStatusQueryService, culture);
|
||||
=> content.Children(GetNavigationQueryService(content), GetPublishedStatusFilteringService(content), culture);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the children of the content, filtered by a predicate.
|
||||
@@ -493,7 +509,7 @@ public static class FriendlyPublishedContentExtensions
|
||||
this IPublishedContent content,
|
||||
Func<IPublishedContent, bool> predicate,
|
||||
string? culture = null)
|
||||
=> content.Children(VariationContextAccessor, GetPublishedCache(content), GetNavigationQueryService(content), PublishStatusQueryService, predicate, culture);
|
||||
=> content.Children(GetNavigationQueryService(content), GetPublishedStatusFilteringService(content), predicate, culture);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the children of the content, of any of the specified types.
|
||||
@@ -506,7 +522,7 @@ public static class FriendlyPublishedContentExtensions
|
||||
/// <param name="contentTypeAlias">The content type alias.</param>
|
||||
/// <returns>The children of the content, of any of the specified types.</returns>
|
||||
public static IEnumerable<IPublishedContent>? ChildrenOfType(this IPublishedContent content, string contentTypeAlias, string? culture = null)
|
||||
=> content.ChildrenOfType(VariationContextAccessor, GetPublishedCache(content), GetNavigationQueryService(content), PublishStatusQueryService, contentTypeAlias, culture);
|
||||
=> content.ChildrenOfType(GetNavigationQueryService(content), GetPublishedStatusFilteringService(content), contentTypeAlias, culture);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the children of the content, of a given content type.
|
||||
@@ -523,30 +539,30 @@ public static class FriendlyPublishedContentExtensions
|
||||
/// </remarks>
|
||||
public static IEnumerable<T>? Children<T>(this IPublishedContent content, string? culture = null)
|
||||
where T : class, IPublishedContent
|
||||
=> content.Children<T>(VariationContextAccessor, GetPublishedCache(content), GetNavigationQueryService(content), PublishStatusQueryService, culture);
|
||||
=> content.Children<T>(GetNavigationQueryService(content), GetPublishedStatusFilteringService(content), culture);
|
||||
|
||||
public static IPublishedContent? FirstChild(this IPublishedContent content, string? culture = null)
|
||||
=> content.FirstChild(VariationContextAccessor, GetPublishedCache(content), GetNavigationQueryService(content), PublishStatusQueryService, culture);
|
||||
=> content.FirstChild(GetNavigationQueryService(content), GetPublishedStatusFilteringService(content), culture);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the first child of the content, of a given content type.
|
||||
/// </summary>
|
||||
public static IPublishedContent? FirstChildOfType(this IPublishedContent content, string contentTypeAlias, string? culture = null)
|
||||
=> content.FirstChildOfType(VariationContextAccessor, GetPublishedCache(content), GetNavigationQueryService(content), PublishStatusQueryService, contentTypeAlias, culture);
|
||||
=> content.FirstChildOfType(GetNavigationQueryService(content), GetPublishedStatusFilteringService(content), contentTypeAlias, culture);
|
||||
|
||||
public static IPublishedContent? FirstChild(this IPublishedContent content, Func<IPublishedContent, bool> predicate, string? culture = null)
|
||||
=> content.FirstChild(VariationContextAccessor, GetPublishedCache(content), GetNavigationQueryService(content), PublishStatusQueryService, predicate, culture);
|
||||
=> content.FirstChild(GetNavigationQueryService(content), GetPublishedStatusFilteringService(content), predicate, culture);
|
||||
|
||||
public static IPublishedContent? FirstChild(this IPublishedContent content, Guid uniqueId, string? culture = null)
|
||||
=> content.FirstChild(VariationContextAccessor, GetPublishedCache(content), GetNavigationQueryService(content), PublishStatusQueryService, uniqueId, culture);
|
||||
=> content.FirstChild(GetNavigationQueryService(content), GetPublishedStatusFilteringService(content), uniqueId, culture);
|
||||
|
||||
public static T? FirstChild<T>(this IPublishedContent content, string? culture = null)
|
||||
where T : class, IPublishedContent
|
||||
=> content.FirstChild<T>(VariationContextAccessor, GetPublishedCache(content), GetNavigationQueryService(content), PublishStatusQueryService, culture);
|
||||
=> content.FirstChild<T>(GetNavigationQueryService(content), GetPublishedStatusFilteringService(content), culture);
|
||||
|
||||
public static T? FirstChild<T>(this IPublishedContent content, Func<T, bool> predicate, string? culture = null)
|
||||
where T : class, IPublishedContent
|
||||
=> content.FirstChild(VariationContextAccessor, GetPublishedCache(content), GetNavigationQueryService(content), PublishStatusQueryService, predicate, culture);
|
||||
=> content.FirstChild(GetNavigationQueryService(content), GetPublishedStatusFilteringService(content), predicate, culture);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the siblings of the content.
|
||||
@@ -561,7 +577,7 @@ public static class FriendlyPublishedContentExtensions
|
||||
/// <para>Note that in V7 this method also return the content node self.</para>
|
||||
/// </remarks>
|
||||
public static IEnumerable<IPublishedContent>? Siblings(this IPublishedContent content, string? culture = null)
|
||||
=> content.Siblings(GetPublishedCache(content), GetNavigationQueryService(content), VariationContextAccessor, PublishStatusQueryService, culture);
|
||||
=> content.Siblings(GetNavigationQueryService(content), GetPublishedStatusFilteringService(content), culture);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the siblings of the content, of a given content type.
|
||||
@@ -577,7 +593,7 @@ public static class FriendlyPublishedContentExtensions
|
||||
/// <para>Note that in V7 this method also return the content node self.</para>
|
||||
/// </remarks>
|
||||
public static IEnumerable<IPublishedContent>? SiblingsOfType(this IPublishedContent content, string contentTypeAlias, string? culture = null)
|
||||
=> content.SiblingsOfType(VariationContextAccessor, GetPublishedCache(content), GetNavigationQueryService(content), PublishStatusQueryService, contentTypeAlias, culture);
|
||||
=> content.SiblingsOfType(GetNavigationQueryService(content), GetPublishedStatusFilteringService(content), contentTypeAlias, culture);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the siblings of the content, of a given content type.
|
||||
@@ -594,7 +610,7 @@ public static class FriendlyPublishedContentExtensions
|
||||
/// </remarks>
|
||||
public static IEnumerable<T>? Siblings<T>(this IPublishedContent content, string? culture = null)
|
||||
where T : class, IPublishedContent
|
||||
=> content.Siblings<T>(VariationContextAccessor, GetPublishedCache(content), GetNavigationQueryService(content), PublishStatusQueryService, culture);
|
||||
=> content.Siblings<T>(GetNavigationQueryService(content), GetPublishedStatusFilteringService(content), culture);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the siblings of the content including the node itself to indicate the position.
|
||||
@@ -608,7 +624,7 @@ public static class FriendlyPublishedContentExtensions
|
||||
public static IEnumerable<IPublishedContent>? SiblingsAndSelf(
|
||||
this IPublishedContent content,
|
||||
string? culture = null)
|
||||
=> content.SiblingsAndSelf(GetPublishedCache(content), GetNavigationQueryService(content), VariationContextAccessor, PublishStatusQueryService, culture);
|
||||
=> content.SiblingsAndSelf(GetNavigationQueryService(content), GetPublishedStatusFilteringService(content), culture);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the siblings of the content including the node itself to indicate the position, of a given content type.
|
||||
@@ -624,7 +640,7 @@ public static class FriendlyPublishedContentExtensions
|
||||
this IPublishedContent content,
|
||||
string contentTypeAlias,
|
||||
string? culture = null)
|
||||
=> content.SiblingsAndSelfOfType(VariationContextAccessor, GetPublishedCache(content), GetNavigationQueryService(content), PublishStatusQueryService, contentTypeAlias, culture);
|
||||
=> content.SiblingsAndSelfOfType(GetNavigationQueryService(content), GetPublishedStatusFilteringService(content), contentTypeAlias, culture);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the siblings of the content including the node itself to indicate the position, of a given content type.
|
||||
@@ -638,7 +654,7 @@ public static class FriendlyPublishedContentExtensions
|
||||
/// <returns>The siblings of the content including the node itself, of the given content type.</returns>
|
||||
public static IEnumerable<T>? SiblingsAndSelf<T>(this IPublishedContent content, string? culture = null)
|
||||
where T : class, IPublishedContent
|
||||
=> content.SiblingsAndSelf<T>(VariationContextAccessor, GetPublishedCache(content), GetNavigationQueryService(content), PublishStatusQueryService, culture);
|
||||
=> content.SiblingsAndSelf<T>(GetNavigationQueryService(content), GetPublishedStatusFilteringService(content), culture);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the url of the content item.
|
||||
@@ -671,17 +687,15 @@ public static class FriendlyPublishedContentExtensions
|
||||
/// <returns>The children of the content.</returns>
|
||||
[Obsolete("This method is no longer used in Umbraco. The method will be removed in Umbraco 17.")]
|
||||
public static DataTable ChildrenAsTable(this IPublishedContent content, string contentTypeAliasFilter = "", string? culture = null)
|
||||
=>
|
||||
content.ChildrenAsTable(
|
||||
VariationContextAccessor,
|
||||
GetPublishedCache(content),
|
||||
GetNavigationQueryService(content),
|
||||
ContentTypeService,
|
||||
MediaTypeService,
|
||||
MemberTypeService,
|
||||
PublishedUrlProvider,
|
||||
contentTypeAliasFilter,
|
||||
culture);
|
||||
=> content.ChildrenAsTable(
|
||||
GetNavigationQueryService(content),
|
||||
GetPublishedStatusFilteringService(content),
|
||||
ContentTypeService,
|
||||
MediaTypeService,
|
||||
MemberTypeService,
|
||||
PublishedUrlProvider,
|
||||
contentTypeAliasFilter,
|
||||
culture);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the url for a media.
|
||||
|
||||
@@ -17,22 +17,7 @@ public static class PublishedContentExtensions
|
||||
{
|
||||
#region Variations
|
||||
|
||||
/// <summary>
|
||||
/// Gets the culture assigned to a document by domains, in the context of a current Uri.
|
||||
/// </summary>
|
||||
/// <param name="content">The document.</param>
|
||||
/// <param name="umbracoContextAccessor"></param>
|
||||
/// <param name="siteDomainHelper">The site domain helper.</param>
|
||||
/// <param name="current">An optional current Uri.</param>
|
||||
/// <returns>The culture assigned to the document by domains.</returns>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// In 1:1 multilingual setup, a document contains several cultures (there is not
|
||||
/// one document per culture), and domains, withing the context of a current Uri, assign
|
||||
/// a culture to that document.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
[Obsolete("Please use the method taking all parameters. This overload will be removed in V17.")]
|
||||
[Obsolete("Use the overload with IPublishedStatusFilteringService, scheduled for removal in v17")]
|
||||
public static string? GetCultureFromDomains(
|
||||
this IPublishedContent content,
|
||||
IUmbracoContextAccessor umbracoContextAccessor,
|
||||
@@ -43,6 +28,19 @@ public static class PublishedContentExtensions
|
||||
return DomainUtilities.GetCultureFromDomains(content.Id, content.Path, current, umbracoContext, siteDomainHelper);
|
||||
}
|
||||
|
||||
public static string? GetCultureFromDomains(
|
||||
this IPublishedContent content,
|
||||
IUmbracoContextAccessor umbracoContextAccessor,
|
||||
ISiteDomainMapper siteDomainHelper,
|
||||
IDomainCache domainCache,
|
||||
IPublishedCache publishedCache,
|
||||
INavigationQueryService navigationQueryService,
|
||||
Uri? current = null)
|
||||
{
|
||||
IUmbracoContext umbracoContext = umbracoContextAccessor.GetRequiredUmbracoContext();
|
||||
return DomainUtilities.GetCultureFromDomains(content.Id, content.Path, current, umbracoContext, siteDomainHelper, domainCache, publishedCache, navigationQueryService);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the culture assigned to a document by domains, in the context of a current Uri.
|
||||
/// </summary>
|
||||
@@ -68,6 +66,7 @@ public static class PublishedContentExtensions
|
||||
IDomainCache domainCache,
|
||||
IPublishedCache publishedCache,
|
||||
INavigationQueryService navigationQueryService,
|
||||
IPublishedStatusFilteringService publishedStatusFilteringService,
|
||||
Uri? current = null)
|
||||
{
|
||||
IUmbracoContext umbracoContext = umbracoContextAccessor.GetRequiredUmbracoContext();
|
||||
|
||||
Reference in New Issue
Block a user