Fix EntityContainer.GetUdi() for member type containers (#20840)
Fix EntityContainer.GetUdi() for member type containers
This commit is contained in:
@@ -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
|
||||
{
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
@@ -16,9 +16,10 @@ namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Core.Extensions;
|
||||
public class UdiGetterExtensionsTests
|
||||
{
|
||||
[TestCase(Constants.ObjectTypes.Strings.DataType, "6ad82c70-685c-4e04-9b36-d81bd779d16f", "umb://data-type-container/6ad82c70685c4e049b36d81bd779d16f")]
|
||||
[TestCase(Constants.ObjectTypes.Strings.DocumentBlueprint, "6ad82c70-685c-4e04-9b36-d81bd779d16f", "umb://document-blueprint-container/6ad82c70685c4e049b36d81bd779d16f")]
|
||||
[TestCase(Constants.ObjectTypes.Strings.DocumentType, "6ad82c70-685c-4e04-9b36-d81bd779d16f", "umb://document-type-container/6ad82c70685c4e049b36d81bd779d16f")]
|
||||
[TestCase(Constants.ObjectTypes.Strings.MediaType, "6ad82c70-685c-4e04-9b36-d81bd779d16f", "umb://media-type-container/6ad82c70685c4e049b36d81bd779d16f")]
|
||||
[TestCase(Constants.ObjectTypes.Strings.DocumentBlueprint, "6ad82c70-685c-4e04-9b36-d81bd779d16f", "umb://document-blueprint-container/6ad82c70685c4e049b36d81bd779d16f")]
|
||||
[TestCase(Constants.ObjectTypes.Strings.MemberType, "6ad82c70-685c-4e04-9b36-d81bd779d16f", "umb://member-type-container/6ad82c70685c4e049b36d81bd779d16f")]
|
||||
public void GetUdiForEntityContainer(Guid containedObjectType, Guid key, string expected)
|
||||
{
|
||||
EntityContainer entity = new EntityContainer(containedObjectType)
|
||||
|
||||
Reference in New Issue
Block a user