V13: Delivery API composite id handler (#15305)

* Implement DeliveryApiCompositeIdHandler

* Replace duplicate decomposing with Handler instead

* Add obsolete messages

* Make Id integer instead of string

* Move from examine to core

---------

Co-authored-by: Zeegaan <nge@umbraco.dk>
This commit is contained in:
Nikolaj Geisle
2023-11-29 14:10:25 +01:00
committed by GitHub
parent 88f907912b
commit a8dc058cb5
8 changed files with 109 additions and 25 deletions

View File

@@ -0,0 +1,21 @@
namespace Umbraco.Cms.Core.DeliveryApi;
public class DeliveryApiCompositeIdHandler : IDeliveryApiCompositeIdHandler
{
public string IndexId(int id, string culture) => $"{id}|{culture}";
public DeliveryApiIndexCompositeIdModel Decompose(string indexId)
{
var parts = indexId.Split(Constants.CharArrays.VerticalTab);
if (parts.Length == 2 && int.TryParse(parts[0], out var id))
{
return new DeliveryApiIndexCompositeIdModel
{
Id = id,
Culture = parts[1],
};
}
return new DeliveryApiIndexCompositeIdModel();
}
}

View File

@@ -0,0 +1,8 @@
namespace Umbraco.Cms.Core.DeliveryApi;
public class DeliveryApiIndexCompositeIdModel
{
public int? Id { get; set; }
public string? Culture { get; set; }
}

View File

@@ -0,0 +1,8 @@
namespace Umbraco.Cms.Core.DeliveryApi;
public interface IDeliveryApiCompositeIdHandler
{
string IndexId(int id, string culture);
DeliveryApiIndexCompositeIdModel Decompose(string indexId);
}