diff --git a/src/Umbraco.Core/ContentVariationExtensions.cs b/src/Umbraco.Core/ContentVariationExtensions.cs
index 5b157307ab..0b6b3b5c12 100644
--- a/src/Umbraco.Core/ContentVariationExtensions.cs
+++ b/src/Umbraco.Core/ContentVariationExtensions.cs
@@ -195,5 +195,37 @@ namespace Umbraco.Core
return true;
}
+
+ ///
+ /// Sets or removes the content type variation depending on the specified value.
+ ///
+ /// The content type.
+ /// The variation to set or remove.
+ /// If set to true sets the variation; otherwise, removes the variation.
+ public static void SetVariesBy(this IContentTypeBase contentType, ContentVariation variation, bool value = true) => contentType.Variations = contentType.Variations.SetVariesBy(variation, value);
+
+ ///
+ /// Sets or removes the property type variation depending on the specified value.
+ ///
+ /// The property type.
+ /// The variation to set or remove.
+ /// If set to true sets the variation; otherwise, removes the variation.
+ public static void SetVariesBy(this PropertyType propertyType, ContentVariation variation, bool value = true) => propertyType.Variations = propertyType.Variations.SetVariesBy(variation, value);
+
+ ///
+ /// Sets or removes the variation depending on the specified value.
+ ///
+ /// The existing variations.
+ /// The variation to set or remove.
+ /// If set to true sets the variation; otherwise, removes the variation.
+ ///
+ /// The variations with the specified variation set or removed.
+ ///
+ public static ContentVariation SetVariesBy(this ContentVariation variations, ContentVariation variation, bool value = true)
+ {
+ return value
+ ? variations | variation // Set flag using bitwise logical OR
+ : variations & ~variation; // Remove flag using bitwise logical AND with bitwise complement (reversing the bit)
+ }
}
}
diff --git a/src/Umbraco.Web/Models/Mapping/ContentTypeMapDefinition.cs b/src/Umbraco.Web/Models/Mapping/ContentTypeMapDefinition.cs
index cdd534a14f..06155d6888 100644
--- a/src/Umbraco.Web/Models/Mapping/ContentTypeMapDefinition.cs
+++ b/src/Umbraco.Web/Models/Mapping/ContentTypeMapDefinition.cs
@@ -215,7 +215,7 @@ namespace Umbraco.Web.Models.Mapping
}
// Umbraco.Code.MapAll -CreateDate -DeleteDate -UpdateDate
- // Umbraco.Code.MapAll -SupportsPublishing -Key -PropertyEditorAlias -ValueStorageType
+ // Umbraco.Code.MapAll -SupportsPublishing -Key -PropertyEditorAlias -ValueStorageType -Variations
private static void Map(PropertyTypeBasic source, PropertyType target, MapperContext context)
{
target.Name = source.Label;
@@ -225,9 +225,7 @@ namespace Umbraco.Web.Models.Mapping
target.MandatoryMessage = source.Validation.MandatoryMessage;
target.ValidationRegExp = source.Validation.Pattern;
target.ValidationRegExpMessage = source.Validation.PatternMessage;
- target.Variations = source.AllowCultureVariant
- ? target.Variations | ContentVariation.Culture // Set flag using bitwise logical OR
- : target.Variations & ~ContentVariation.Culture; // Remove flag using bitwise logical AND with bitwise complement (reversing the bit)
+ target.SetVariesBy(ContentVariation.Culture, source.AllowCultureVariant);
if (source.Id > 0)
target.Id = source.Id;
@@ -369,7 +367,7 @@ namespace Umbraco.Web.Models.Mapping
target.Validation = source.Validation;
}
- // Umbraco.Code.MapAll -CreatorId -Level -SortOrder
+ // Umbraco.Code.MapAll -CreatorId -Level -SortOrder -Variations
// Umbraco.Code.MapAll -CreateDate -UpdateDate -DeleteDate
// Umbraco.Code.MapAll -ContentTypeComposition (done by AfterMapSaveToType)
private static void MapSaveToTypeBase(TSource source, IContentTypeComposition target, MapperContext context)
@@ -399,9 +397,7 @@ namespace Umbraco.Web.Models.Mapping
if (!(target is IMemberType))
{
- target.Variations = source.AllowCultureVariant
- ? target.Variations | ContentVariation.Culture // Set flag using bitwise logical OR
- : target.Variations & ~ContentVariation.Culture; // Remove flag using bitwise logical AND with bitwise complement (reversing the bit)
+ target.SetVariesBy(ContentVariation.Culture, source.AllowCultureVariant);
}
// handle property groups and property types