Files
Umbraco-CMS/src/Umbraco.Core/PropertyEditors/LabelPropertyEditor.cs

71 lines
2.6 KiB
C#
Raw Normal View History

// Copyright (c) Umbraco.
// See LICENSE for more details.
using System;
using Microsoft.Extensions.DependencyInjection;
using Umbraco.Cms.Core.IO;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Serialization;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Strings;
using Umbraco.Cms.Web.Common.DependencyInjection;
2018-06-03 13:30:50 +02:00
namespace Umbraco.Cms.Core.PropertyEditors
2018-06-03 13:30:50 +02:00
{
/// <summary>
/// Represents a property editor for label properties.
/// </summary>
[DataEditor(
Cms.Core.Constants.PropertyEditors.Aliases.Label,
"Label",
"readonlyvalue",
Icon = "icon-readonly")]
2018-06-03 13:30:50 +02:00
public class LabelPropertyEditor : DataEditor
{
2019-12-04 14:03:39 +01:00
private readonly IIOHelper _ioHelper;
private readonly IEditorConfigurationParser _editorConfigurationParser;
// Scheduled for removal in v12
[Obsolete("Please use constructor that takes an IEditorConfigurationParser instead")]
public LabelPropertyEditor(IDataValueEditorFactory dataValueEditorFactory,
IIOHelper ioHelper)
: this(dataValueEditorFactory, ioHelper, StaticServiceProvider.Instance.GetRequiredService<IEditorConfigurationParser>())
{
}
2019-12-04 14:03:39 +01:00
2018-06-03 13:30:50 +02:00
/// <summary>
/// Initializes a new instance of the <see cref="LabelPropertyEditor"/> class.
/// </summary>
public LabelPropertyEditor(IDataValueEditorFactory dataValueEditorFactory,
IIOHelper ioHelper,
IEditorConfigurationParser editorConfigurationParser)
: base(dataValueEditorFactory)
2019-12-04 14:03:39 +01:00
{
_ioHelper = ioHelper;
_editorConfigurationParser = editorConfigurationParser;
2019-12-04 14:03:39 +01:00
}
2018-06-03 13:30:50 +02:00
/// <inheritdoc />
2022-02-28 14:37:15 +01:00
protected override IDataValueEditor CreateValueEditor() => DataValueEditorFactory.Create<LabelPropertyValueEditor>(Attribute!);
2018-06-03 13:30:50 +02:00
/// <inheritdoc />
protected override IConfigurationEditor CreateConfigurationEditor() => new LabelConfigurationEditor(_ioHelper, _editorConfigurationParser);
2018-06-03 13:30:50 +02:00
// provides the property value editor
internal class LabelPropertyValueEditor : DataValueEditor
{
public LabelPropertyValueEditor(
ILocalizedTextService localizedTextService,
IShortStringHelper shortStringHelper,
IJsonSerializer jsonSerializer,
IIOHelper ioHelper,
DataEditorAttribute attribute)
: base(localizedTextService, shortStringHelper, jsonSerializer, ioHelper, attribute)
2018-06-03 13:30:50 +02:00
{ }
/// <inheritdoc />
public override bool IsReadOnly => true;
}
}
}