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 @@ -6,42 +6,45 @@ namespace Umbraco.Extensions;
public static class ArtifactMigratorCollectionBuilderExtensions
{
/// <summary>
/// Adds the legacy artifact migrators to allow importing from Umbraco 7.
/// Adds/inserts the legacy artifact migrators to allow importing from Umbraco 7.
/// </summary>
/// <param name="artifactMigratorCollectionBuilder">The artifact migrator collection builder.</param>
/// <returns>
/// The artifact migrator collection builder.
/// </returns>
/// <remarks>
/// The legacy migrators are inserted at the beginning of the collection to ensure they run before any other migrators, including default Deploy migrators.
/// </remarks>
public static ArtifactMigratorCollectionBuilder AddLegacyMigrators(this ArtifactMigratorCollectionBuilder artifactMigratorCollectionBuilder)
=> artifactMigratorCollectionBuilder
=> artifactMigratorCollectionBuilder.Insert(
// Pre-values to configuration
.Append<PreValuesDataTypeArtifactJsonMigrator>()
typeof(PreValuesDataTypeArtifactJsonMigrator),
// Release/expire dates to schedule
.Append<DocumentArtifactJsonMigrator>()
typeof(DocumentArtifactJsonMigrator),
// Allowed at root and child content types to permissions
.Append<ContentTypeArtifactJsonMigrator>()
typeof(ContentTypeArtifactJsonMigrator),
// Data types
.Append<CheckBoxListDataTypeArtifactMigrator>()
.Append<ColorPickerAliasDataTypeArtifactMigrator>()
.Append<ContentPicker2DataTypeArtifactMigrator>()
.Append<ContentPickerAliasDataTypeArtifactMigrator>()
.Append<DateDataTypeArtifactMigrator>()
.Append<DropDownFlexibleDataTypeArtifactMigrator>() // Ensure this is appended before other dropdown migrators to avoid duplicate migration
.Append<DropDownDataTypeArtifactMigrator>()
.Append<DropdownlistMultiplePublishKeysDataTypeArtifactMigrator>()
.Append<DropdownlistPublishingKeysDataTypeArtifactMigrator>()
.Append<DropDownMultipleDataTypeArtifactMigrator>()
.Append<MediaPicker2DataTypeArtifactMigrator>()
.Append<MemberPicker2DataTypeArtifactMigrator>()
.Append<MultiNodeTreePicker2DataTypeArtifactMigrator>()
.Append<MultipleMediaPickerDataTypeArtifactMigrator>()
.Append<NoEditDataTypeArtifactMigrator>()
.Append<RadioButtonListDataTypeArtifactMigrator>()
.Append<RelatedLinks2DataTypeArtifactMigrator>()
.Append<RelatedLinksDataTypeArtifactMigrator>()
.Append<TextboxDataTypeArtifactMigrator>()
.Append<TextboxMultipleDataTypeArtifactMigrator>()
.Append<TinyMCEv3DataTypeArtifactMigrator>()
typeof(CheckBoxListDataTypeArtifactMigrator),
typeof(ColorPickerAliasDataTypeArtifactMigrator),
typeof(ContentPicker2DataTypeArtifactMigrator),
typeof(ContentPickerAliasDataTypeArtifactMigrator),
typeof(DateDataTypeArtifactMigrator),
typeof(DropDownFlexibleDataTypeArtifactMigrator), // Ensure this is appended before other dropdown migrators to avoid duplicate migration
typeof(DropDownDataTypeArtifactMigrator),
typeof(DropdownlistMultiplePublishKeysDataTypeArtifactMigrator),
typeof(DropdownlistPublishingKeysDataTypeArtifactMigrator),
typeof(DropDownMultipleDataTypeArtifactMigrator),
typeof(MediaPicker2DataTypeArtifactMigrator),
typeof(MemberPicker2DataTypeArtifactMigrator),
typeof(MultiNodeTreePicker2DataTypeArtifactMigrator),
typeof(MultipleMediaPickerDataTypeArtifactMigrator),
typeof(NoEditDataTypeArtifactMigrator),
typeof(RadioButtonListDataTypeArtifactMigrator),
typeof(RelatedLinks2DataTypeArtifactMigrator),
typeof(RelatedLinksDataTypeArtifactMigrator),
typeof(TextboxDataTypeArtifactMigrator),
typeof(TextboxMultipleDataTypeArtifactMigrator),
typeof(TinyMCEv3DataTypeArtifactMigrator),
// Add prefixes to pre-value property editor aliases, triggering property type migrators
.Append<PrevalueArtifactMigrator>();
typeof(PrevalueArtifactMigrator));
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@ namespace Umbraco.Extensions;
public static class ArtifactTypeResolverCollectionBuilderExtensions
{
/// <summary>
/// Adds the legacy artifact type resolver to allow importing from Umbraco 7.
/// Adds/inserts the legacy artifact type resolver to allow importing from Umbraco 7.
/// </summary>
/// <param name="artifactTypeResolverCollectionBuilder">The artifact type resolver collection builder.</param>
/// <returns>
/// The artifact type resolver collection builder.
/// </returns>
/// <remarks>
/// The legacy artifact type resolver is inserted at the beginning of the collection to ensure it runs before any other resolvers.
/// </remarks>
public static ArtifactTypeResolverCollectionBuilder AddLegacyTypeResolver(this ArtifactTypeResolverCollectionBuilder artifactTypeResolverCollectionBuilder)
=> artifactTypeResolverCollectionBuilder.Append<LegacyArtifactTypeResolver>();
=> artifactTypeResolverCollectionBuilder.Insert<LegacyArtifactTypeResolver>();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using Umbraco.Cms.Core.Composing;
using Umbraco.Deploy.Core.Migrators;

namespace Umbraco.Extensions;

internal static class OrderedCollectionBuilderExtensions
{
public static ArtifactMigratorCollectionBuilder Insert(this ArtifactMigratorCollectionBuilder builder, params IEnumerable<Type> types)
=> Insert(builder, 0, types);

public static ArtifactMigratorCollectionBuilder Insert(this ArtifactMigratorCollectionBuilder builder, int index, params IEnumerable<Type> types)
=> Insert<ArtifactMigratorCollectionBuilder, ArtifactMigratorCollection, IArtifactMigrator>(builder, index, types);

public static PropertyTypeMigratorCollectionBuilder Insert(this PropertyTypeMigratorCollectionBuilder builder, params IEnumerable<Type> types)
=> Insert(builder, 0, types);

public static PropertyTypeMigratorCollectionBuilder Insert(this PropertyTypeMigratorCollectionBuilder builder, int index, params IEnumerable<Type> types)
=> Insert<PropertyTypeMigratorCollectionBuilder, PropertyTypeMigratorCollection, IPropertyTypeMigrator>(builder, index, types);

private static TBuilder Insert<TBuilder, TCollection, TItem>(TBuilder builder, int index, params IEnumerable<Type> types)
where TBuilder : OrderedCollectionBuilderBase<TBuilder, TCollection, TItem>
where TCollection : class, IBuilderCollection<TItem>
{
foreach (var type in types)
{
builder.Insert(index, type);

// Insert next type after the current one
index++;
}

return builder;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,22 @@ namespace Umbraco.Extensions;
public static class PropertyTypeMigratorCollectionBuilderExtensions
{
/// <summary>
/// Adds the legacy property type migrators to allow importing from Umbraco 7.
/// Adds/inserts the legacy property type migrators to allow importing from Umbraco 7.
/// </summary>
/// <returns>
/// The property type migrator collection builder.
/// </returns>
/// <remarks>
/// The legacy migrators are inserted at the beginning of the collection to ensure they run before any other migrators, including default Deploy migrators.
/// </remarks>
public static PropertyTypeMigratorCollectionBuilder AddLegacyMigrators(this PropertyTypeMigratorCollectionBuilder propertyTypeMigratorCollectionBuilder)
=> propertyTypeMigratorCollectionBuilder
=> propertyTypeMigratorCollectionBuilder.Insert(
// Pre-values to a single value or JSON array
.Append<CheckBoxListPropertyTypeMigrator>()
.Append<DropDownPropertyTypeMigrator>()
.Append<DropDownListFlexiblePropertyTypeMigrator>()
.Append<DropdownlistMultiplePublishKeysPropertyTypeMigrator>()
.Append<DropdownlistPublishingKeysPropertyTypeMigrator>()
.Append<DropDownMultiplePropertyTypeMigrator>()
.Append<RadioButtonListPropertyTypeMigrator>();
typeof(CheckBoxListPropertyTypeMigrator),
typeof(DropDownPropertyTypeMigrator),
typeof(DropDownListFlexiblePropertyTypeMigrator),
typeof(DropdownlistMultiplePublishKeysPropertyTypeMigrator),
typeof(DropdownlistPublishingKeysPropertyTypeMigrator),
typeof(DropDownMultiplePropertyTypeMigrator),
typeof(RadioButtonListPropertyTypeMigrator));
}