From 242668cb2cb50d99dc4b4784ea9b37ec8ed610f4 Mon Sep 17 00:00:00 2001 From: Mike Alhayek Date: Mon, 26 Aug 2024 09:42:34 -0700 Subject: [PATCH] Add AddSiteDisplayDriver extension --- .../OrchardCore.Admin/Startup.cs | 3 +-- .../OrchardCore.AuditTrail/Startup.cs | 5 ++--- .../OrchardCore.ContentLocalization/Startup.cs | 5 ++--- .../OrchardCore.Contents/AuditTrail/Startup.cs | 3 +-- .../ExportContentToDeploymentTargetStartup.cs | 3 +-- .../OrchardCore.CustomSettings/Startup.cs | 3 +-- .../OrchardCore.Email.Azure/Startup.cs | 3 +-- .../OrchardCore.Email.Smtp/Startup.cs | 3 +-- .../OrchardCore.Email/Startup.cs | 3 +-- .../OrchardCore.Facebook/Startup.cs | 3 +-- .../OrchardCore.Facebook/StartupLogin.cs | 3 +-- .../OrchardCore.Facebook/StartupPixel.cs | 3 +-- .../OrchardCore.GitHub/Startup.cs | 3 +-- .../GoogleAuthenticationStartup.cs | 7 +++---- .../OrchardCore.Https/Startup.cs | 3 +-- .../OrchardCore.Layers/Startup.cs | 3 +-- .../OrchardCore.Localization/Startup.cs | 3 +-- .../MicrosoftAccountStartup.cs | 5 ++--- .../OrchardCore.ReCaptcha/Startup.cs | 3 +-- .../OrchardCore.ReverseProxy/Startup.cs | 3 +-- .../OrchardCore.Search.AzureAI/Startup.cs | 5 ++--- .../OrchardCore.Search.Elasticsearch/Startup.cs | 3 +-- .../OrchardCore.Search.Lucene/Startup.cs | 3 +-- .../OrchardCore.Search/Startup.cs | 3 +-- .../OrchardCore.Security/Startup.cs | 3 +-- src/OrchardCore.Modules/OrchardCore.Seo/Startup.cs | 3 +-- .../OrchardCore.Settings/Startup.cs | 4 ++-- .../OrchardCore.Sitemaps/Startup.cs | 3 +-- src/OrchardCore.Modules/OrchardCore.Sms/Startup.cs | 5 ++--- .../OrchardCore.Taxonomies/Startup.cs | 3 +-- .../OrchardCore.Twitter/Startup.cs | 5 ++--- .../OrchardCore.Users/Startup.cs | 9 ++++----- .../TwoFactorAuthenticationStartup.cs | 11 +++++------ .../Extensions/ServiceCollectionExtensions.cs | 3 +-- .../SiteServiceCollectionExtensions.cs | 13 +++++++++++++ src/docs/releases/2.0.0.md | 3 ++- 36 files changed, 65 insertions(+), 84 deletions(-) create mode 100644 src/OrchardCore/OrchardCore.DisplayManagement/SiteServiceCollectionExtensions.cs diff --git a/src/OrchardCore.Modules/OrchardCore.Admin/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Admin/Startup.cs index 1a83938744d..bcbcfba5bcc 100644 --- a/src/OrchardCore.Modules/OrchardCore.Admin/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Admin/Startup.cs @@ -22,7 +22,6 @@ using OrchardCore.Mvc.Routing; using OrchardCore.Navigation; using OrchardCore.Security.Permissions; -using OrchardCore.Settings; using OrchardCore.Settings.Deployment; namespace OrchardCore.Admin; @@ -55,7 +54,7 @@ public override void ConfigureServices(IServiceCollection services) services.AddScoped(); services.AddScoped(); services.AddScoped(); - services.AddScoped, AdminSiteSettingsDisplayDriver>(); + services.AddSiteDisplayDriver(); services.AddScoped(); services.AddScoped(); services.AddSingleton(); diff --git a/src/OrchardCore.Modules/OrchardCore.AuditTrail/Startup.cs b/src/OrchardCore.Modules/OrchardCore.AuditTrail/Startup.cs index 684789e0ff1..281167d89b2 100644 --- a/src/OrchardCore.Modules/OrchardCore.AuditTrail/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.AuditTrail/Startup.cs @@ -17,7 +17,6 @@ using OrchardCore.Modules; using OrchardCore.Navigation; using OrchardCore.Security.Permissions; -using OrchardCore.Settings; using OrchardCore.Settings.Deployment; using YesSql.Filters.Query; @@ -47,8 +46,8 @@ public override void ConfigureServices(IServiceCollection services) services.AddScoped(); services.AddScoped(); - services.AddScoped, AuditTrailSettingsDisplayDriver>(); - services.AddScoped, AuditTrailTrimmingSettingsDisplayDriver>(); + services.AddSiteDisplayDriver(); + services.AddSiteDisplayDriver(); services.AddScoped, AuditTrailOptionsDisplayDriver>(); diff --git a/src/OrchardCore.Modules/OrchardCore.ContentLocalization/Startup.cs b/src/OrchardCore.Modules/OrchardCore.ContentLocalization/Startup.cs index 2d7c4ac6f7e..7bb7a176dc6 100644 --- a/src/OrchardCore.Modules/OrchardCore.ContentLocalization/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.ContentLocalization/Startup.cs @@ -21,7 +21,6 @@ using OrchardCore.Modules; using OrchardCore.Navigation; using OrchardCore.Security.Permissions; -using OrchardCore.Settings; using OrchardCore.Sitemaps.Builders; namespace OrchardCore.ContentLocalization; @@ -64,8 +63,8 @@ public override void ConfigureServices(IServiceCollection services) services.AddLiquidFilter("switch_culture_url"); services.AddScoped(); services.AddScoped(); - services.AddScoped, ContentCulturePickerSettingsDriver>(); - services.AddScoped, ContentRequestCultureProviderSettingsDriver>(); + services.AddSiteDisplayDriver(); + services.AddSiteDisplayDriver(); services.Configure(options => options.AddInitialRequestCultureProvider(new ContentRequestCultureProvider())); services.Configure(_shellConfiguration.GetSection("OrchardCore_ContentLocalization_CulturePickerOptions")); } diff --git a/src/OrchardCore.Modules/OrchardCore.Contents/AuditTrail/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Contents/AuditTrail/Startup.cs index 8e9e4d50b5c..c78786f0dc1 100644 --- a/src/OrchardCore.Modules/OrchardCore.Contents/AuditTrail/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Contents/AuditTrail/Startup.cs @@ -14,7 +14,6 @@ using OrchardCore.Data.Migration; using OrchardCore.DisplayManagement.Handlers; using OrchardCore.Modules; -using OrchardCore.Settings; namespace OrchardCore.Contents.AuditTrail; @@ -32,7 +31,7 @@ public override void ConfigureServices(IServiceCollection services) services.AddTransient, ContentAuditTrailEventConfiguration>(); services.AddScoped(); - services.AddScoped, ContentAuditTrailSettingsDisplayDriver>(); + services.AddSiteDisplayDriver(); services.AddScoped, AuditTrailContentEventDisplayDriver>(); diff --git a/src/OrchardCore.Modules/OrchardCore.Contents/Deployment/ExportContentToDeploymentTarget/ExportContentToDeploymentTargetStartup.cs b/src/OrchardCore.Modules/OrchardCore.Contents/Deployment/ExportContentToDeploymentTarget/ExportContentToDeploymentTargetStartup.cs index 581c9a6bdb5..f410d1f94b9 100644 --- a/src/OrchardCore.Modules/OrchardCore.Contents/Deployment/ExportContentToDeploymentTarget/ExportContentToDeploymentTargetStartup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Contents/Deployment/ExportContentToDeploymentTarget/ExportContentToDeploymentTargetStartup.cs @@ -6,7 +6,6 @@ using OrchardCore.DisplayManagement.Handlers; using OrchardCore.Modules; using OrchardCore.Navigation; -using OrchardCore.Settings; using OrchardCore.Settings.Deployment; namespace OrchardCore.Contents.Deployment.ExportContentToDeploymentTarget; @@ -18,7 +17,7 @@ public override void ConfigureServices(IServiceCollection services) { services.AddScoped(); - services.AddScoped, ExportContentToDeploymentTargetSettingsDisplayDriver>(); + services.AddSiteDisplayDriver(); services.AddDeployment(); diff --git a/src/OrchardCore.Modules/OrchardCore.CustomSettings/Startup.cs b/src/OrchardCore.Modules/OrchardCore.CustomSettings/Startup.cs index 93a212611e9..d5a8418841f 100644 --- a/src/OrchardCore.Modules/OrchardCore.CustomSettings/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.CustomSettings/Startup.cs @@ -12,7 +12,6 @@ using OrchardCore.Navigation; using OrchardCore.Recipes; using OrchardCore.Security.Permissions; -using OrchardCore.Settings; namespace OrchardCore.CustomSettings; @@ -21,7 +20,7 @@ public sealed class Startup : StartupBase public override void ConfigureServices(IServiceCollection services) { services.AddScoped(); - services.AddScoped, CustomSettingsDisplayDriver>(); + services.AddSiteDisplayDriver(); services.AddScoped(); services.AddScoped(); // Permissions diff --git a/src/OrchardCore.Modules/OrchardCore.Email.Azure/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Email.Azure/Startup.cs index d6be2d33b6e..471f31c1f36 100644 --- a/src/OrchardCore.Modules/OrchardCore.Email.Azure/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Email.Azure/Startup.cs @@ -8,7 +8,6 @@ using OrchardCore.Email.Core; using OrchardCore.Email.Services; using OrchardCore.Environment.Shell.Configuration; -using OrchardCore.Settings; namespace OrchardCore.Email.Azure; @@ -26,7 +25,7 @@ public void ConfigureServices(IServiceCollection services) services.AddTransient, AzureEmailOptionsConfiguration>(); services.AddEmailProviderOptionsConfiguration() - .AddScoped, AzureEmailSettingsDisplayDriver>(); + .AddSiteDisplayDriver(); services.Configure(options => { diff --git a/src/OrchardCore.Modules/OrchardCore.Email.Smtp/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Email.Smtp/Startup.cs index 873d8c46056..b57b9f3dd24 100644 --- a/src/OrchardCore.Modules/OrchardCore.Email.Smtp/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Email.Smtp/Startup.cs @@ -6,7 +6,6 @@ using OrchardCore.Email.Smtp.Extensions; using OrchardCore.Email.Smtp.Services; using OrchardCore.Environment.Shell.Configuration; -using OrchardCore.Settings; namespace OrchardCore.Email.Smtp; @@ -22,7 +21,7 @@ public Startup(IShellConfiguration shellConfiguration) public void ConfigureServices(IServiceCollection services) { services.AddSmtpEmailProvider() - .AddScoped, SmtpSettingsDisplayDriver>() + .AddSiteDisplayDriver() .AddTransient, SmtpOptionsConfiguration>(); services.Configure(options => diff --git a/src/OrchardCore.Modules/OrchardCore.Email/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Email/Startup.cs index 38c059baafb..bedc902678d 100644 --- a/src/OrchardCore.Modules/OrchardCore.Email/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Email/Startup.cs @@ -7,7 +7,6 @@ using OrchardCore.Modules; using OrchardCore.Navigation; using OrchardCore.Security.Permissions; -using OrchardCore.Settings; namespace OrchardCore.Email; @@ -16,7 +15,7 @@ public sealed class Startup : StartupBase public override void ConfigureServices(IServiceCollection services) { services.AddEmailServices() - .AddScoped, EmailSettingsDisplayDriver>() + .AddSiteDisplayDriver() .AddScoped() .AddScoped(); diff --git a/src/OrchardCore.Modules/OrchardCore.Facebook/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Facebook/Startup.cs index e71bbee0ac0..36b4597cae7 100644 --- a/src/OrchardCore.Modules/OrchardCore.Facebook/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Facebook/Startup.cs @@ -14,7 +14,6 @@ using OrchardCore.Recipes; using OrchardCore.ResourceManagement; using OrchardCore.Security.Permissions; -using OrchardCore.Settings; namespace OrchardCore.Facebook; @@ -31,7 +30,7 @@ public override void ConfigureServices(IServiceCollection services) services.AddScoped(); services.AddSingleton(); - services.AddScoped, FacebookSettingsDisplayDriver>(); + services.AddSiteDisplayDriver(); services.AddRecipeExecutionStep(); services.AddTransient, ResourceManagementOptionsConfiguration>(); diff --git a/src/OrchardCore.Modules/OrchardCore.Facebook/StartupLogin.cs b/src/OrchardCore.Modules/OrchardCore.Facebook/StartupLogin.cs index b86b4f5fd1a..7d4b6a2ede9 100644 --- a/src/OrchardCore.Modules/OrchardCore.Facebook/StartupLogin.cs +++ b/src/OrchardCore.Modules/OrchardCore.Facebook/StartupLogin.cs @@ -13,7 +13,6 @@ using OrchardCore.Modules; using OrchardCore.Navigation; using OrchardCore.Recipes; -using OrchardCore.Settings; namespace OrchardCore.Facebook; @@ -25,7 +24,7 @@ public override void ConfigureServices(IServiceCollection services) services.AddScoped(); services.AddSingleton(); - services.AddScoped, FacebookLoginSettingsDisplayDriver>(); + services.AddSiteDisplayDriver(); services.AddRecipeExecutionStep(); // Register the options initializers required by the Facebook handler. diff --git a/src/OrchardCore.Modules/OrchardCore.Facebook/StartupPixel.cs b/src/OrchardCore.Modules/OrchardCore.Facebook/StartupPixel.cs index 3ac45eb5945..d1c4676f122 100644 --- a/src/OrchardCore.Modules/OrchardCore.Facebook/StartupPixel.cs +++ b/src/OrchardCore.Modules/OrchardCore.Facebook/StartupPixel.cs @@ -6,7 +6,6 @@ using OrchardCore.Modules; using OrchardCore.Navigation; using OrchardCore.Security.Permissions; -using OrchardCore.Settings; namespace OrchardCore.Facebook; @@ -15,7 +14,7 @@ public sealed class StartupPixel : StartupBase { public override void ConfigureServices(IServiceCollection services) { - services.AddScoped, FacebookPixelSettingsDisplayDriver>(); + services.AddSiteDisplayDriver(); services.AddScoped(); services.AddScoped(); diff --git a/src/OrchardCore.Modules/OrchardCore.GitHub/Startup.cs b/src/OrchardCore.Modules/OrchardCore.GitHub/Startup.cs index 8b4e68cc01e..111656100d2 100644 --- a/src/OrchardCore.Modules/OrchardCore.GitHub/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.GitHub/Startup.cs @@ -12,7 +12,6 @@ using OrchardCore.Navigation; using OrchardCore.Recipes; using OrchardCore.Security.Permissions; -using OrchardCore.Settings; namespace OrchardCore.GitHub; @@ -30,7 +29,7 @@ public sealed class GitHubLoginStartup : StartupBase public override void ConfigureServices(IServiceCollection services) { services.AddSingleton(); - services.AddScoped, GitHubAuthenticationSettingsDisplayDriver>(); + services.AddSiteDisplayDriver(); services.AddScoped(); services.AddRecipeExecutionStep(); diff --git a/src/OrchardCore.Modules/OrchardCore.Google/GoogleAuthenticationStartup.cs b/src/OrchardCore.Modules/OrchardCore.Google/GoogleAuthenticationStartup.cs index 6a077e7da54..14595dff43d 100644 --- a/src/OrchardCore.Modules/OrchardCore.Google/GoogleAuthenticationStartup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Google/GoogleAuthenticationStartup.cs @@ -20,7 +20,6 @@ using OrchardCore.Modules; using OrchardCore.Navigation; using OrchardCore.Security.Permissions; -using OrchardCore.Settings; using OrchardCore.Settings.Deployment; namespace OrchardCore.Google; @@ -32,7 +31,7 @@ public override void ConfigureServices(IServiceCollection services) { services.AddScoped(); services.AddSingleton(); - services.AddScoped, GoogleAuthenticationSettingsDisplayDriver>(); + services.AddSiteDisplayDriver(); services.AddScoped(); // Register the options initializers required by the Google Handler. services.TryAddEnumerable(new[] @@ -56,7 +55,7 @@ public override void ConfigureServices(IServiceCollection services) services.AddScoped(); services.AddSingleton(); - services.AddScoped, GoogleAnalyticsSettingsDisplayDriver>(); + services.AddSiteDisplayDriver(); services.AddScoped(); services.Configure((options) => { @@ -73,7 +72,7 @@ public override void ConfigureServices(IServiceCollection services) services.AddScoped(); services.AddSingleton(); - services.AddScoped, GoogleTagManagerSettingsDisplayDriver>(); + services.AddSiteDisplayDriver(); services.AddScoped(); services.Configure((options) => { diff --git a/src/OrchardCore.Modules/OrchardCore.Https/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Https/Startup.cs index 0f44f6a8ede..5c0cde3df68 100644 --- a/src/OrchardCore.Modules/OrchardCore.Https/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Https/Startup.cs @@ -10,7 +10,6 @@ using OrchardCore.Modules; using OrchardCore.Navigation; using OrchardCore.Security.Permissions; -using OrchardCore.Settings; using OrchardCore.Settings.Deployment; namespace OrchardCore.Https; @@ -35,7 +34,7 @@ public override async ValueTask ConfigureAsync(IApplicationBuilder app, IEndpoin public override void ConfigureServices(IServiceCollection services) { services.AddScoped(); - services.AddScoped, HttpsSettingsDisplayDriver>(); + services.AddSiteDisplayDriver(); services.AddSingleton(); services.AddScoped(); diff --git a/src/OrchardCore.Modules/OrchardCore.Layers/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Layers/Startup.cs index 018ddce7002..81037428b81 100644 --- a/src/OrchardCore.Modules/OrchardCore.Layers/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Layers/Startup.cs @@ -21,7 +21,6 @@ using OrchardCore.Recipes; using OrchardCore.Scripting; using OrchardCore.Security.Permissions; -using OrchardCore.Settings; namespace OrchardCore.Layers; @@ -39,7 +38,7 @@ public override void ConfigureServices(IServiceCollection services) options.Filters.Add(); }); - services.AddScoped, LayerSiteSettingsDisplayDriver>(); + services.AddSiteDisplayDriver(); services.AddContentPart(); services.AddScoped(); services.AddScoped(); diff --git a/src/OrchardCore.Modules/OrchardCore.Localization/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Localization/Startup.cs index f76da554bcd..4df8612d107 100644 --- a/src/OrchardCore.Modules/OrchardCore.Localization/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Localization/Startup.cs @@ -13,7 +13,6 @@ using OrchardCore.Modules; using OrchardCore.Navigation; using OrchardCore.Security.Permissions; -using OrchardCore.Settings; using OrchardCore.Settings.Deployment; namespace OrchardCore.Localization; @@ -28,7 +27,7 @@ public sealed class Startup : StartupBase /// public override void ConfigureServices(IServiceCollection services) { - services.AddScoped, LocalizationSettingsDisplayDriver>(); + services.AddSiteDisplayDriver(); services.AddScoped(); services.AddScoped(); services.AddScoped(); diff --git a/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/MicrosoftAccountStartup.cs b/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/MicrosoftAccountStartup.cs index 826174b7dad..10988b9ba18 100644 --- a/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/MicrosoftAccountStartup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/MicrosoftAccountStartup.cs @@ -17,7 +17,6 @@ using OrchardCore.Navigation; using OrchardCore.Recipes; using OrchardCore.Security.Permissions; -using OrchardCore.Settings; namespace OrchardCore.Microsoft.Authentication; @@ -29,7 +28,7 @@ public override void ConfigureServices(IServiceCollection services) services.TryAddEnumerable(new ServiceDescriptor(typeof(IPermissionProvider), typeof(Permissions), ServiceLifetime.Scoped)); services.AddSingleton(); - services.AddScoped, MicrosoftAccountSettingsDisplayDriver>(); + services.AddSiteDisplayDriver(); services.AddScoped(); services.AddRecipeExecutionStep(); @@ -57,7 +56,7 @@ public override void ConfigureServices(IServiceCollection services) services.AddSingleton(); services.AddRecipeExecutionStep(); - services.AddScoped, AzureADSettingsDisplayDriver>(); + services.AddSiteDisplayDriver(); services.AddScoped(); services.AddTransient, AzureADSettingsConfiguration>(); diff --git a/src/OrchardCore.Modules/OrchardCore.ReCaptcha/Startup.cs b/src/OrchardCore.Modules/OrchardCore.ReCaptcha/Startup.cs index 5d0b1ce96cd..c96e5b9e3cb 100644 --- a/src/OrchardCore.Modules/OrchardCore.ReCaptcha/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.ReCaptcha/Startup.cs @@ -7,7 +7,6 @@ using OrchardCore.ReCaptcha.Drivers; using OrchardCore.ReCaptcha.Users.Handlers; using OrchardCore.Security.Permissions; -using OrchardCore.Settings; using OrchardCore.Settings.Deployment; using OrchardCore.Users; using OrchardCore.Users.Events; @@ -22,7 +21,7 @@ public override void ConfigureServices(IServiceCollection services) { services.AddReCaptcha(); - services.AddScoped, ReCaptchaSettingsDisplayDriver>(); + services.AddSiteDisplayDriver(); services.AddScoped(); services.AddScoped(); } diff --git a/src/OrchardCore.Modules/OrchardCore.ReverseProxy/Startup.cs b/src/OrchardCore.Modules/OrchardCore.ReverseProxy/Startup.cs index 7b97365bb91..d2c0841ecd1 100644 --- a/src/OrchardCore.Modules/OrchardCore.ReverseProxy/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.ReverseProxy/Startup.cs @@ -10,7 +10,6 @@ using OrchardCore.ReverseProxy.Services; using OrchardCore.ReverseProxy.Settings; using OrchardCore.Security.Permissions; -using OrchardCore.Settings; using OrchardCore.Settings.Deployment; namespace OrchardCore.ReverseProxy; @@ -29,7 +28,7 @@ public override void ConfigureServices(IServiceCollection services) { services.AddScoped(); services.AddScoped(); - services.AddScoped, ReverseProxySettingsDisplayDriver>(); + services.AddSiteDisplayDriver(); services.AddSingleton(); diff --git a/src/OrchardCore.Modules/OrchardCore.Search.AzureAI/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Search.AzureAI/Startup.cs index ed3a62b98ed..aa08615d1b6 100644 --- a/src/OrchardCore.Modules/OrchardCore.Search.AzureAI/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Search.AzureAI/Startup.cs @@ -10,7 +10,6 @@ using OrchardCore.Search.AzureAI.Drivers; using OrchardCore.Search.AzureAI.Handlers; using OrchardCore.Search.AzureAI.Services; -using OrchardCore.Settings; namespace OrchardCore.Search.AzureAI; @@ -20,7 +19,7 @@ public override void ConfigureServices(IServiceCollection services) { services.AddAzureAISearchServices(); services.AddScoped(); - services.AddScoped, AzureAISearchDefaultSettingsDisplayDriver>(); + services.AddSiteDisplayDriver(); } } @@ -29,7 +28,7 @@ public sealed class SearchStartup : StartupBase { public override void ConfigureServices(IServiceCollection services) { - services.AddScoped, AzureAISearchSettingsDisplayDriver>(); + services.AddSiteDisplayDriver(); services.AddScoped(); services.AddScoped(); } diff --git a/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Startup.cs index 093bbc6aa3d..71bbf78ba0c 100644 --- a/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Startup.cs @@ -27,7 +27,6 @@ using OrchardCore.Search.Elasticsearch.Services; using OrchardCore.Search.Lucene.Handler; using OrchardCore.Security.Permissions; -using OrchardCore.Settings; namespace OrchardCore.Search.Elasticsearch; @@ -108,7 +107,7 @@ public sealed class SearchStartup : StartupBase public override void ConfigureServices(IServiceCollection services) { services.AddScoped(); - services.AddScoped, ElasticSettingsDisplayDriver>(); + services.AddSiteDisplayDriver(); services.AddScoped(); } } diff --git a/src/OrchardCore.Modules/OrchardCore.Search.Lucene/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Search.Lucene/Startup.cs index 4db6f1ee0d4..fc9644884a2 100644 --- a/src/OrchardCore.Modules/OrchardCore.Search.Lucene/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Search.Lucene/Startup.cs @@ -25,7 +25,6 @@ using OrchardCore.Search.Lucene.Services; using OrchardCore.Search.Lucene.Settings; using OrchardCore.Security.Permissions; -using OrchardCore.Settings; namespace OrchardCore.Search.Lucene; @@ -69,7 +68,7 @@ public sealed class SearchStartup : StartupBase public override void ConfigureServices(IServiceCollection services) { services.AddScoped(); - services.AddScoped, LuceneSettingsDisplayDriver>(); + services.AddSiteDisplayDriver(); services.AddScoped(); } } diff --git a/src/OrchardCore.Modules/OrchardCore.Search/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Search/Startup.cs index cd278c1676d..f75a3c62778 100644 --- a/src/OrchardCore.Modules/OrchardCore.Search/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Search/Startup.cs @@ -18,7 +18,6 @@ using OrchardCore.Search.Models; using OrchardCore.Search.ViewModels; using OrchardCore.Security.Permissions; -using OrchardCore.Settings; namespace OrchardCore.Search; @@ -32,7 +31,7 @@ public override void ConfigureServices(IServiceCollection services) services.AddTransient, SearchSettingsConfiguration>(); services.AddScoped(); services.AddScoped(); - services.AddScoped, SearchSettingsDisplayDriver>(); + services.AddSiteDisplayDriver(); services.AddContentPart() .UseDisplayDriver(); diff --git a/src/OrchardCore.Modules/OrchardCore.Security/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Security/Startup.cs index f9dea13cdee..c233898b851 100644 --- a/src/OrchardCore.Modules/OrchardCore.Security/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Security/Startup.cs @@ -9,7 +9,6 @@ using OrchardCore.Security.Permissions; using OrchardCore.Security.Services; using OrchardCore.Security.Settings; -using OrchardCore.Settings; namespace OrchardCore.Security; @@ -21,7 +20,7 @@ public override int Order public override void ConfigureServices(IServiceCollection services) { services.AddScoped(); - services.AddScoped, SecuritySettingsDisplayDriver>(); + services.AddSiteDisplayDriver(); services.AddScoped(); services.AddSingleton(); diff --git a/src/OrchardCore.Modules/OrchardCore.Seo/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Seo/Startup.cs index 4246f6da8e9..2797efff106 100644 --- a/src/OrchardCore.Modules/OrchardCore.Seo/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Seo/Startup.cs @@ -16,7 +16,6 @@ using OrchardCore.Seo.Models; using OrchardCore.Seo.Services; using OrchardCore.SeoMeta.Settings; -using OrchardCore.Settings; namespace OrchardCore.Seo; @@ -38,7 +37,7 @@ public override void ConfigureServices(IServiceCollection services) services.AddScoped(); services.AddScoped(); - services.AddScoped, RobotsSettingsDisplayDriver>(); + services.AddSiteDisplayDriver(); services.AddScoped(); services.AddTransient(); } diff --git a/src/OrchardCore.Modules/OrchardCore.Settings/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Settings/Startup.cs index 3ca02e824af..a2fa1e98a1a 100644 --- a/src/OrchardCore.Modules/OrchardCore.Settings/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Settings/Startup.cs @@ -71,8 +71,8 @@ public override void ConfigureServices(IServiceCollection services) services.AddSingleton(); // Site Settings editor - services.AddScoped, DefaultSiteSettingsDisplayDriver>(); - services.AddScoped, ButtonsSettingsDisplayDriver>(); + services.AddSiteDisplayDriver(); + services.AddSiteDisplayDriver(); services.AddScoped(); services.AddScoped(); diff --git a/src/OrchardCore.Modules/OrchardCore.Sitemaps/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Sitemaps/Startup.cs index b8062490079..a6fda6cb24a 100644 --- a/src/OrchardCore.Modules/OrchardCore.Sitemaps/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Sitemaps/Startup.cs @@ -14,7 +14,6 @@ using OrchardCore.Routing; using OrchardCore.Security.Permissions; using OrchardCore.Seo; -using OrchardCore.Settings; using OrchardCore.Sitemaps.Builders; using OrchardCore.Sitemaps.Cache; using OrchardCore.Sitemaps.Deployment; @@ -131,6 +130,6 @@ public sealed class SeoStartup : StartupBase public override void ConfigureServices(IServiceCollection services) { services.AddTransient(); - services.AddScoped, SitemapsRobotsSettingsDisplayDriver>(); + services.AddSiteDisplayDriver(); } } diff --git a/src/OrchardCore.Modules/OrchardCore.Sms/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Sms/Startup.cs index 1e9cb2f1d86..2020d77e941 100644 --- a/src/OrchardCore.Modules/OrchardCore.Sms/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Sms/Startup.cs @@ -5,7 +5,6 @@ using OrchardCore.Navigation; using OrchardCore.Notifications; using OrchardCore.Security.Permissions; -using OrchardCore.Settings; using OrchardCore.Sms.Activities; using OrchardCore.Sms.Drivers; using OrchardCore.Sms.Services; @@ -33,11 +32,11 @@ public override void ConfigureServices(IServiceCollection services) } services.AddTwilioSmsProvider() - .AddScoped, TwilioSettingsDisplayDriver>(); + .AddSiteDisplayDriver(); services.AddScoped(); services.AddScoped(); - services.AddScoped, SmsSettingsDisplayDriver>(); + services.AddSiteDisplayDriver(); } } diff --git a/src/OrchardCore.Modules/OrchardCore.Taxonomies/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Taxonomies/Startup.cs index 5f70871c8c3..32a9f6acb2f 100644 --- a/src/OrchardCore.Modules/OrchardCore.Taxonomies/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Taxonomies/Startup.cs @@ -16,7 +16,6 @@ using OrchardCore.Modules; using OrchardCore.Navigation; using OrchardCore.Security.Permissions; -using OrchardCore.Settings; using OrchardCore.Settings.Deployment; using OrchardCore.Taxonomies.Drivers; using OrchardCore.Taxonomies.Fields; @@ -87,7 +86,7 @@ public override void ConfigureServices(IServiceCollection services) services.AddScoped, TaxonomyContentsAdminListDisplayDriver>(); services.AddScoped(); - services.AddScoped, TaxonomyContentsAdminListSettingsDisplayDriver>(); + services.AddSiteDisplayDriver(); } } diff --git a/src/OrchardCore.Modules/OrchardCore.Twitter/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Twitter/Startup.cs index 8c0fcfb076e..b5ac28602c9 100644 --- a/src/OrchardCore.Modules/OrchardCore.Twitter/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Twitter/Startup.cs @@ -9,7 +9,6 @@ using OrchardCore.Navigation; using OrchardCore.Recipes; using OrchardCore.Security.Permissions; -using OrchardCore.Settings; using OrchardCore.Twitter.Drivers; using OrchardCore.Twitter.Recipes; using OrchardCore.Twitter.Services; @@ -34,7 +33,7 @@ public sealed class TwitterStartup : StartupBase { public override void ConfigureServices(IServiceCollection services) { - services.AddScoped, TwitterSettingsDisplayDriver>(); + services.AddSiteDisplayDriver(); services.AddScoped(); services.AddSingleton(); @@ -68,7 +67,7 @@ public override void ConfigureServices(IServiceCollection services) { services.AddScoped(); services.AddSingleton(); - services.AddScoped, TwitterSigninSettingsDisplayDriver>(); + services.AddSiteDisplayDriver(); // Register the options initializers required by the Twitter Handler. services.TryAddEnumerable(new[] { diff --git a/src/OrchardCore.Modules/OrchardCore.Users/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Users/Startup.cs index 05794b189fc..48ff97c6d6e 100644 --- a/src/OrchardCore.Modules/OrchardCore.Users/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Users/Startup.cs @@ -33,7 +33,6 @@ using OrchardCore.ResourceManagement; using OrchardCore.Security; using OrchardCore.Security.Permissions; -using OrchardCore.Settings; using OrchardCore.Settings.Deployment; using OrchardCore.Setup.Events; using OrchardCore.Sms; @@ -206,7 +205,7 @@ public override void ConfigureServices(IServiceCollection services) services.AddScoped(); services.AddScoped(); - services.AddScoped, LoginSettingsDisplayDriver>(); + services.AddSiteDisplayDriver(); services.AddScoped, UserDisplayDriver>(); services.AddScoped, UserInformationDisplayDriver>(); @@ -368,7 +367,7 @@ public override void ConfigureServices(IServiceCollection services) }); services.AddScoped(); - services.AddScoped, ChangeEmailSettingsDisplayDriver>(); + services.AddSiteDisplayDriver(); services.AddScoped, ChangeEmailUserMenuDisplayDriver>(); } } @@ -435,7 +434,7 @@ public override void ConfigureServices(IServiceCollection services) }); services.AddScoped(); - services.AddScoped, RegistrationSettingsDisplayDriver>(); + services.AddSiteDisplayDriver(); services.AddScoped, RegisterUserLoginFormDisplayDriver>(); services.AddScoped, RegisterUserFormDisplayDriver>(); } @@ -516,7 +515,7 @@ public override void ConfigureServices(IServiceCollection services) }); services.AddScoped(); - services.AddScoped, ResetPasswordSettingsDisplayDriver>(); + services.AddSiteDisplayDriver(); services.AddScoped, ResetPasswordFormDisplayDriver>(); services.AddScoped, ForgotPasswordLoginFormDisplayDriver>(); diff --git a/src/OrchardCore.Modules/OrchardCore.Users/TwoFactorAuthenticationStartup.cs b/src/OrchardCore.Modules/OrchardCore.Users/TwoFactorAuthenticationStartup.cs index 787b3a23fce..20629391bb6 100644 --- a/src/OrchardCore.Modules/OrchardCore.Users/TwoFactorAuthenticationStartup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Users/TwoFactorAuthenticationStartup.cs @@ -7,7 +7,6 @@ using OrchardCore.DisplayManagement.Handlers; using OrchardCore.Modules; using OrchardCore.Mvc.Core.Utilities; -using OrchardCore.Settings; using OrchardCore.Users.Controllers; using OrchardCore.Users.Drivers; using OrchardCore.Users.Endpoints.EmailAuthenticator; @@ -35,7 +34,7 @@ public override void ConfigureServices(IServiceCollection services) services.AddScoped(); services.AddScoped, TwoFactorUserMenuDisplayDriver>(); - services.AddScoped, TwoFactorLoginSettingsDisplayDriver>(); + services.AddSiteDisplayDriver(); services.AddScoped, TwoFactorMethodDisplayDriver>(); } @@ -116,7 +115,7 @@ public sealed class RoleTwoFactorAuthenticationStartup : StartupBase { public override void ConfigureServices(IServiceCollection services) { - services.AddScoped, RoleLoginSettingsDisplayDriver>(); + services.AddSiteDisplayDriver(); services.AddScoped(); } } @@ -137,7 +136,7 @@ public override void ConfigureServices(IServiceCollection services) }); services.AddTransient, AuthenticatorAppProviderTwoFactorOptionsConfiguration>(); - services.AddScoped, AuthenticatorAppLoginSettingsDisplayDriver>(); + services.AddSiteDisplayDriver(); services.AddScoped, TwoFactorMethodLoginAuthenticationAppDisplayDriver>(); } @@ -183,7 +182,7 @@ public override void ConfigureServices(IServiceCollection services) }); services.AddScoped, TwoFactorMethodLoginEmailDisplayDriver>(); - services.AddScoped, EmailAuthenticatorLoginSettingsDisplayDriver>(); + services.AddSiteDisplayDriver(); } public override void Configure(IApplicationBuilder app, IEndpointRouteBuilder routes, IServiceProvider serviceProvider) @@ -207,7 +206,7 @@ public override void ConfigureServices(IServiceCollection services) services.AddTransient, PhoneProviderTwoFactorOptionsConfiguration>(); services.AddScoped, TwoFactorMethodLoginSmsDisplayDriver>(); - services.AddScoped, SmsAuthenticatorLoginSettingsDisplayDriver>(); + services.AddSiteDisplayDriver(); } public override void Configure(IApplicationBuilder app, IEndpointRouteBuilder routes, IServiceProvider serviceProvider) diff --git a/src/OrchardCore.Modules/OrchardCore.Workflows/Trimming/Extensions/ServiceCollectionExtensions.cs b/src/OrchardCore.Modules/OrchardCore.Workflows/Trimming/Extensions/ServiceCollectionExtensions.cs index f927e318a79..c498089b5fb 100644 --- a/src/OrchardCore.Modules/OrchardCore.Workflows/Trimming/Extensions/ServiceCollectionExtensions.cs +++ b/src/OrchardCore.Modules/OrchardCore.Workflows/Trimming/Extensions/ServiceCollectionExtensions.cs @@ -2,7 +2,6 @@ using OrchardCore.DisplayManagement.Handlers; using OrchardCore.Environment.Shell.Configuration; using OrchardCore.Navigation; -using OrchardCore.Settings; using OrchardCore.Workflows.Trimming; using OrchardCore.Workflows.Trimming.Drivers; using OrchardCore.Workflows.Trimming.Services; @@ -15,7 +14,7 @@ public static IServiceCollection AddTrimmingServices(this IServiceCollection ser { services.AddScoped(); services.AddSingleton(); - services.AddScoped, WorkflowTrimmingDisplayDriver>(); + services.AddSiteDisplayDriver(); services.AddScoped(); services.Configure(shellConfiguration.GetSection("OrchardCore_Workflows:Trimming")); diff --git a/src/OrchardCore/OrchardCore.DisplayManagement/SiteServiceCollectionExtensions.cs b/src/OrchardCore/OrchardCore.DisplayManagement/SiteServiceCollectionExtensions.cs new file mode 100644 index 00000000000..6b2af4f9bef --- /dev/null +++ b/src/OrchardCore/OrchardCore.DisplayManagement/SiteServiceCollectionExtensions.cs @@ -0,0 +1,13 @@ +using Microsoft.Extensions.DependencyInjection; +using OrchardCore.Settings; + +namespace OrchardCore.DisplayManagement.Handlers; + +public static class SiteServiceCollectionExtensions +{ + public static IServiceCollection AddSiteDisplayDriver(this IServiceCollection services) + where TDriver : class, IDisplayDriver + { + return services.AddScoped, TDriver>(); + } +} diff --git a/src/docs/releases/2.0.0.md b/src/docs/releases/2.0.0.md index 7bc02ae540c..b52897693ed 100644 --- a/src/docs/releases/2.0.0.md +++ b/src/docs/releases/2.0.0.md @@ -314,10 +314,11 @@ and removed the following methods: A new `SiteDisplayDriver` base class was introduced to simplify the process of adding a UI settings. - !!! note With the new `SiteDisplayDriver` base class for custom settings, you no longer need explicit checks like `context.GroupId.Equals(GroupId, StringComparison.OrdinalIgnoreCase)` as the base class handles this check for you. +A new extension has been introduced to simplify the registration of site setting drivers. Instead of using `service.AddScoped, CustomSettingsDisplayDriver>()`, you can now register it with the more streamlined `service.AddSiteDisplayDriver()`. + Similarly, the `ContentPartDisplayDriver` base class have undergone modifications. The following methods were marked obsolete: - `IDisplayResult Display(TPart part)`