Expose "expanding" state in API value conversion (#14312)
* Expose "expanding" state in API value conversion * Add unit test * Add non-breaking and obsoletion * Add compat suppressions
This commit is contained in:
@@ -122,6 +122,11 @@ public interface IPublishedPropertyType
|
||||
/// <param name="referenceCacheLevel">The reference cache level.</param>
|
||||
/// <param name="inter">The intermediate value.</param>
|
||||
/// <param name="preview">A value indicating whether content should be considered draft.</param>
|
||||
/// <param name="expanding">A value indicating whether the property value should be expanded.</param>
|
||||
/// <returns>The object value.</returns>
|
||||
object? ConvertInterToDeliveryApiObject(IPublishedElement owner, PropertyCacheLevel referenceCacheLevel, object? inter, bool preview);
|
||||
object? ConvertInterToDeliveryApiObject(IPublishedElement owner, PropertyCacheLevel referenceCacheLevel, object? inter, bool preview, bool expanding);
|
||||
|
||||
[Obsolete($"Use the {nameof(ConvertInterToDeliveryApiObject)} that supports property expansion. Will be removed in V14.")]
|
||||
object? ConvertInterToDeliveryApiObject(IPublishedElement owner, PropertyCacheLevel referenceCacheLevel, object? inter, bool preview)
|
||||
=> ConvertInterToDeliveryApiObject(owner, referenceCacheLevel, inter, preview, false);
|
||||
}
|
||||
|
||||
@@ -301,7 +301,7 @@ namespace Umbraco.Cms.Core.Models.PublishedContent
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public object? ConvertInterToDeliveryApiObject(IPublishedElement owner, PropertyCacheLevel referenceCacheLevel, object? inter, bool preview)
|
||||
public object? ConvertInterToDeliveryApiObject(IPublishedElement owner, PropertyCacheLevel referenceCacheLevel, object? inter, bool preview, bool expanding)
|
||||
{
|
||||
if (!_initialized)
|
||||
{
|
||||
@@ -311,7 +311,7 @@ namespace Umbraco.Cms.Core.Models.PublishedContent
|
||||
// use the converter if any, else just return the inter value
|
||||
return _converter != null
|
||||
? _converter is IDeliveryApiPropertyValueConverter deliveryApiPropertyValueConverter
|
||||
? deliveryApiPropertyValueConverter.ConvertIntermediateToDeliveryApiObject(owner, this, referenceCacheLevel, inter, preview)
|
||||
? deliveryApiPropertyValueConverter.ConvertIntermediateToDeliveryApiObject(owner, this, referenceCacheLevel, inter, preview, expanding)
|
||||
: _converter.ConvertIntermediateToObject(owner, this, referenceCacheLevel, inter, preview)
|
||||
: inter;
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class RawValueProperty : PublishedPropertyBase
|
||||
_xpathValue = new Lazy<object?>(() =>
|
||||
PropertyType.ConvertInterToXPath(content, PropertyCacheLevel.Unknown, interValue?.Value, isPreviewing));
|
||||
_deliveryApiValue = new Lazy<object?>(() =>
|
||||
PropertyType.ConvertInterToDeliveryApiObject(content, PropertyCacheLevel.Unknown, interValue?.Value, isPreviewing));
|
||||
PropertyType.ConvertInterToDeliveryApiObject(content, PropertyCacheLevel.Unknown, interValue?.Value, isPreviewing, false));
|
||||
}
|
||||
|
||||
// RawValueProperty does not (yet?) support variants,
|
||||
|
||||
Reference in New Issue
Block a user