Skip to content
Merged
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
8 changes: 6 additions & 2 deletions src/Umbraco.Core/Extensions/UdiGetterExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ public static GuidUdi GetUdi(this EntityContainer entity)
{
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;
Expand All @@ -72,9 +76,9 @@ public static GuidUdi GetUdi(this EntityContainer entity)
{
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
{
Expand Down
4 changes: 2 additions & 2 deletions src/Umbraco.Core/Models/EntityContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -83,7 +83,7 @@ public static Guid GetContainerObjectType(Guid containedObjectType)
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));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading