Skip to content

Commit

Permalink
Register DisplayDrivers with ContentOptions (#4361)
Browse files Browse the repository at this point in the history
  • Loading branch information
deanmarcussen authored and hishamco committed Feb 18, 2020
1 parent de23d15 commit 1e287b6
Show file tree
Hide file tree
Showing 48 changed files with 1,371 additions and 174 deletions.
7 changes: 4 additions & 3 deletions src/OrchardCore.Modules/OrchardCore.Alias/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ public override void ConfigureServices(IServiceCollection services)
services.AddScoped<IContentAliasProvider, AliasPartContentAliasProvider>();

// Identity Part
services.AddContentPart<AliasPart>();
services.AddScoped<IContentPartDisplayDriver, AliasPartDisplayDriver>();
services.AddScoped<IContentPartHandler, AliasPartHandler>();
services.AddContentPart<AliasPart>()
.UseDisplayDriver<AliasPartDisplayDriver>()
.AddHandler<AliasPartHandler>();

services.AddScoped<IContentPartIndexHandler, AliasPartIndexHandler>();
services.AddScoped<IContentTypePartDefinitionDisplayDriver, AliasPartSettingsDisplayDriver>();

Expand Down
8 changes: 4 additions & 4 deletions src/OrchardCore.Modules/OrchardCore.Autoroute/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
using OrchardCore.ContentManagement;
using OrchardCore.ContentManagement.Display.ContentDisplay;
using OrchardCore.ContentManagement.GraphQL.Options;
using OrchardCore.ContentManagement.Handlers;
using OrchardCore.ContentManagement.Records;
using OrchardCore.ContentManagement.Routing;
using OrchardCore.ContentTypes.Editors;
Expand All @@ -43,10 +42,11 @@ static Startup()
public override void ConfigureServices(IServiceCollection services)
{
// Autoroute Part
services.AddContentPart<AutoroutePart>();
services.AddScoped<IContentPartDisplayDriver, AutoroutePartDisplay>();
services.AddContentPart<AutoroutePart>()
.UseDisplayDriver<AutoroutePartDisplay>()
.AddHandler<AutoroutePartHandler>();

services.AddScoped<IPermissionProvider, Permissions>();
services.AddScoped<IContentPartHandler, AutoroutePartHandler>();
services.AddScoped<IContentTypePartDefinitionDisplayDriver, AutoroutePartSettingsDisplayDriver>();
services.AddScoped<IContentPartIndexHandler, AutoroutePartIndexHandler>();

Expand Down
44 changes: 22 additions & 22 deletions src/OrchardCore.Modules/OrchardCore.ContentFields/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,65 +57,65 @@ public Startup(IOptions<AdminOptions> adminOptions)
public override void ConfigureServices(IServiceCollection services)
{
// Boolean Field
services.AddContentField<BooleanField>();
services.AddScoped<IContentFieldDisplayDriver, BooleanFieldDisplayDriver>();
services.AddContentField<BooleanField>()
.UseDisplayDriver<BooleanFieldDisplayDriver>();
services.AddScoped<IContentPartFieldDefinitionDisplayDriver, BooleanFieldSettingsDriver>();
services.AddScoped<IContentFieldIndexHandler, BooleanFieldIndexHandler>();

// Text Field
services.AddContentField<TextField>();
services.AddScoped<IContentFieldDisplayDriver, TextFieldDisplayDriver>();
services.AddContentField<TextField>()
.UseDisplayDriver<TextFieldDisplayDriver>();
services.AddScoped<IContentPartFieldDefinitionDisplayDriver, TextFieldSettingsDriver>();
services.AddScoped<IContentFieldIndexHandler, TextFieldIndexHandler>();
services.AddScoped<IContentPartFieldDefinitionDisplayDriver, TextFieldPredefinedListEditorSettingsDriver>();
services.AddScoped<IContentPartFieldDefinitionDisplayDriver, TextFieldHeaderDisplaySettingsDriver>();

// Html Field
services.AddContentField<HtmlField>();
services.AddScoped<IContentFieldDisplayDriver, HtmlFieldDisplayDriver>();
services.AddContentField<HtmlField>()
.UseDisplayDriver<HtmlFieldDisplayDriver>();
services.AddScoped<IContentPartFieldDefinitionDisplayDriver, HtmlFieldSettingsDriver>();
services.AddScoped<IContentPartFieldDefinitionDisplayDriver, HtmlFieldTrumbowygEditorSettingsDriver>();
services.AddScoped<IContentFieldIndexHandler, HtmlFieldIndexHandler>();

// Link Field
services.AddContentField<LinkField>();
services.AddScoped<IContentFieldDisplayDriver, LinkFieldDisplayDriver>();
services.AddContentField<LinkField>()
.UseDisplayDriver<LinkFieldDisplayDriver>();
services.AddScoped<IContentPartFieldDefinitionDisplayDriver, LinkFieldSettingsDriver>();
services.AddScoped<IContentFieldIndexHandler, LinkFieldIndexHandler>();

// Numeric Field
services.AddContentField<NumericField>();
services.AddScoped<IContentFieldDisplayDriver, NumericFieldDisplayDriver>();
services.AddContentField<NumericField>()
.UseDisplayDriver<NumericFieldDisplayDriver>();
services.AddScoped<IContentPartFieldDefinitionDisplayDriver, NumericFieldSettingsDriver>();
services.AddScoped<IContentFieldIndexHandler, NumericFieldIndexHandler>();

// DateTime Field
services.AddContentField<DateTimeField>();
services.AddScoped<IContentFieldDisplayDriver, DateTimeFieldDisplayDriver>();
services.AddContentField<DateTimeField>()
.UseDisplayDriver<DateTimeFieldDisplayDriver>();
services.AddScoped<IContentPartFieldDefinitionDisplayDriver, DateTimeFieldSettingsDriver>();
services.AddScoped<IContentFieldIndexHandler, DateTimeFieldIndexHandler>();

// Date Field
services.AddContentField<DateField>();
services.AddScoped<IContentFieldDisplayDriver, DateFieldDisplayDriver>();
services.AddContentField<DateField>()
.UseDisplayDriver<DateFieldDisplayDriver>();
services.AddScoped<IContentPartFieldDefinitionDisplayDriver, DateFieldSettingsDriver>();
services.AddScoped<IContentFieldIndexHandler, DateFieldIndexHandler>();

// Time Field
services.AddContentField<TimeField>();
services.AddScoped<IContentFieldDisplayDriver, TimeFieldDisplayDriver>();
services.AddContentField<TimeField>()
.UseDisplayDriver<TimeFieldDisplayDriver>();
services.AddScoped<IContentPartFieldDefinitionDisplayDriver, TimeFieldSettingsDriver>();
services.AddScoped<IContentFieldIndexHandler, TimeFieldIndexHandler>();

// Video field
services.AddContentField<YoutubeField>();
services.AddScoped<IContentFieldDisplayDriver, YoutubeFieldDisplayDriver>();
services.AddContentField<YoutubeField>()
.UseDisplayDriver<YoutubeFieldDisplayDriver>();
services.AddScoped<IContentPartFieldDefinitionDisplayDriver, YoutubeFieldSettingsDriver>();
services.AddScoped<IContentFieldIndexHandler, YoutubeFieldIndexHandler>();

// Content picker field
services.AddContentField<ContentPickerField>();
services.AddScoped<IContentFieldDisplayDriver, ContentPickerFieldDisplayDriver>();
services.AddContentField<ContentPickerField>()
.UseDisplayDriver<ContentPickerFieldDisplayDriver>();
services.AddScoped<IContentPartFieldDefinitionDisplayDriver, ContentPickerFieldSettingsDriver>();
services.AddScoped<IContentFieldIndexHandler, ContentPickerFieldIndexHandler>();
services.AddScoped<IContentPickerResultProvider, DefaultContentPickerResultProvider>();
Expand Down Expand Up @@ -147,8 +147,8 @@ public LocalizationSetContentPickerStartup(IOptions<AdminOptions> adminOptions)

public override void ConfigureServices(IServiceCollection services)
{
services.AddContentField<LocalizationSetContentPickerField>();
services.AddScoped<IContentFieldDisplayDriver, LocalizationSetContentPickerFieldDisplayDriver>();
services.AddContentField<LocalizationSetContentPickerField>()
.UseDisplayDriver<LocalizationSetContentPickerFieldDisplayDriver>();
services.AddScoped<IContentPartFieldDefinitionDisplayDriver, LocalizationSetContentPickerFieldSettingsDriver>();
services.AddScoped<IContentFieldIndexHandler, LocalizationSetContentPickerFieldIndexHandler>();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using OrchardCore.ContentLocalization.Drivers;
using OrchardCore.ContentLocalization.Handlers;
using OrchardCore.ContentLocalization.Models;
using OrchardCore.ContentLocalization.Records;
using OrchardCore.ContentManagement;
using OrchardCore.ContentManagement.Display.ContentDisplay;
using OrchardCore.Data.Migration;
using YesSql.Indexes;

Expand All @@ -13,7 +15,9 @@ public static class ServiceCollectionExtensions
{
public static IServiceCollection AddContentLocalization(this IServiceCollection services)
{
services.AddContentPart<LocalizationPart>();
services.AddContentPart<LocalizationPart>()
.UseDisplayDriver<LocalizationPartDisplayDriver>()
.AddHandler<LocalizationPartHandler>();

services.TryAddScoped<IContentLocalizationManager, DefaultContentLocalizationManager>();
services.AddSingleton<IIndexProvider, LocalizedContentItemIndexProvider>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
using System;
using System.Globalization;
using System.Linq;
using Fluid;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Fluid;
using OrchardCore.Admin;
using OrchardCore.ContentLocalization.Controllers;
using OrchardCore.ContentLocalization.Drivers;
using OrchardCore.ContentLocalization.Handlers;
using OrchardCore.ContentLocalization.Indexing;
using OrchardCore.ContentLocalization.Liquid;
using OrchardCore.ContentLocalization.Models;
using OrchardCore.ContentLocalization.Records;
using OrchardCore.ContentLocalization.Security;
using OrchardCore.ContentLocalization.Services;
using OrchardCore.ContentLocalization.ViewModels;
using OrchardCore.ContentManagement.Display.ContentDisplay;
using OrchardCore.ContentManagement.Handlers;
using OrchardCore.DisplayManagement.Handlers;
using OrchardCore.Indexing;
using OrchardCore.Liquid;
Expand Down Expand Up @@ -48,10 +45,8 @@ public Startup(IOptions<AdminOptions> adminOptions)

public override void ConfigureServices(IServiceCollection services)
{
services.AddScoped<IContentPartDisplayDriver, LocalizationPartDisplayDriver>();
services.AddScoped<IContentPartIndexHandler, LocalizationPartIndexHandler>();
services.AddSingleton<ILocalizationEntries, LocalizationEntries>();
services.AddScoped<IContentPartHandler, LocalizationPartHandler>();
services.AddContentLocalization();

services.AddScoped<IPermissionProvider, Permissions>();
Expand Down
7 changes: 4 additions & 3 deletions src/OrchardCore.Modules/OrchardCore.ContentPreview/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ public override void ConfigureServices(IServiceCollection services)
services.AddScoped<IPermissionProvider, Permissions>();

// Preview Part
services.AddContentPart<PreviewPart>();
services.AddScoped<IDataMigration, Migrations>();
services.AddScoped<IContentPartHandler, PreviewPartHandler>();
services.AddContentPart<PreviewPart>()
.AddHandler<PreviewPartHandler>();

services.AddScoped<IDataMigration, Migrations>();
services.AddScoped<IContentTypePartDefinitionDisplayDriver, PreviewPartSettingsDisplayDriver>();
services.TryAddEnumerable(ServiceDescriptor.Singleton<IStartupFilter, PreviewStartupFilter>());
}
Expand Down
6 changes: 3 additions & 3 deletions src/OrchardCore.Modules/OrchardCore.Contents/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ public override void ConfigureServices(IServiceCollection services)
services.AddScoped<IDataMigration, Migrations>();

// Common Part
services.AddContentPart<CommonPart>();
services.AddContentPart<CommonPart>()
.UseDisplayDriver<DateEditorDriver>()
.UseDisplayDriver<OwnerEditorDriver>();

services.AddScoped<IContentTypePartDefinitionDisplayDriver, CommonPartSettingsDisplayDriver>();
services.AddScoped<IContentPartDisplayDriver, DateEditorDriver>();
services.AddScoped<IContentPartDisplayDriver, OwnerEditorDriver>();

// FullTextAspect
services.AddScoped<IContentTypeDefinitionDisplayDriver, FullTextAspectSettingsDisplayDriver>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ public override void ConfigureServices(IServiceCollection services)
services.AddScoped<IDataMigration, WidgetMigrations>();
services.AddScoped<IShapeTableProvider, LiquidShapes>();

services.AddScoped<IContentPartDisplayDriver, FacebookPluginPartDisplayDriver>();
services.AddContentPart<FacebookPluginPart>();
services.AddScoped<IContentPartHandler, FacebookPluginPartHandler>();
services.AddContentPart<FacebookPluginPart>()
.UseDisplayDriver<FacebookPluginPartDisplayDriver>()
.AddHandler<FacebookPluginPartHandler>();

services.AddScoped<IContentTypePartDefinitionDisplayDriver, FacebookPluginPartSettingsDisplayDriver>();
}
}
Expand Down
9 changes: 5 additions & 4 deletions src/OrchardCore.Modules/OrchardCore.Flows/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,14 @@ public Startup(IOptions<AdminOptions> adminOptions)
public override void ConfigureServices(IServiceCollection services)
{
// Flow Part
services.AddScoped<IContentPartDisplayDriver, FlowPartDisplay>();
services.AddContentPart<FlowPart>();
services.AddContentPart<FlowPart>()
.UseDisplayDriver<FlowPartDisplay>();

services.AddScoped<IContentDisplayDriver, FlowMetadataDisplay>();

// Bag Part
services.AddScoped<IContentPartDisplayDriver, BagPartDisplay>();
services.AddContentPart<BagPart>();
services.AddContentPart<BagPart>()
.UseDisplayDriver<BagPartDisplay>();
services.AddScoped<IContentTypePartDefinitionDisplayDriver, BagPartSettingsDisplayDriver>();
services.AddScoped<IContentPartIndexHandler, BagPartIndexHandler>();

Expand Down
47 changes: 26 additions & 21 deletions src/OrchardCore.Modules/OrchardCore.Forms/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,27 +33,32 @@ public override void ConfigureServices(IServiceCollection services)
options.Filters.Add<ImportModelStatePageFilter>();
});

services.AddScoped<IContentPartDisplayDriver, FormPartDisplay>();
services.AddScoped<IContentPartDisplayDriver, FormElementPartDisplay>();
services.AddScoped<IContentPartDisplayDriver, FormInputElementPartDisplay>();
services.AddScoped<IContentPartDisplayDriver, ButtonPartDisplay>();
services.AddScoped<IContentPartDisplayDriver, LabelPartDisplay>();
services.AddScoped<IContentPartDisplayDriver, InputPartDisplay>();
services.AddScoped<IContentPartDisplayDriver, TextAreaPartDisplay>();
services.AddScoped<IContentPartDisplayDriver, ValidationSummaryPartDisplay>();
services.AddScoped<IContentPartDisplayDriver, ValidationPartDisplay>();

services
.AddContentPart<FormPart>()
.AddContentPart<FormElementPart>()
.AddContentPart<FormInputElementPart>()
.AddContentPart<LabelPart>()
.AddContentPart<ButtonPart>()
.AddContentPart<InputPart>()
.AddContentPart<TextAreaPart>()
.AddContentPart<ValidationSummaryPart>()
.AddContentPart<ValidationPart>()
;
services.AddContentPart<FormPart>()
.UseDisplayDriver<FormPartDisplay>();

services.AddContentPart<FormElementPart>()
.UseDisplayDriver<FormElementPartDisplay>();

services.AddContentPart<FormInputElementPart>()
.UseDisplayDriver<FormInputElementPartDisplay>();

services.AddContentPart<LabelPart>()
.UseDisplayDriver<LabelPartDisplay>();

services.AddContentPart<ButtonPart>()
.UseDisplayDriver<ButtonPartDisplay>();

services.AddContentPart<InputPart>()
.UseDisplayDriver<InputPartDisplay>();

services.AddContentPart<TextAreaPart>()
.UseDisplayDriver<TextAreaPartDisplay>();

services.AddContentPart<ValidationSummaryPart>()
.UseDisplayDriver<ValidationSummaryPartDisplay>();

services.AddContentPart<ValidationPart>()
.UseDisplayDriver<ValidationPartDisplay>();

services.AddScoped<IDataMigration, Migrations>();
}
Expand Down
16 changes: 8 additions & 8 deletions src/OrchardCore.Modules/OrchardCore.Html/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
using Fluid;
using Microsoft.Extensions.DependencyInjection;
using OrchardCore.ContentManagement;
using OrchardCore.ContentManagement.Display.ContentDisplay;
using OrchardCore.ContentTypes.Editors;
using OrchardCore.Data.Migration;
using OrchardCore.Html.Drivers;
using OrchardCore.Html.Handlers;
using OrchardCore.Html.Indexing;
using OrchardCore.Html.Models;
using OrchardCore.Html.Settings;
using OrchardCore.Html.ViewModels;
using OrchardCore.ContentManagement;
using OrchardCore.ContentManagement.Display.ContentDisplay;
using OrchardCore.ContentManagement.Handlers;
using OrchardCore.ContentTypes.Editors;
using OrchardCore.Data.Migration;
using OrchardCore.Indexing;
using OrchardCore.Modules;

Expand All @@ -26,13 +25,14 @@ static Startup()
public override void ConfigureServices(IServiceCollection services)
{
// Body Part
services.AddContentPart<HtmlBodyPart>();
services.AddScoped<IContentPartDisplayDriver, HtmlBodyPartDisplay>();
services.AddContentPart<HtmlBodyPart>()
.UseDisplayDriver<HtmlBodyPartDisplay>()
.AddHandler<HtmlBodyPartHandler>();

services.AddScoped<IContentTypePartDefinitionDisplayDriver, HtmlBodyPartSettingsDisplayDriver>();
services.AddScoped<IContentTypePartDefinitionDisplayDriver, HtmlBodyPartTrumbowygEditorSettingsDriver>();
services.AddScoped<IDataMigration, Migrations>();
services.AddScoped<IContentPartIndexHandler, HtmlBodyPartIndexHandler>();
services.AddScoped<IContentPartHandler, HtmlBodyPartHandler>();
}
}
}
10 changes: 5 additions & 5 deletions src/OrchardCore.Modules/OrchardCore.Liquid/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using Newtonsoft.Json.Linq;
using OrchardCore.ContentManagement;
using OrchardCore.ContentManagement.Display.ContentDisplay;
using OrchardCore.ContentManagement.Handlers;
using OrchardCore.ContentManagement.Metadata.Models;
using OrchardCore.Data.Migration;
using OrchardCore.DisplayManagement.Descriptors;
Expand Down Expand Up @@ -65,12 +64,13 @@ public class LiquidPartStartup : StartupBase
public override void ConfigureServices(IServiceCollection services)
{
// Liquid Part
services.AddScoped<IContentPartDisplayDriver, LiquidPartDisplay>();
services.AddScoped<IShapeTableProvider, LiquidShapes>();
services.AddContentPart<LiquidPart>();
services.AddContentPart<LiquidPart>()
.UseDisplayDriver<LiquidPartDisplay>()
.AddHandler<LiquidPartHandler>();

services.AddScoped<IDataMigration, Migrations>();
services.AddScoped<IContentPartIndexHandler, LiquidPartIndexHandler>();
services.AddScoped<IContentPartHandler, LiquidPartHandler>();
}
}
}
}
Loading

0 comments on commit 1e287b6

Please sign in to comment.