Delivery API: Only add default strategy if delivery API is not registered. (#20982)
* Only add if not already present * Update src/Umbraco.Cms.Api.Management/DependencyInjection/WebhooksBuilderExtensions.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Kenn Jacobsen <kja@umbraco.dk>
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||||
using Umbraco.Cms.Api.Common.Accessors;
|
using Umbraco.Cms.Api.Common.Accessors;
|
||||||
using Umbraco.Cms.Api.Common.Rendering;
|
using Umbraco.Cms.Api.Common.Rendering;
|
||||||
using Umbraco.Cms.Api.Management.Factories;
|
using Umbraco.Cms.Api.Management.Factories;
|
||||||
@@ -16,9 +16,10 @@ internal static class WebhooksBuilderExtensions
|
|||||||
builder.Services.AddUnique<IWebhookPresentationFactory, WebhookPresentationFactory>();
|
builder.Services.AddUnique<IWebhookPresentationFactory, WebhookPresentationFactory>();
|
||||||
builder.AddMapDefinition<WebhookEventMapDefinition>();
|
builder.AddMapDefinition<WebhookEventMapDefinition>();
|
||||||
|
|
||||||
// deliveryApi will overwrite these more basic ones.
|
// We have to use TryAdd here, as if they are registered by the delivery API, we don't want to register them
|
||||||
builder.Services.AddScoped<IOutputExpansionStrategy, ElementOnlyOutputExpansionStrategy>();
|
// Delivery API will also overwrite these IF it is enabled.
|
||||||
builder.Services.AddSingleton<IOutputExpansionStrategyAccessor, RequestContextOutputExpansionStrategyAccessor>();
|
builder.Services.TryAddScoped<IOutputExpansionStrategy, ElementOnlyOutputExpansionStrategy>();
|
||||||
|
builder.Services.TryAddSingleton<IOutputExpansionStrategyAccessor, RequestContextOutputExpansionStrategyAccessor>();
|
||||||
|
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user