diff --git a/src/Umbraco.Infrastructure/PropertyEditors/BlockEditorPropertyValueEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/BlockEditorPropertyValueEditor.cs index 798cdf1d7d..a43921156a 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/BlockEditorPropertyValueEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/BlockEditorPropertyValueEditor.cs @@ -35,7 +35,9 @@ public abstract class BlockEditorPropertyValueEditor : BlockVal IIOHelper ioHelper) : this(propertyEditors, dataValueReferenceFactories, dataTypeConfigurationCache, shortStringHelper, jsonSerializer, StaticServiceProvider.Instance.GetRequiredService(), - StaticServiceProvider.Instance.GetRequiredService()) + StaticServiceProvider.Instance.GetRequiredService(), + ioHelper, + attribute) { } @@ -46,8 +48,10 @@ public abstract class BlockEditorPropertyValueEditor : BlockVal IShortStringHelper shortStringHelper, IJsonSerializer jsonSerializer, BlockEditorVarianceHandler blockEditorVarianceHandler, - ILanguageService languageService) - : base(propertyEditors, dataTypeConfigurationCache, shortStringHelper, jsonSerializer, dataValueReferenceFactories, blockEditorVarianceHandler, languageService) => + ILanguageService languageService, + IIOHelper ioHelper, + DataEditorAttribute attribute) + : base(propertyEditors, dataTypeConfigurationCache, shortStringHelper, jsonSerializer, dataValueReferenceFactories, blockEditorVarianceHandler, languageService, ioHelper, attribute) => _jsonSerializer = jsonSerializer; /// diff --git a/src/Umbraco.Infrastructure/PropertyEditors/BlockGridPropertyEditorBase.cs b/src/Umbraco.Infrastructure/PropertyEditors/BlockGridPropertyEditorBase.cs index 4e410841a1..1975faabc2 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/BlockGridPropertyEditorBase.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/BlockGridPropertyEditorBase.cs @@ -5,6 +5,7 @@ using System.ComponentModel.DataAnnotations; using Microsoft.Extensions.Logging; using Umbraco.Cms.Core.Cache; using Umbraco.Cms.Core.Cache.PropertyEditors; +using Umbraco.Cms.Core.IO; using Umbraco.Cms.Core.Models; using Umbraco.Cms.Core.Models.Blocks; using Umbraco.Cms.Core.Models.Validation; @@ -37,11 +38,12 @@ public abstract class BlockGridPropertyEditorBase : DataEditor #region Value Editor protected override IDataValueEditor CreateValueEditor() => - DataValueEditorFactory.Create(); + DataValueEditorFactory.Create(Attribute!); internal class BlockGridEditorPropertyValueEditor : BlockEditorPropertyValueEditor { public BlockGridEditorPropertyValueEditor( + DataEditorAttribute attribute, PropertyEditorCollection propertyEditors, DataValueReferenceFactoryCollection dataValueReferenceFactories, IDataTypeConfigurationCache dataTypeConfigurationCache, @@ -52,8 +54,9 @@ public abstract class BlockGridPropertyEditorBase : DataEditor IBlockEditorElementTypeCache elementTypeCache, IPropertyValidationService propertyValidationService, BlockEditorVarianceHandler blockEditorVarianceHandler, - ILanguageService languageService) - : base(propertyEditors, dataValueReferenceFactories, dataTypeConfigurationCache, shortStringHelper, jsonSerializer, blockEditorVarianceHandler, languageService) + ILanguageService languageService, + IIOHelper ioHelper) + : base(propertyEditors, dataValueReferenceFactories, dataTypeConfigurationCache, shortStringHelper, jsonSerializer, blockEditorVarianceHandler, languageService, ioHelper, attribute) { BlockEditorValues = new BlockEditorValues(new BlockGridEditorDataConverter(jsonSerializer), elementTypeCache, logger); Validators.Add(new BlockEditorValidator(propertyValidationService, BlockEditorValues, elementTypeCache)); diff --git a/src/Umbraco.Infrastructure/PropertyEditors/BlockListPropertyEditorBase.cs b/src/Umbraco.Infrastructure/PropertyEditors/BlockListPropertyEditorBase.cs index 749937bd4d..93277438ce 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/BlockListPropertyEditorBase.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/BlockListPropertyEditorBase.cs @@ -3,6 +3,7 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Umbraco.Cms.Core.Cache; using Umbraco.Cms.Core.Cache.PropertyEditors; +using Umbraco.Cms.Core.IO; using Umbraco.Cms.Core.Models; using Umbraco.Cms.Core.Models.Blocks; using Umbraco.Cms.Core.Models.Validation; @@ -47,11 +48,12 @@ public abstract class BlockListPropertyEditorBase : DataEditor protected virtual BlockEditorDataConverter CreateBlockEditorDataConverter() => new BlockListEditorDataConverter(_jsonSerializer); protected override IDataValueEditor CreateValueEditor() => - DataValueEditorFactory.Create(CreateBlockEditorDataConverter()); + DataValueEditorFactory.Create(Attribute!, CreateBlockEditorDataConverter()); internal class BlockListEditorPropertyValueEditor : BlockEditorPropertyValueEditor { public BlockListEditorPropertyValueEditor( + DataEditorAttribute attribute, BlockEditorDataConverter blockEditorDataConverter, PropertyEditorCollection propertyEditors, DataValueReferenceFactoryCollection dataValueReferenceFactories, @@ -63,8 +65,10 @@ public abstract class BlockListPropertyEditorBase : DataEditor IJsonSerializer jsonSerializer, IPropertyValidationService propertyValidationService, BlockEditorVarianceHandler blockEditorVarianceHandler, - ILanguageService languageService) - : base(propertyEditors, dataValueReferenceFactories, dataTypeConfigurationCache, shortStringHelper, jsonSerializer, blockEditorVarianceHandler, languageService) + ILanguageService languageService, + IIOHelper ioHelper + ) + : base(propertyEditors, dataValueReferenceFactories, dataTypeConfigurationCache, shortStringHelper, jsonSerializer, blockEditorVarianceHandler, languageService, ioHelper, attribute) { BlockEditorValues = new BlockEditorValues(blockEditorDataConverter, elementTypeCache, logger); Validators.Add(new BlockEditorValidator(propertyValidationService, BlockEditorValues, elementTypeCache)); diff --git a/src/Umbraco.Infrastructure/PropertyEditors/BlockValuePropertyValueEditorBase.cs b/src/Umbraco.Infrastructure/PropertyEditors/BlockValuePropertyValueEditorBase.cs index 8a774a5cfd..1c2624ffc5 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/BlockValuePropertyValueEditorBase.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/BlockValuePropertyValueEditorBase.cs @@ -42,7 +42,10 @@ public abstract class BlockValuePropertyValueEditorBase : DataV jsonSerializer, dataValueReferenceFactoryCollection, StaticServiceProvider.Instance.GetRequiredService(), - StaticServiceProvider.Instance.GetRequiredService()) + StaticServiceProvider.Instance.GetRequiredService(), + ioHelper, + attribute + ) { } @@ -53,8 +56,10 @@ public abstract class BlockValuePropertyValueEditorBase : DataV IJsonSerializer jsonSerializer, DataValueReferenceFactoryCollection dataValueReferenceFactoryCollection, BlockEditorVarianceHandler blockEditorVarianceHandler, - ILanguageService languageService) - : base(shortStringHelper, jsonSerializer) + ILanguageService languageService, + IIOHelper ioHelper, + DataEditorAttribute attribute) + : base(shortStringHelper, jsonSerializer, ioHelper, attribute) { _propertyEditors = propertyEditors; _dataTypeConfigurationCache = dataTypeConfigurationCache; diff --git a/src/Umbraco.Infrastructure/PropertyEditors/RichTextPropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/RichTextPropertyEditor.cs index f1281747c2..25b028f1e1 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/RichTextPropertyEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/RichTextPropertyEditor.cs @@ -65,7 +65,7 @@ public class RichTextPropertyEditor : DataEditor /// /// protected override IDataValueEditor CreateValueEditor() => - DataValueEditorFactory.Create(); + DataValueEditorFactory.Create(Attribute!); protected override IConfigurationEditor CreateConfigurationEditor() => new RichTextConfigurationEditor(_ioHelper); @@ -87,6 +87,7 @@ public class RichTextPropertyEditor : DataEditor private readonly ILogger _logger; public RichTextPropertyValueEditor( + DataEditorAttribute attribute, PropertyEditorCollection propertyEditors, IDataTypeConfigurationCache dataTypeReadCache, ILogger logger, @@ -102,8 +103,9 @@ public class RichTextPropertyEditor : DataEditor DataValueReferenceFactoryCollection dataValueReferenceFactoryCollection, IRichTextRequiredValidator richTextRequiredValidator, BlockEditorVarianceHandler blockEditorVarianceHandler, - ILanguageService languageService) - : base(propertyEditors, dataTypeReadCache, shortStringHelper, jsonSerializer, dataValueReferenceFactoryCollection, blockEditorVarianceHandler, languageService) + ILanguageService languageService, + IIOHelper ioHelper) + : base(propertyEditors, dataTypeReadCache, shortStringHelper, jsonSerializer, dataValueReferenceFactoryCollection, blockEditorVarianceHandler, languageService, ioHelper, attribute) { _backOfficeSecurityAccessor = backOfficeSecurityAccessor; _imageSourceParser = imageSourceParser; diff --git a/tests/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/DataValueEditorReuseTests.cs b/tests/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/DataValueEditorReuseTests.cs index 4fe4c34b6e..39132ee7a8 100644 --- a/tests/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/DataValueEditorReuseTests.cs +++ b/tests/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/DataValueEditorReuseTests.cs @@ -39,8 +39,9 @@ public class DataValueEditorReuseTests var blockVarianceHandler = new BlockEditorVarianceHandler(Mock.Of()); _dataValueEditorFactoryMock .Setup(m => - m.Create(It.IsAny>())) + m.Create(It.IsAny(), It.IsAny>())) .Returns(() => new BlockListPropertyEditorBase.BlockListEditorPropertyValueEditor( + new DataEditorAttribute("a"), new BlockListEditorDataConverter(Mock.Of()), _propertyEditorCollection, _dataValueReferenceFactories, @@ -52,7 +53,9 @@ public class DataValueEditorReuseTests Mock.Of(), Mock.Of(), blockVarianceHandler, - Mock.Of())); + Mock.Of(), + Mock.Of() + )); } [Test] @@ -109,7 +112,7 @@ public class DataValueEditorReuseTests Assert.NotNull(dataValueEditor2); Assert.AreNotSame(dataValueEditor1, dataValueEditor2); _dataValueEditorFactoryMock.Verify( - m => m.Create(It.IsAny>()), + m => m.Create(It.IsAny(), It.IsAny>()), Times.Exactly(2)); } @@ -131,7 +134,7 @@ public class DataValueEditorReuseTests Assert.AreEqual("config", ((DataValueEditor)dataValueEditor2).ConfigurationObject); Assert.AreNotSame(dataValueEditor1, dataValueEditor2); _dataValueEditorFactoryMock.Verify( - m => m.Create(It.IsAny>()), + m => m.Create(It.IsAny(), It.IsAny>()), Times.Exactly(2)); } }