From aaced541e33d8b9a3f0e951d80da63e20846e0c3 Mon Sep 17 00:00:00 2001 From: Lombiq Date: Mon, 4 Jan 2016 19:09:00 +0100 Subject: [PATCH] Adding WithIdentity() content metadata helper to add IdentityPart in migrations and changing affected code to use this --- .../Extensions/CommonMetaDataExtensions.cs | 17 +++++++++++++ src/Orchard.Web/Core/Navigation/Migrations.cs | 14 +++++------ src/Orchard.Web/Core/Orchard.Core.csproj | 1 + .../Orchard.Azure.MediaServices/Migrations.cs | 2 +- .../Modules/Orchard.Blogs/Migrations.cs | 6 ++--- .../Modules/Orchard.Comments/Migrations.cs | 4 ++-- .../Orchard.ContentPicker/Migrations.cs | 2 +- .../Modules/Orchard.CustomForms/Migrations.cs | 2 +- .../Modules/Orchard.Dashboards/Migrations.cs | 2 +- .../Orchard.DynamicForms/Migrations.cs | 2 +- .../Modules/Orchard.Layouts/Migrations.cs | 8 +++---- .../Orchard.MediaLibrary/Migrations.cs | 24 +++++++++---------- .../Orchard.MediaProcessing/Migrations.cs | 2 +- .../Modules/Orchard.Projections/Migrations.cs | 6 ++--- .../Modules/Orchard.Search/Migrations.cs | 2 +- .../Orchard.Search/Orchard.Search.csproj | 4 ++++ .../Migrations/Migrations.cs | 2 +- .../Extensions/WidgetsMetaDataExtensions.cs | 4 ++-- .../Modules/Orchard.Widgets/Migrations.cs | 2 +- 19 files changed, 64 insertions(+), 42 deletions(-) create mode 100644 src/Orchard.Web/Core/Common/Extensions/CommonMetaDataExtensions.cs diff --git a/src/Orchard.Web/Core/Common/Extensions/CommonMetaDataExtensions.cs b/src/Orchard.Web/Core/Common/Extensions/CommonMetaDataExtensions.cs new file mode 100644 index 000000000..e2239064a --- /dev/null +++ b/src/Orchard.Web/Core/Common/Extensions/CommonMetaDataExtensions.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using Orchard.ContentManagement.MetaData.Builders; + +namespace Orchard.ContentManagement.MetaData { + public static class CommonMetaDataExtensions { + /// + /// Adds IdentityPart to the content type. + /// + /// The ContentTypeDefinitionBuilder object on which this method is called. + public static ContentTypeDefinitionBuilder WithIdentity(this ContentTypeDefinitionBuilder builder) { + return builder.WithPart("IdentityPart"); + } + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Core/Navigation/Migrations.cs b/src/Orchard.Web/Core/Navigation/Migrations.cs index 48f891805..861c11004 100644 --- a/src/Orchard.Web/Core/Navigation/Migrations.cs +++ b/src/Orchard.Web/Core/Navigation/Migrations.cs @@ -20,7 +20,7 @@ namespace Orchard.Core.Navigation { ContentDefinitionManager.AlterTypeDefinition("MenuItem", cfg => cfg .WithPart("MenuPart") - .WithPart("IdentityPart") + .WithIdentity() .WithPart("CommonPart") .DisplayedAs("Custom Link") .WithSetting("Description", "Represents a simple custom link with a text and an url.") @@ -34,7 +34,7 @@ namespace Orchard.Core.Navigation { ContentDefinitionManager.AlterTypeDefinition("MenuWidget", cfg => cfg .WithPart("CommonPart") - .WithPart("IdentityPart") + .WithIdentity() .WithPart("WidgetPart") .WithPart("MenuWidgetPart") .WithSetting("Stereotype", "Widget") @@ -52,7 +52,7 @@ namespace Orchard.Core.Navigation { .WithPart("MenuPart") .WithPart("BodyPart") .WithPart("CommonPart") - .WithPart("IdentityPart") + .WithIdentity() .DisplayedAs("Html Menu Item") .WithSetting("Description", "Renders some custom HTML in the menu.") .WithSetting("BodyPartSettings.FlavorDefault", "html") @@ -92,7 +92,7 @@ namespace Orchard.Core.Navigation { ContentDefinitionManager.AlterTypeDefinition("MenuItem", cfg => cfg .WithPart("MenuPart") .WithPart("CommonPart") - .WithPart("IdentityPart") + .WithIdentity() .DisplayedAs("Custom Link") .WithSetting("Description", "Represents a simple custom link with a text and an url.") .WithSetting("Stereotype", "MenuItem") // because we declare a new stereotype, the Shape MenuItem_Edit is needed @@ -115,7 +115,7 @@ namespace Orchard.Core.Navigation { ContentDefinitionManager.AlterTypeDefinition("MenuWidget", cfg => cfg .WithPart("CommonPart") - .WithPart("IdentityPart") + .WithIdentity() .WithPart("WidgetPart") .WithPart("MenuWidgetPart") .WithSetting("Stereotype", "Widget") @@ -130,7 +130,7 @@ namespace Orchard.Core.Navigation { .WithPart("MenuPart") .WithPart("BodyPart") .WithPart("CommonPart") - .WithPart("IdentityPart") + .WithIdentity() .DisplayedAs("Html Menu Item") .WithSetting("Description", "Renders some custom HTML in the menu.") .WithSetting("BodyPartSettings.FlavorDefault", "html") @@ -172,7 +172,7 @@ namespace Orchard.Core.Navigation { public int UpdateFrom5() { ContentDefinitionManager.AlterTypeDefinition("Menu", cfg => cfg - .WithPart("IdentityPart") + .WithIdentity() ); return 6; diff --git a/src/Orchard.Web/Core/Orchard.Core.csproj b/src/Orchard.Web/Core/Orchard.Core.csproj index 36cbc19b0..00d6532fb 100644 --- a/src/Orchard.Web/Core/Orchard.Core.csproj +++ b/src/Orchard.Web/Core/Orchard.Core.csproj @@ -77,6 +77,7 @@ + diff --git a/src/Orchard.Web/Modules/Orchard.Azure.MediaServices/Migrations.cs b/src/Orchard.Web/Modules/Orchard.Azure.MediaServices/Migrations.cs index 97580b798..57067be36 100644 --- a/src/Orchard.Web/Modules/Orchard.Azure.MediaServices/Migrations.cs +++ b/src/Orchard.Web/Modules/Orchard.Azure.MediaServices/Migrations.cs @@ -66,7 +66,7 @@ namespace Orchard.Azure.MediaServices { ContentDefinitionManager.AlterTypeDefinition("CloudVideo", type => type .WithPart("CommonPart") - .WithPart("IdentityPart") + .WithIdentity() .WithPart("MediaPart") .WithPart("TitlePart") .WithPart("PublishLaterPart") diff --git a/src/Orchard.Web/Modules/Orchard.Blogs/Migrations.cs b/src/Orchard.Web/Modules/Orchard.Blogs/Migrations.cs index e4b00a464..60e0fcb54 100644 --- a/src/Orchard.Web/Modules/Orchard.Blogs/Migrations.cs +++ b/src/Orchard.Web/Modules/Orchard.Blogs/Migrations.cs @@ -80,7 +80,7 @@ namespace Orchard.Blogs { .WithPart("CommonPart") .WithPart("WidgetPart") .WithSetting("Stereotype", "Widget") - .WithPart("IdentityPart") + .WithIdentity() ); return 7; @@ -134,12 +134,12 @@ namespace Orchard.Blogs { public int UpdateFrom6() { ContentDefinitionManager.AlterTypeDefinition("RecentBlogPosts", cfg => cfg - .WithPart("IdentityPart") + .WithIdentity() ); ContentDefinitionManager.AlterTypeDefinition("BlogArchives", cfg => cfg - .WithPart("IdentityPart") + .WithIdentity() ); return 7; diff --git a/src/Orchard.Web/Modules/Orchard.Comments/Migrations.cs b/src/Orchard.Web/Modules/Orchard.Comments/Migrations.cs index 379c77d2c..9d6de0ece 100644 --- a/src/Orchard.Web/Modules/Orchard.Comments/Migrations.cs +++ b/src/Orchard.Web/Modules/Orchard.Comments/Migrations.cs @@ -56,7 +56,7 @@ namespace Orchard.Comments { p => p .WithSetting("OwnerEditorSettings.ShowOwnerEditor", "false") .WithSetting("DateEditorSettings.ShowDateEditor", "false")) - .WithPart("IdentityPart") + .WithIdentity() ); ContentDefinitionManager.AlterTypeDefinition("Blog", @@ -82,7 +82,7 @@ namespace Orchard.Comments { } public int UpdateFrom1() { - ContentDefinitionManager.AlterTypeDefinition("Comment", cfg => cfg.WithPart("IdentityPart")); + ContentDefinitionManager.AlterTypeDefinition("Comment", cfg => cfg.WithIdentity()); return 2; } diff --git a/src/Orchard.Web/Modules/Orchard.ContentPicker/Migrations.cs b/src/Orchard.Web/Modules/Orchard.ContentPicker/Migrations.cs index 405fcc978..91b73fabb 100644 --- a/src/Orchard.Web/Modules/Orchard.ContentPicker/Migrations.cs +++ b/src/Orchard.Web/Modules/Orchard.ContentPicker/Migrations.cs @@ -16,7 +16,7 @@ namespace Orchard.ContentPicker { ContentDefinitionManager.AlterTypeDefinition("ContentMenuItem", cfg => cfg .WithPart("MenuPart") .WithPart("CommonPart") - .WithPart("IdentityPart") + .WithIdentity() .WithPart("ContentMenuItemPart") .DisplayedAs("Content Menu Item") .WithSetting("Description", "Adds a Content Item to the menu.") diff --git a/src/Orchard.Web/Modules/Orchard.CustomForms/Migrations.cs b/src/Orchard.Web/Modules/Orchard.CustomForms/Migrations.cs index f3d75d9c1..dad45d608 100644 --- a/src/Orchard.Web/Modules/Orchard.CustomForms/Migrations.cs +++ b/src/Orchard.Web/Modules/Orchard.CustomForms/Migrations.cs @@ -37,7 +37,7 @@ namespace Orchard.CustomForms { cfg => cfg .WithPart("WidgetPart") .WithPart("CommonPart") - .WithPart("IdentityPart") + .WithIdentity() .WithPart("CustomFormPart") .WithSetting("Stereotype", "Widget") ); diff --git a/src/Orchard.Web/Modules/Orchard.Dashboards/Migrations.cs b/src/Orchard.Web/Modules/Orchard.Dashboards/Migrations.cs index 97bf38c37..7ce3a0711 100644 --- a/src/Orchard.Web/Modules/Orchard.Dashboards/Migrations.cs +++ b/src/Orchard.Web/Modules/Orchard.Dashboards/Migrations.cs @@ -7,7 +7,7 @@ namespace Orchard.Dashboards { public int Create() { ContentDefinitionManager.AlterTypeDefinition("Dashboard", type => type .WithPart("CommonPart") - .WithPart("IdentityPart") + .WithIdentity() .WithPart("TitlePart") .WithPart("LayoutPart", p => p .WithSetting("LayoutTypePartSettings.DefaultLayoutData", DefaultDashboardSelector.DefaultLayout))); diff --git a/src/Orchard.Web/Modules/Orchard.DynamicForms/Migrations.cs b/src/Orchard.Web/Modules/Orchard.DynamicForms/Migrations.cs index cc20cd75a..03a434b58 100644 --- a/src/Orchard.Web/Modules/Orchard.DynamicForms/Migrations.cs +++ b/src/Orchard.Web/Modules/Orchard.DynamicForms/Migrations.cs @@ -108,7 +108,7 @@ namespace Orchard.DynamicForms { public int UpdateFrom2() { ContentDefinitionManager.AlterTypeDefinition("FormWidget", type => type - .WithPart("IdentityPart")); + .WithIdentity()); return 3; } diff --git a/src/Orchard.Web/Modules/Orchard.Layouts/Migrations.cs b/src/Orchard.Web/Modules/Orchard.Layouts/Migrations.cs index 746120763..0261358fc 100644 --- a/src/Orchard.Web/Modules/Orchard.Layouts/Migrations.cs +++ b/src/Orchard.Web/Modules/Orchard.Layouts/Migrations.cs @@ -29,7 +29,7 @@ namespace Orchard.Layouts { .WithSetting("OwnerEditorSettings.ShowOwnerEditor", "false") .WithSetting("DateEditorSettings.ShowDateEditor", "false")) .WithPart("TitlePart") - .WithPart("IdentityPart") + .WithIdentity() .WithPart("LayoutPart", p => p .WithSetting("LayoutTypePartSettings.IsTemplate", "True")) .DisplayedAs("Layout") @@ -39,7 +39,7 @@ namespace Orchard.Layouts { .WithPart("CommonPart", p => p .WithSetting("OwnerEditorSettings.ShowOwnerEditor", "false") .WithSetting("DateEditorSettings.ShowDateEditor", "false")) - .WithPart("IdentityPart") + .WithIdentity() .WithPart("WidgetPart") .WithPart("LayoutPart") .WithSetting("Stereotype", "Widget") @@ -72,7 +72,7 @@ namespace Orchard.Layouts { public int UpdateFrom2() { ContentDefinitionManager.AlterTypeDefinition("Layout", type => type - .WithPart("IdentityPart")); + .WithIdentity()); return 3; } @@ -83,7 +83,7 @@ namespace Orchard.Layouts { .WithSetting("OwnerEditorSettings.ShowOwnerEditor", "false") .WithSetting("DateEditorSettings.ShowDateEditor", "false")) .WithPart("WidgetPart") - .WithPart("IdentityPart") + .WithIdentity() .WithPart("ElementWrapperPart", p => p .WithSetting("ElementWrapperPartSettings.ElementTypeName", elementTypeName)) .WithSetting("Stereotype", "Widget") diff --git a/src/Orchard.Web/Modules/Orchard.MediaLibrary/Migrations.cs b/src/Orchard.Web/Modules/Orchard.MediaLibrary/Migrations.cs index 8a6be0d4c..6591d036c 100644 --- a/src/Orchard.Web/Modules/Orchard.MediaLibrary/Migrations.cs +++ b/src/Orchard.Web/Modules/Orchard.MediaLibrary/Migrations.cs @@ -59,41 +59,41 @@ namespace Orchard.MediaLibrary { .DisplayedAs("Image") .WithSetting("MediaFileNameEditorSettings.ShowFileNameEditor", "True") .AsImage() - .WithPart("IdentityPart") + .WithIdentity() ); ContentDefinitionManager.AlterTypeDefinition("VectorImage", td => td .DisplayedAs("Vector Image") .WithSetting("MediaFileNameEditorSettings.ShowFileNameEditor", "True") .AsVectorImage() - .WithPart("IdentityPart") + .WithIdentity() ); ContentDefinitionManager.AlterTypeDefinition("Video", td => td .DisplayedAs("Video") .WithSetting("MediaFileNameEditorSettings.ShowFileNameEditor", "True") .AsVideo() - .WithPart("IdentityPart") + .WithIdentity() ); ContentDefinitionManager.AlterTypeDefinition("Audio", td => td .DisplayedAs("Audio") .WithSetting("MediaFileNameEditorSettings.ShowFileNameEditor", "True") .AsAudio() - .WithPart("IdentityPart") + .WithIdentity() ); ContentDefinitionManager.AlterTypeDefinition("Document", td => td .DisplayedAs("Document") .WithSetting("MediaFileNameEditorSettings.ShowFileNameEditor", "True") .AsDocument() - .WithPart("IdentityPart") + .WithIdentity() ); ContentDefinitionManager.AlterTypeDefinition("OEmbed", td => td .DisplayedAs("External Media") .WithSetting("Stereotype", "Media") - .WithPart("IdentityPart") + .WithIdentity() .WithPart("CommonPart") .WithPart("MediaPart") .WithPart("OEmbedPart") @@ -105,23 +105,23 @@ namespace Orchard.MediaLibrary { public int UpdateFrom2() { ContentDefinitionManager.AlterTypeDefinition("Image", td => td - .WithPart("IdentityPart") + .WithIdentity() ); ContentDefinitionManager.AlterTypeDefinition("Video", td => td - .WithPart("IdentityPart") + .WithIdentity() ); ContentDefinitionManager.AlterTypeDefinition("Audio", td => td - .WithPart("IdentityPart") + .WithIdentity() ); ContentDefinitionManager.AlterTypeDefinition("Document", td => td - .WithPart("IdentityPart") + .WithIdentity() ); ContentDefinitionManager.AlterTypeDefinition("OEmbed", td => td - .WithPart("IdentityPart") + .WithIdentity() ); return 3; @@ -200,7 +200,7 @@ namespace Orchard.MediaLibrary { .DisplayedAs("Vector Image") .WithSetting("Stereotype", "Media") .WithSetting("MediaFileNameEditorSettings.ShowFileNameEditor", "True") - .WithPart("IdentityPart") + .WithIdentity() .WithPart("CommonPart") .WithPart("MediaPart") .WithPart("VectorImagePart") diff --git a/src/Orchard.Web/Modules/Orchard.MediaProcessing/Migrations.cs b/src/Orchard.Web/Modules/Orchard.MediaProcessing/Migrations.cs index 242c96023..0123d5a0e 100644 --- a/src/Orchard.Web/Modules/Orchard.MediaProcessing/Migrations.cs +++ b/src/Orchard.Web/Modules/Orchard.MediaProcessing/Migrations.cs @@ -14,7 +14,7 @@ namespace Orchard.MediaProcessing { cfg => cfg .WithPart("ImageProfilePart") .WithPart("CommonPart", p => p.WithSetting("OwnerEditorSettings.ShowOwnerEditor", "false")) - .WithPart("IdentityPart") + .WithIdentity() ); SchemaBuilder.CreateTable("FilterRecord", diff --git a/src/Orchard.Web/Modules/Orchard.Projections/Migrations.cs b/src/Orchard.Web/Modules/Orchard.Projections/Migrations.cs index 1f721e147..149e87667 100644 --- a/src/Orchard.Web/Modules/Orchard.Projections/Migrations.cs +++ b/src/Orchard.Web/Modules/Orchard.Projections/Migrations.cs @@ -64,7 +64,7 @@ namespace Orchard.Projections { cfg => cfg .WithPart("QueryPart") .WithPart("TitlePart") - .WithPart("IdentityPart") + .WithIdentity() ); SchemaBuilder.CreateTable("QueryPartRecord", @@ -179,7 +179,7 @@ namespace Orchard.Projections { cfg => cfg .WithPart("WidgetPart") .WithPart("CommonPart") - .WithPart("IdentityPart") + .WithIdentity() .WithPart("ProjectionPart") .WithSetting("Stereotype", "Widget") ); @@ -277,7 +277,7 @@ namespace Orchard.Projections { public int UpdateFrom3() { ContentDefinitionManager.AlterTypeDefinition("NavigationQueryMenuItem", cfg => cfg - .WithPart("IdentityPart") + .WithIdentity() ); return 4; diff --git a/src/Orchard.Web/Modules/Orchard.Search/Migrations.cs b/src/Orchard.Web/Modules/Orchard.Search/Migrations.cs index abd815677..a680469c0 100644 --- a/src/Orchard.Web/Modules/Orchard.Search/Migrations.cs +++ b/src/Orchard.Web/Modules/Orchard.Search/Migrations.cs @@ -27,7 +27,7 @@ namespace Orchard.Search { public int UpdateFrom2() { ContentDefinitionManager.AlterTypeDefinition("SearchForm", - cfg => cfg.WithPart("IdentityPart")); + cfg => cfg.WithIdentity()); return 3; } diff --git a/src/Orchard.Web/Modules/Orchard.Search/Orchard.Search.csproj b/src/Orchard.Web/Modules/Orchard.Search/Orchard.Search.csproj index 17359f424..8f4fd6e37 100644 --- a/src/Orchard.Web/Modules/Orchard.Search/Orchard.Search.csproj +++ b/src/Orchard.Web/Modules/Orchard.Search/Orchard.Search.csproj @@ -101,6 +101,10 @@ Orchard.Framework false + + {9916839c-39fc-4ceb-a5af-89ca7e87119f} + Orchard.Core + {73a7688a-5bd3-4f7e-adfa-ce36c5a10e3b} Orchard.MediaLibrary diff --git a/src/Orchard.Web/Modules/Orchard.Templates/Migrations/Migrations.cs b/src/Orchard.Web/Modules/Orchard.Templates/Migrations/Migrations.cs index 4b68c649d..87668afd1 100644 --- a/src/Orchard.Web/Modules/Orchard.Templates/Migrations/Migrations.cs +++ b/src/Orchard.Web/Modules/Orchard.Templates/Migrations/Migrations.cs @@ -12,7 +12,7 @@ namespace Orchard.Templates { ContentDefinitionManager.AlterTypeDefinition("Template", type => type .WithPart("CommonPart") - .WithPart("IdentityPart") + .WithIdentity() .WithPart("TitlePart") .WithPart("ShapePart") .Draftable()); diff --git a/src/Orchard.Web/Modules/Orchard.Widgets/Extensions/WidgetsMetaDataExtensions.cs b/src/Orchard.Web/Modules/Orchard.Widgets/Extensions/WidgetsMetaDataExtensions.cs index e043ec465..ffa6b4294 100644 --- a/src/Orchard.Web/Modules/Orchard.Widgets/Extensions/WidgetsMetaDataExtensions.cs +++ b/src/Orchard.Web/Modules/Orchard.Widgets/Extensions/WidgetsMetaDataExtensions.cs @@ -25,8 +25,8 @@ namespace Orchard.ContentManagement.MetaData { return builder .WithPart("CommonPart") .WithPart("WidgetPart") - .WithPart("IdentityPart") - .WithSetting("Stereotype", "Widget"); + .WithSetting("Stereotype", "Widget") + .WithIdentity(); } } } \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Widgets/Migrations.cs b/src/Orchard.Web/Modules/Orchard.Widgets/Migrations.cs index c1f2b91b0..fbfedb3ba 100644 --- a/src/Orchard.Web/Modules/Orchard.Widgets/Migrations.cs +++ b/src/Orchard.Web/Modules/Orchard.Widgets/Migrations.cs @@ -44,7 +44,7 @@ namespace Orchard.Widgets { } public int UpdateFrom1() { - ContentDefinitionManager.AlterTypeDefinition("HtmlWidget", cfg => cfg.WithPart("IdentityPart")); + ContentDefinitionManager.AlterTypeDefinition("HtmlWidget", cfg => cfg.WithIdentity()); return 2; }