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
Original file line number Diff line number Diff line change
Expand Up @@ -11,91 +11,119 @@
namespace Umbraco.Cms.Core.DependencyInjection;

/// <summary>
/// Contains extensions methods for <see cref="IUmbracoBuilder" /> used for registering content apps.
/// Contains extensions methods for <see cref="IUmbracoBuilder" />.
/// </summary>
public static partial class UmbracoBuilderExtensions
{
/// <summary>
/// Register a component.
/// Register a component.
/// </summary>
/// <typeparam name="T">The type of the component.</typeparam>
/// <param name="builder">The builder.</param>
/// <returns>
/// The builder.
/// </returns>
public static IUmbracoBuilder AddComponent<T>(this IUmbracoBuilder builder)
where T : class, IComponent
where T : IComponent
{
builder.Components().Append<T>();

return builder;
}

/// <summary>
/// Register a content app.
/// Register a content app.
/// </summary>
/// <typeparam name="T">The type of the content app.</typeparam>
/// <param name="builder">The builder.</param>
/// <returns>
/// The builder.
/// </returns>
public static IUmbracoBuilder AddContentApp<T>(this IUmbracoBuilder builder)
where T : class, IContentAppFactory
where T : IContentAppFactory
{
builder.ContentApps().Append<T>();

return builder;
}

/// <summary>
/// Register a content finder.
/// Register a content finder.
/// </summary>
/// <typeparam name="T">The type of the content finder.</typeparam>
/// <param name="builder">The builder.</param>
/// <returns>
/// The builder.
/// </returns>
public static IUmbracoBuilder AddContentFinder<T>(this IUmbracoBuilder builder)
where T : class, IContentFinder
where T : IContentFinder
{
builder.ContentFinders().Append<T>();

return builder;
}

/// <summary>
/// Register a dashboard.
/// Register a dashboard.
/// </summary>
/// <typeparam name="T">The type of the dashboard.</typeparam>
/// <param name="builder">The builder.</param>
/// <returns>
/// The builder.
/// </returns>
public static IUmbracoBuilder AddDashboard<T>(this IUmbracoBuilder builder)
where T : class, IDashboard
where T : IDashboard
{
builder.Dashboards().Add<T>();

return builder;
}

/// <summary>
/// Register a manifest filter
/// Register a manifest filter.
/// </summary>
/// <typeparam name="T">The type of the manifest filter.</typeparam>
/// <param name="builder">The Builder.</param>
/// <returns>
/// The builder.
/// </returns>
public static IUmbracoBuilder AddManifestFilter<T>(this IUmbracoBuilder builder)
where T : class, IManifestFilter
where T : IManifestFilter
{
builder.ManifestFilters().Append<T>();

return builder;
}

/// <summary>
/// Register a media url provider.
/// Register a media URL provider.
/// </summary>
/// <typeparam name="T">The type of the media url provider.</typeparam>
/// <typeparam name="T">The type of the media URL provider.</typeparam>
/// <param name="builder">The builder.</param>
/// <returns>
/// The builder.
/// </returns>
public static IUmbracoBuilder AddMediaUrlProvider<T>(this IUmbracoBuilder builder)
where T : class, IMediaUrlProvider
where T : IMediaUrlProvider
{
builder.MediaUrlProviders().Append<T>();

return builder;
}

/// <summary>
/// Register a embed provider.
/// Register a embed provider.
/// </summary>
/// <typeparam name="T">The type of the embed provider.</typeparam>
/// <param name="builder">The builder.</param>
/// <returns>
/// The builder.
/// </returns>
public static IUmbracoBuilder AddEmbedProvider<T>(this IUmbracoBuilder builder)
where T : class, IEmbedProvider
where T : IEmbedProvider
{
builder.EmbedProviders().Append<T>();

return builder;
}

Expand All @@ -104,46 +132,62 @@ public static IUmbracoBuilder AddEmbedProvider<T>(this IUmbracoBuilder builder)
/// </summary>
/// <typeparam name="T">The type of the section.</typeparam>
/// <param name="builder">The builder.</param>
/// <returns>
/// The builder.
/// </returns>
public static IUmbracoBuilder AddSection<T>(this IUmbracoBuilder builder)
where T : class, ISection
where T : ISection
{
builder.Sections().Append<T>();

return builder;
}

/// <summary>
/// Register a url provider.
/// Register a URL provider.
/// </summary>
/// <typeparam name="T">The type of the url provider.</typeparam>
/// <typeparam name="T">The type of the URL provider.</typeparam>
/// <param name="builder">The Builder.</param>
/// <returns>
/// The builder.
/// </returns>
public static IUmbracoBuilder AddUrlProvider<T>(this IUmbracoBuilder builder)
where T : class, IUrlProvider
where T : IUrlProvider
{
builder.UrlProviders().Append<T>();

return builder;
}

/// <summary>
/// Add an IMapDefinition to the MapDefinitionCollectionBuilder
/// Add a map definition.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="builder"></param>
/// <returns></returns>
public static IUmbracoBuilder AddMapDefinition<T>(this IUmbracoBuilder builder) where T : IMapDefinition
/// <typeparam name="T">The type of map definition.</typeparam>
/// <param name="builder">The builder.</param>
/// <returns>
/// The builder.
/// </returns>
public static IUmbracoBuilder AddMapDefinition<T>(this IUmbracoBuilder builder)
where T : IMapDefinition
{
builder.WithCollectionBuilder<MapDefinitionCollectionBuilder>().Add<T>();
builder.MapDefinitions().Add<T>();

return builder;
}

/// <summary>
/// Add an IWebhookEvent to the WebhookEventCollectionBuilder.
/// Add a webhook event.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="builder"></param>
/// <returns></returns>
public static IUmbracoBuilder AddWebhookEvent<T>(this IUmbracoBuilder builder) where T : IWebhookEvent
/// <typeparam name="T">The type of webhook event.</typeparam>
/// <param name="builder">The builder.</param>
/// <returns>
/// The builder.
/// </returns>
public static IUmbracoBuilder AddWebhookEvent<T>(this IUmbracoBuilder builder)
where T : IWebhookEvent
{
builder.WebhookEvents().Append<T>();
builder.WebhookEvents().Add<T>();

return builder;
}
}
2 changes: 1 addition & 1 deletion src/Umbraco.Core/Webhooks/WebhookEventCollectionBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace Umbraco.Cms.Core.Webhooks;

public class WebhookEventCollectionBuilder : OrderedCollectionBuilderBase<WebhookEventCollectionBuilder, WebhookEventCollection, IWebhookEvent>
public class WebhookEventCollectionBuilder : SetCollectionBuilderBase<WebhookEventCollectionBuilder, WebhookEventCollection, IWebhookEvent>
{
protected override WebhookEventCollectionBuilder This => this;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ public static class WebhookEventCollectionBuilderCmsContentExtensions
public static WebhookEventCollectionBuilderCmsContent AddDefault(this WebhookEventCollectionBuilderCmsContent builder)
{
builder.Builder
.Append<ContentCopiedWebhookEvent>()
.Append<ContentDeletedWebhookEvent>()
.Append<ContentEmptiedRecycleBinWebhookEvent>()
.Append<ContentMovedToRecycleBinWebhookEvent>()
.Append<ContentMovedWebhookEvent>()
.Append<ContentPublishedWebhookEvent>()
.Append<ContentSavedWebhookEvent>()
.Append<ContentSortedWebhookEvent>()
.Append<ContentUnpublishedWebhookEvent>();
.Add<ContentCopiedWebhookEvent>()
.Add<ContentDeletedWebhookEvent>()
.Add<ContentEmptiedRecycleBinWebhookEvent>()
.Add<ContentMovedToRecycleBinWebhookEvent>()
.Add<ContentMovedWebhookEvent>()
.Add<ContentPublishedWebhookEvent>()
.Add<ContentSavedWebhookEvent>()
.Add<ContentSortedWebhookEvent>()
.Add<ContentUnpublishedWebhookEvent>();

return builder;
}
Expand All @@ -41,8 +41,8 @@ public static WebhookEventCollectionBuilderCmsContent AddDefault(this WebhookEve
public static WebhookEventCollectionBuilderCmsContent AddBlueprint(this WebhookEventCollectionBuilderCmsContent builder)
{
builder.Builder
.Append<ContentDeletedBlueprintWebhookEvent>()
.Append<ContentSavedBlueprintWebhookEvent>();
.Add<ContentDeletedBlueprintWebhookEvent>()
.Add<ContentSavedBlueprintWebhookEvent>();

return builder;
}
Expand All @@ -57,8 +57,8 @@ public static WebhookEventCollectionBuilderCmsContent AddBlueprint(this WebhookE
public static WebhookEventCollectionBuilderCmsContent AddVersion(this WebhookEventCollectionBuilderCmsContent builder)
{
builder.Builder
.Append<ContentDeletedVersionsWebhookEvent>()
.Append<ContentRolledBackWebhookEvent>();
.Add<ContentDeletedVersionsWebhookEvent>()
.Add<ContentRolledBackWebhookEvent>();

return builder;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ public static class WebhookEventCollectionBuilderCmsContentTypeExtensions
public static WebhookEventCollectionBuilderCmsContentType AddDocumentType(this WebhookEventCollectionBuilderCmsContentType builder)
{
builder.Builder
.Append<DocumentTypeChangedWebhookEvent>()
.Append<DocumentTypeDeletedWebhookEvent>()
.Append<DocumentTypeMovedWebhookEvent>()
.Append<DocumentTypeSavedWebhookEvent>();
.Add<DocumentTypeChangedWebhookEvent>()
.Add<DocumentTypeDeletedWebhookEvent>()
.Add<DocumentTypeMovedWebhookEvent>()
.Add<DocumentTypeSavedWebhookEvent>();

return builder;
}
Expand All @@ -36,10 +36,10 @@ public static WebhookEventCollectionBuilderCmsContentType AddDocumentType(this W
public static WebhookEventCollectionBuilderCmsContentType AddMediaType(this WebhookEventCollectionBuilderCmsContentType builder)
{
builder.Builder
.Append<MediaTypeChangedWebhookEvent>()
.Append<MediaTypeDeletedWebhookEvent>()
.Append<MediaTypeMovedWebhookEvent>()
.Append<MediaTypeSavedWebhookEvent>();
.Add<MediaTypeChangedWebhookEvent>()
.Add<MediaTypeDeletedWebhookEvent>()
.Add<MediaTypeMovedWebhookEvent>()
.Add<MediaTypeSavedWebhookEvent>();

return builder;
}
Expand All @@ -55,10 +55,10 @@ public static WebhookEventCollectionBuilderCmsContentType AddMediaType(this Webh
public static WebhookEventCollectionBuilderCmsContentType AddMemberType(this WebhookEventCollectionBuilderCmsContentType builder)
{
builder.Builder
.Append<MemberTypeChangedWebhookEvent>()
.Append<MemberTypeDeletedWebhookEvent>()
.Append<MemberTypeMovedWebhookEvent>()
.Append<MemberTypeSavedWebhookEvent>();
.Add<MemberTypeChangedWebhookEvent>()
.Add<MemberTypeDeletedWebhookEvent>()
.Add<MemberTypeMovedWebhookEvent>()
.Add<MemberTypeSavedWebhookEvent>();

return builder;
}
Expand Down
Loading