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:
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace Umbraco.Cms.Core.DeliveryApi;
|
||||
|
||||
public class DeliveryApiIndexCompositeIdModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
|
||||
public string? Culture { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace Umbraco.Cms.Core.DeliveryApi;
|
||||
|
||||
public interface IDeliveryApiCompositeIdHandler
|
||||
{
|
||||
string IndexId(int id, string culture);
|
||||
|
||||
DeliveryApiIndexCompositeIdModel Decompose(string indexId);
|
||||
}
|
||||
Reference in New Issue
Block a user