Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ internal static void AddAllCoreCollectionBuilders(this IUmbracoBuilder builder)
builder.DynamicRootOriginFinders()
.Append<ByKeyDynamicRootOriginFinder>()
.Append<ParentDynamicRootOriginFinder>()
.Append<ParentOrSelfDynamicRootOriginFinder>()
.Append<CurrentDynamicRootOriginFinder>()
.Append<SiteDynamicRootOriginFinder>()
.Append<RootDynamicRootOriginFinder>();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using Umbraco.Cms.Core.Services;

namespace Umbraco.Cms.Core.DynamicRoot.Origin;

public class ParentOrSelfDynamicRootOriginFinder : ParentDynamicRootOriginFinder
{
public ParentOrSelfDynamicRootOriginFinder(IEntityService entityService) : base(entityService)
{
}

protected override string SupportedOriginType { get; set; } = "ParentOrSelf";

public override Guid? FindOriginKey(DynamicRootNodeQuery query)
{
var baseResult = base.FindOriginKey(query);
if(baseResult is not null || query.Context.CurrentKey is null)
{
return baseResult;
}
query.OriginKey = query.Context.CurrentKey;
return base.FindOriginKey(query);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ public RootDynamicRootOriginFinder(IEntityService entityService)
}

var entity = _entityService.Get(query.Context.ParentKey);
if (entity is null && query.Context.CurrentKey.HasValue)
{
entity = _entityService.Get(query.Context.CurrentKey.Value);
}

if (entity is null || _allowedObjectTypes.Contains(entity.NodeObjectType) is false)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ public SiteDynamicRootOriginFinder(IEntityService entityService, IDomainService

public override Guid? FindOriginKey(DynamicRootNodeQuery query)
{
if (query.OriginAlias != SupportedOriginType || query.Context.CurrentKey.HasValue is false)
if (query.OriginAlias != SupportedOriginType)
{
return null;
}

IEntitySlim? entity = _entityService.Get(query.Context.CurrentKey.Value);
IEntitySlim? entity = query.Context.CurrentKey.HasValue is false ? _entityService.Get(query.Context.ParentKey) : _entityService.Get(query.Context.CurrentKey.Value);
if (entity is null || entity.NodeObjectType != Constants.ObjectTypes.Document)
{
return null;
Expand Down