Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add AddShapeTableProvider() extension method #16723

Merged
merged 4 commits into from
Sep 16, 2024
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
@@ -1,5 +1,5 @@
using Microsoft.Extensions.DependencyInjection;
using OrchardCore.DisplayManagement.Descriptors;
using OrchardCore.DisplayManagement;
using OrchardCore.Modules;

namespace OrchardCore.ContentFields.Media;
Expand All @@ -9,6 +9,6 @@ public sealed class Startup : StartupBase
{
public override void ConfigureServices(IServiceCollection services)
{
services.AddScoped<IShapeTableProvider, MediaShapes>();
services.AddShapeTableProvider<MediaShapes>();
}
}
4 changes: 2 additions & 2 deletions src/OrchardCore.Modules/OrchardCore.Contents/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
using OrchardCore.ContentTypes.Editors;
using OrchardCore.Data.Migration;
using OrchardCore.Deployment;
using OrchardCore.DisplayManagement.Descriptors;
using OrchardCore.DisplayManagement;
using OrchardCore.DisplayManagement.Handlers;
using OrchardCore.DisplayManagement.Liquid;
using OrchardCore.DisplayManagement.Liquid.Tags;
Expand Down Expand Up @@ -142,7 +142,7 @@ static async Task<FluidValue> GetContentByHandleAsync(LiquidTemplateContext cont
services.AddPermissionProvider<Permissions>();
services.AddPermissionProvider<ContentTypePermissions>();
services.AddScoped<IAuthorizationHandler, ContentTypeAuthorizationHandler>();
services.AddScoped<IShapeTableProvider, Shapes>();
services.AddShapeTableProvider<Shapes>();
services.AddNavigationProvider<AdminMenu>();
services.AddScoped<IContentDisplayDriver, ContentsDriver>();
services.AddScoped<IContentHandler, ContentsHandler>();
Expand Down
3 changes: 2 additions & 1 deletion src/OrchardCore.Modules/OrchardCore.Demo/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using OrchardCore.Demo.Models;
using OrchardCore.Demo.Services;
using OrchardCore.Demo.TagHelpers;
using OrchardCore.DisplayManagement;
using OrchardCore.DisplayManagement.Descriptors;
using OrchardCore.DisplayManagement.Handlers;
using OrchardCore.Environment.Commands;
Expand Down Expand Up @@ -84,7 +85,7 @@ public override void ConfigureServices(IServiceCollection services)
services.AddScoped<ITestDependency, ClassFoo>();
services.AddScoped<ICommandHandler, DemoCommands>();
services.AddSingleton<IBackgroundTask, TestBackgroundTask>();
services.AddScoped<IShapeTableProvider, DemoShapeProvider>();
services.AddShapeTableProvider<DemoShapeProvider>();
services.AddShapeAttributes<DemoShapeProvider>();
services.AddNavigationProvider<AdminMenu>();
services.AddScoped<IContentDisplayDriver, TestContentElementDisplayDriver>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using OrchardCore.ContentManagement.Display.ContentDisplay;
using OrchardCore.ContentTypes.Editors;
using OrchardCore.Data.Migration;
using OrchardCore.DisplayManagement.Descriptors;
using OrchardCore.DisplayManagement;
using OrchardCore.Facebook.Widgets;
using OrchardCore.Facebook.Widgets.Drivers;
using OrchardCore.Facebook.Widgets.Handlers;
Expand All @@ -20,7 +20,7 @@ public sealed class StartupWidgets : StartupBase
public override void ConfigureServices(IServiceCollection services)
{
services.AddDataMigration<WidgetMigrations>();
services.AddScoped<IShapeTableProvider, LiquidShapes>();
services.AddShapeTableProvider<LiquidShapes>();

services.AddContentPart<FacebookPluginPart>()
.UseDisplayDriver<FacebookPluginPartDisplayDriver>()
Expand Down
4 changes: 2 additions & 2 deletions src/OrchardCore.Modules/OrchardCore.Forms/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using OrchardCore.ContentManagement;
using OrchardCore.ContentManagement.Display.ContentDisplay;
using OrchardCore.Data.Migration;
using OrchardCore.DisplayManagement.Descriptors;
using OrchardCore.DisplayManagement;
using OrchardCore.Forms.Activities;
using OrchardCore.Forms.Activities.Drivers;
using OrchardCore.Forms.Drivers;
Expand Down Expand Up @@ -77,7 +77,7 @@ public override void ConfigureServices(IServiceCollection services)
.UseDisplayDriver<FormElementValidationPartDisplayDriver>();

services.AddDataMigration<Migrations>();
services.AddScoped<IShapeTableProvider, FormShapeTableProvider>();
services.AddShapeTableProvider<FormShapeTableProvider>();
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/OrchardCore.Modules/OrchardCore.Html/Media/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Microsoft.Extensions.DependencyInjection;
using OrchardCore.DisplayManagement.Descriptors;
using OrchardCore.DisplayManagement;
using OrchardCore.Modules;

namespace OrchardCore.Html.Media;
Expand All @@ -9,6 +9,6 @@ public sealed class Startup : StartupBase
{
public override void ConfigureServices(IServiceCollection services)
{
services.AddScoped<IShapeTableProvider, MediaShapes>();
services.AddShapeTableProvider<MediaShapes>();
}
}
4 changes: 2 additions & 2 deletions src/OrchardCore.Modules/OrchardCore.Liquid/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
using OrchardCore.ContentManagement;
using OrchardCore.ContentManagement.Display.ContentDisplay;
using OrchardCore.Data.Migration;
using OrchardCore.DisplayManagement.Descriptors;
using OrchardCore.DisplayManagement;
using OrchardCore.DisplayManagement.Liquid.Filters;
using OrchardCore.Indexing;
using OrchardCore.Liquid.Drivers;
Expand Down Expand Up @@ -85,7 +85,7 @@ public sealed class LiquidPartStartup : StartupBase
public override void ConfigureServices(IServiceCollection services)
{
// Liquid Part
services.AddScoped<IShapeTableProvider, LiquidShapes>();
services.AddShapeTableProvider<LiquidShapes>();
services.AddContentPart<LiquidPart>()
.UseDisplayDriver<LiquidPartDisplayDriver>()
.AddHandler<LiquidPartHandler>();
Expand Down
4 changes: 2 additions & 2 deletions src/OrchardCore.Modules/OrchardCore.Markdown/Media/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Microsoft.Extensions.DependencyInjection;
using OrchardCore.DisplayManagement.Descriptors;
using OrchardCore.DisplayManagement;
using OrchardCore.Modules;

namespace OrchardCore.Markdown.Media;
Expand All @@ -9,6 +9,6 @@ public sealed class Startup : StartupBase
{
public override void ConfigureServices(IServiceCollection services)
{
services.AddScoped<IShapeTableProvider, MediaShapes>();
services.AddShapeTableProvider<MediaShapes>();
}
}
4 changes: 2 additions & 2 deletions src/OrchardCore.Modules/OrchardCore.Menu/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using OrchardCore.ContentManagement.Handlers;
using OrchardCore.ContentTypes.Editors;
using OrchardCore.Data.Migration;
using OrchardCore.DisplayManagement.Descriptors;
using OrchardCore.DisplayManagement;
using OrchardCore.Menu.Drivers;
using OrchardCore.Menu.Handlers;
using OrchardCore.Menu.Models;
Expand All @@ -22,7 +22,7 @@ public sealed class Startup : StartupBase
public override void ConfigureServices(IServiceCollection services)
{
services.AddDataMigration<Migrations>();
services.AddScoped<IShapeTableProvider, MenuShapes>();
services.AddShapeTableProvider<MenuShapes>();
services.AddPermissionProvider<Permissions>();
services.AddNavigationProvider<AdminMenu>();

Expand Down
5 changes: 3 additions & 2 deletions src/OrchardCore.Modules/OrchardCore.Navigation/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.Extensions.DependencyInjection;
using OrchardCore.DisplayManagement;
using OrchardCore.DisplayManagement.Descriptors;
using OrchardCore.Environment.Shell.Configuration;
using OrchardCore.Modules;
Expand All @@ -18,8 +19,8 @@ public override void ConfigureServices(IServiceCollection services)
{
services.AddNavigation();

services.AddScoped<IShapeTableProvider, NavigationShapes>();
services.AddScoped<IShapeTableProvider, PagerShapesTableProvider>();
services.AddShapeTableProvider<NavigationShapes>();
services.AddShapeTableProvider<PagerShapesTableProvider>();
services.AddShapeAttributes<PagerShapes>();

var navigationConfiguration = _shellConfiguration.GetSection("OrchardCore_Navigation");
Expand Down
4 changes: 2 additions & 2 deletions src/OrchardCore.Modules/OrchardCore.Taxonomies/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
using OrchardCore.ContentTypes.Editors;
using OrchardCore.Data;
using OrchardCore.Data.Migration;
using OrchardCore.DisplayManagement.Descriptors;
using OrchardCore.DisplayManagement;
using OrchardCore.DisplayManagement.Handlers;
using OrchardCore.Indexing;
using OrchardCore.Liquid;
Expand Down Expand Up @@ -46,7 +46,7 @@ public override void ConfigureServices(IServiceCollection services)
.AddLiquidFilter<TaxonomyTermsFilter>("taxonomy_terms");

services.AddDataMigration<Migrations>();
services.AddScoped<IShapeTableProvider, TermShapes>();
services.AddShapeTableProvider<TermShapes>();
services.AddPermissionProvider<Permissions>();

// Taxonomy Part
Expand Down
8 changes: 4 additions & 4 deletions src/OrchardCore.Modules/OrchardCore.Tenants/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using Microsoft.Extensions.Options;
using Microsoft.Net.Http.Headers;
using OrchardCore.Deployment;
using OrchardCore.DisplayManagement.Descriptors;
using OrchardCore.DisplayManagement;
using OrchardCore.Environment.Shell;
using OrchardCore.Environment.Shell.Configuration;
using OrchardCore.Environment.Shell.Distributed;
Expand Down Expand Up @@ -34,7 +34,7 @@ public override void ConfigureServices(IServiceCollection services)
services.AddNavigationProvider<AdminMenu>();
services.AddPermissionProvider<Permissions>();
services.AddScoped<ITenantValidator, TenantValidator>();
services.AddScoped<IShapeTableProvider, TenantShapeTableProvider>();
services.AddShapeTableProvider<TenantShapeTableProvider>();
services.AddSetup();

services.Configure<TenantsOptions>(_shellConfiguration.GetSection("OrchardCore_Tenants"));
Expand Down Expand Up @@ -114,7 +114,7 @@ public override void ConfigureServices(IServiceCollection services)
services.AddScoped<FeatureProfilesManager>();
services.AddScoped<IFeatureProfilesService, FeatureProfilesService>();
services.AddScoped<IFeatureProfilesSchemaService, FeatureProfilesSchemaService>();
services.AddScoped<IShapeTableProvider, TenantFeatureProfileShapeTableProvider>();
services.AddShapeTableProvider<TenantFeatureProfileShapeTableProvider>();

services.AddRecipeExecutionStep<FeatureProfilesStep>();
}
Expand All @@ -134,6 +134,6 @@ public sealed class TenantFeatureProfilesStartup : StartupBase
{
public override void ConfigureServices(IServiceCollection services)
{
services.AddScoped<IShapeTableProvider, TenantFeatureShapeTableProvider>();
services.AddShapeTableProvider<TenantFeatureShapeTableProvider>();
}
}
4 changes: 2 additions & 2 deletions src/OrchardCore.Modules/OrchardCore.Users/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
using OrchardCore.Data;
using OrchardCore.Data.Migration;
using OrchardCore.Deployment;
using OrchardCore.DisplayManagement.Descriptors;
using OrchardCore.DisplayManagement;
using OrchardCore.DisplayManagement.Handlers;
using OrchardCore.DisplayManagement.Theming;
using OrchardCore.Environment.Commands;
Expand Down Expand Up @@ -237,7 +237,7 @@ public override void ConfigureServices(IServiceCollection services)
services.AddTransient<IConfigureOptions<ResourceManagementOptions>, UserOptionsConfiguration>();
services.AddScoped<IDisplayDriver<Navbar>, UserMenuNavbarDisplayDriver>();
services.AddScoped<IDisplayDriver<UserMenu>, UserMenuDisplayDriver>();
services.AddScoped<IShapeTableProvider, UserMenuShapeTableProvider>();
services.AddShapeTableProvider<UserMenuShapeTableProvider>();

services.AddRecipeExecutionStep<UsersStep>();

Expand Down
4 changes: 2 additions & 2 deletions src/OrchardCore.Modules/OrchardCore.Widgets/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using OrchardCore.ContentManagement.Display.ContentDisplay;
using OrchardCore.ContentTypes.Editors;
using OrchardCore.Data.Migration;
using OrchardCore.DisplayManagement.Descriptors;
using OrchardCore.DisplayManagement;
using OrchardCore.Modules;
using OrchardCore.ResourceManagement;
using OrchardCore.Widgets.Drivers;
Expand All @@ -19,7 +19,7 @@ public sealed class Startup : StartupBase
public override void ConfigureServices(IServiceCollection services)
{
// Add Widget Card Shapes
services.AddScoped<IShapeTableProvider, ContentCardShapes>();
services.AddShapeTableProvider<ContentCardShapes>();
// Widgets List Part
services.AddContentPart<WidgetsListPart>()
.UseDisplayDriver<WidgetsListPartDisplayDriver>();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Microsoft.Extensions.DependencyInjection;
using OrchardCore.DisplayManagement.Descriptors;

namespace OrchardCore.DisplayManagement;

/// <summary>
/// Provides an extension methods for <see cref="IShapeTableProvider"/>.
/// </summary>
public static class ShapeTableProviderExtensions
{
/// <summary>
/// Registers required services for the specified <see cref="IShapeTableProvider"/>.
/// </summary>
/// <typeparam name="TShapeTableProvider">The <see cref="IShapeTableProvider"/> to be registered.</typeparam>
/// <param name="services">The <see cref="IServiceCollection"/>.</param>
public static IServiceCollection AddShapeTableProvider<TShapeTableProvider>(this IServiceCollection services)
where TShapeTableProvider: class, IShapeTableProvider
=> services.AddScoped<IShapeTableProvider, TShapeTableProvider>();
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ public static OrchardCoreBuilder AddTheming(this OrchardCoreBuilder builder)
services.AddKeyedSingleton<IDictionary<string, ShapeTable>>(nameof(DefaultShapeTableManager), new ConcurrentDictionary<string, ShapeTable>());
services.AddScoped<IShapeTableManager, DefaultShapeTableManager>();

services.AddScoped<IShapeTableProvider, ShapeAttributeBindingStrategy>();
services.AddScoped<IShapeTableProvider, ShapePlacementParsingStrategy>();
services.AddScoped<IShapeTableProvider, ShapeTemplateBindingStrategy>();
services.AddShapeTableProvider<ShapeAttributeBindingStrategy>();
services.AddShapeTableProvider<ShapePlacementParsingStrategy>();
services.AddShapeTableProvider<ShapeTemplateBindingStrategy>();

services.AddScoped<IPlacementNodeFilterProvider, PathPlacementNodeFilterProvider>();

Expand All @@ -76,9 +76,9 @@ public static OrchardCoreBuilder AddTheming(this OrchardCoreBuilder builder)
services.TryAddSingleton<IShapeTemplateFileProviderAccessor, ShapeTemplateFileProviderAccessor>();

services.AddShapeAttributes<CoreShapes>();
services.AddScoped<IShapeTableProvider, CoreShapesTableProvider>();
services.AddShapeTableProvider<CoreShapesTableProvider>();
services.AddShapeAttributes<ZoneShapes>();
services.AddScoped<IShapeTableProvider, ZoneShapeAlternates>();
services.AddShapeTableProvider<ZoneShapeAlternates>();
services.AddShapeAttributes<GroupShapes>();

services.AddScoped(typeof(IDisplayManager<>), typeof(DisplayManager<>));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using OrchardCore.DisplayManagement;
using OrchardCore.DisplayManagement.Descriptors;
using OrchardCore.DisplayManagement.Extensions;
using OrchardCore.DisplayManagement.Implementation;
Expand Down Expand Up @@ -146,7 +147,7 @@ public DefaultShapeTableManagerTests()
});
#pragma warning restore CA1861 // Avoid constant arrays as arguments

serviceCollection.AddScoped<IShapeTableProvider, TestShapeProvider>();
serviceCollection.AddShapeTableProvider<TestShapeProvider>();
serviceCollection.AddScoped(sp => (TestShapeProvider)sp.GetService<IShapeTableProvider>());

_serviceProvider = serviceCollection.BuildServiceProvider();
Expand Down