Fix EntityContainer.GetUdi() for member type containers (#20840)

Fix EntityContainer.GetUdi() for member type containers
This commit is contained in:
Ronald Barendse
2025-11-14 17:09:46 +01:00
committed by GitHub
parent 06c566c074
commit 0600df4211
3 changed files with 10 additions and 5 deletions

View File

@@ -64,6 +64,10 @@ public static class UdiGetterExtensions
{
entityType = Constants.UdiEntityType.DataTypeContainer;
}
else if (entity.ContainedObjectType == Constants.ObjectTypes.DocumentBlueprint)
{
entityType = Constants.UdiEntityType.DocumentBlueprintContainer;
}
else if (entity.ContainedObjectType == Constants.ObjectTypes.DocumentType)
{
entityType = Constants.UdiEntityType.DocumentTypeContainer;
@@ -72,9 +76,9 @@ public static class UdiGetterExtensions
{
entityType = Constants.UdiEntityType.MediaTypeContainer;
}
else if (entity.ContainedObjectType == Constants.ObjectTypes.DocumentBlueprint)
else if (entity.ContainedObjectType == Constants.ObjectTypes.MemberType)
{
entityType = Constants.UdiEntityType.DocumentBlueprintContainer;
entityType = Constants.UdiEntityType.MemberTypeContainer;
}
else
{

View File

@@ -10,10 +10,10 @@ public sealed class EntityContainer : TreeEntityBase, IUmbracoEntity
private static readonly Dictionary<Guid, Guid> ObjectTypeMap = new()
{
{ Constants.ObjectTypes.DataType, Constants.ObjectTypes.DataTypeContainer },
{ Constants.ObjectTypes.DocumentBlueprint, Constants.ObjectTypes.DocumentBlueprintContainer },
{ Constants.ObjectTypes.DocumentType, Constants.ObjectTypes.DocumentTypeContainer },
{ Constants.ObjectTypes.MediaType, Constants.ObjectTypes.MediaTypeContainer },
{ Constants.ObjectTypes.MemberType, Constants.ObjectTypes.MemberTypeContainer },
{ Constants.ObjectTypes.DocumentBlueprint, Constants.ObjectTypes.DocumentBlueprintContainer },
};
/// <summary>
@@ -83,7 +83,7 @@ public sealed class EntityContainer : TreeEntityBase, IUmbracoEntity
public static Guid GetContainedObjectType(Guid containerObjectType)
{
Guid contained = ObjectTypeMap.FirstOrDefault(x => x.Value == containerObjectType).Key;
if (contained == null)
if (contained == default)
{
throw new ArgumentException("Not a container object type.", nameof(containerObjectType));
}