Skip to content

Commit

Permalink
Add support for all versions
Browse files Browse the repository at this point in the history
Fix #16027
  • Loading branch information
MikeAlhayek committed May 17, 2024
1 parent 07592c1 commit b419d64
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,14 @@ public async Task<ContentItem> GetAsync(string contentItemId, VersionOptions opt
{
return null;
}

options ??= VersionOptions.Published;

if (options.IsAllVersions)
{
throw new ArgumentException($"This method does not support {nameof(options.IsAllVersions)} option.");
}

ContentItem contentItem = null;

if (options.IsLatest)
Expand Down Expand Up @@ -236,6 +242,14 @@ public async Task<IEnumerable<ContentItem>> GetAsync(IEnumerable<string> content
contentItems.AddRange(missingItems);
}
}
else if (options.IsAllVersions)
{
contentItems = (await _session
.Query<ContentItem, ContentItemIndex>()
.Where(x => x.ContentItemId.IsIn(ids))
.ListAsync()
).ToList();
}

var needVersions = new List<ContentItem>();
var finalItems = new List<ContentItem>();
Expand Down Expand Up @@ -550,6 +564,11 @@ public async Task CreateAsync(ContentItem contentItem, VersionOptions options =

options ??= VersionOptions.Published;

if (options.IsAllVersions)
{
throw new ArgumentException($"This method does not support {nameof(options.IsAllVersions)} option.");
}

// Draft flag on create is required for explicitly-published content items
if (options.IsDraft)
{
Expand Down

0 comments on commit b419d64

Please sign in to comment.