Cherry-pick of #20129 to 16.

This commit is contained in:
Andy Butland
2025-09-22 11:26:25 +02:00
parent 5dd75c0877
commit 2c3a2e2b2d
3 changed files with 9 additions and 4 deletions

View File

@@ -24,6 +24,8 @@ public interface IPublishedContentQuery
IEnumerable<IPublishedContent> ContentAtRoot();
IEnumerable<IPublishedContent> ContentAtRoot(string? culture) => culture is null ? ContentAtRoot() : throw new NotSupportedException();
IPublishedContent? Media(int id);
IPublishedContent? Media(Guid id);

View File

@@ -144,6 +144,9 @@ public class PublishedContentQuery : IPublishedContentQuery
public IEnumerable<IPublishedContent> ContentAtRoot()
=> ItemsAtRoot(_publishedContent);
public IEnumerable<IPublishedContent> ContentAtRoot(string? culture)
=> ItemsAtRoot(_publishedContent, culture);
#endregion
#region Media
@@ -212,8 +215,8 @@ public class PublishedContentQuery : IPublishedContentQuery
private IEnumerable<IPublishedContent> ItemsByIds(IPublishedCache? cache, IEnumerable<Guid> ids)
=> ids.Select(eachId => ItemById(eachId, cache)).WhereNotNull();
private static IEnumerable<IPublishedContent> ItemsAtRoot(IPublishedCache? cache)
=> cache?.GetAtRoot() ?? Array.Empty<IPublishedContent>();
private static IEnumerable<IPublishedContent> ItemsAtRoot(IPublishedCache? cache, string? culture = null)
=> cache?.GetAtRoot(culture) ?? Array.Empty<IPublishedContent>();
#endregion

View File

@@ -347,7 +347,7 @@ public static class FriendlyPublishedContentExtensions
/// </param>
/// <returns></returns>
/// <remarks>
/// This can be useful in order to return all nodes in an entire site by a type when combined with TypedContentAtRoot
/// This can be useful in order to return all nodes in an entire site by a type when combined with ContentAtRoot.
/// </remarks>
public static IEnumerable<IPublishedContent> DescendantsOrSelfOfType(
this IEnumerable<IPublishedContent> parentNodes, string docTypeAlias, string? culture = null)
@@ -375,7 +375,7 @@ public static class FriendlyPublishedContentExtensions
/// </param>
/// <returns></returns>
/// <remarks>
/// This can be useful in order to return all nodes in an entire site by a type when combined with TypedContentAtRoot
/// This can be useful in order to return all nodes in an entire site by a type when combined with ContentAtRoot.
/// </remarks>
public static IEnumerable<T> DescendantsOrSelf<T>(
this IEnumerable<IPublishedContent> parentNodes,