Renames the PropertyValueEditor converter methods to be inline with the new converter method names
This commit is contained in:
@@ -532,17 +532,17 @@ namespace Umbraco.Core.Models
|
||||
/// Sets tags for the property - will add tags to the tags table and set the property value to be the comma delimited value of the tags.
|
||||
/// </summary>
|
||||
/// <param name="content">The content item to assign the tags to</param>
|
||||
/// <param name="propertyAlias">The property alias to assign the tags to</param>
|
||||
/// <param name="propertyTypeAlias">The property alias to assign the tags to</param>
|
||||
/// <param name="tags">The tags to assign</param>
|
||||
/// <param name="replaceTags">True to replace the tags on the current property with the tags specified or false to merge them with the currently assigned ones</param>
|
||||
/// <param name="tagGroup">The group/category to assign the tags, the default value is "default"</param>
|
||||
/// <returns></returns>
|
||||
public static void SetTags(this IContent content, string propertyAlias, IEnumerable<string> tags, bool replaceTags, string tagGroup = "default")
|
||||
public static void SetTags(this IContent content, string propertyTypeAlias, IEnumerable<string> tags, bool replaceTags, string tagGroup = "default")
|
||||
{
|
||||
var property = content.Properties["propertyAlias"];
|
||||
var property = content.Properties[propertyTypeAlias];
|
||||
if (property == null)
|
||||
{
|
||||
throw new IndexOutOfRangeException("No property exists with name " + propertyAlias);
|
||||
throw new IndexOutOfRangeException("No property exists with name " + propertyTypeAlias);
|
||||
}
|
||||
|
||||
var trimmedTags = tags.Select(x => x.Trim()).ToArray();
|
||||
@@ -569,15 +569,15 @@ namespace Umbraco.Core.Models
|
||||
/// Remove any of the tags specified in the collection from the property if they are currently assigned.
|
||||
/// </summary>
|
||||
/// <param name="content"></param>
|
||||
/// <param name="propertyAlias"></param>
|
||||
/// <param name="propertyTypeAlias"></param>
|
||||
/// <param name="tags"></param>
|
||||
/// <param name="tagGroup">The group/category that the tags are currently assigned to, the default value is "default"</param>
|
||||
public static void RemoveTags(this IContent content, string propertyAlias, IEnumerable<string> tags, string tagGroup = "default")
|
||||
public static void RemoveTags(this IContent content, string propertyTypeAlias, IEnumerable<string> tags, string tagGroup = "default")
|
||||
{
|
||||
var property = content.Properties["propertyAlias"];
|
||||
var property = content.Properties[propertyTypeAlias];
|
||||
if (property == null)
|
||||
{
|
||||
throw new IndexOutOfRangeException("No property exists with name " + propertyAlias);
|
||||
throw new IndexOutOfRangeException("No property exists with name " + propertyTypeAlias);
|
||||
}
|
||||
|
||||
var trimmedTags = tags.Select(x => x.Trim()).ToArray();
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace Umbraco.Core.Models
|
||||
var propertyEditor = PropertyEditorResolver.Current.GetByAlias(property.PropertyType.PropertyEditorAlias);
|
||||
if (propertyEditor != null)
|
||||
{
|
||||
var cacheValue = propertyEditor.ValueEditor.FormatValueForCache(property);
|
||||
var cacheValue = propertyEditor.ValueEditor.ConvertDbToString(property);
|
||||
|
||||
switch (property.PropertyType.DataTypeDatabaseType)
|
||||
{
|
||||
|
||||
@@ -8,6 +8,14 @@ using Umbraco.Core.Models.Editors;
|
||||
|
||||
namespace Umbraco.Core.PropertyEditors
|
||||
{
|
||||
/// <summary>
|
||||
/// An interface that indicates that a property editor supports tags and will store it's published tags into the tag db table
|
||||
/// </summary>
|
||||
public interface ISupportTags
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents the value editor for the property editor during content editing
|
||||
/// </summary>
|
||||
@@ -169,7 +177,7 @@ namespace Umbraco.Core.PropertyEditors
|
||||
/// If overridden then the object returned must match the type supplied in the ValueType, otherwise persisting the
|
||||
/// value to the DB will fail when it tries to validate the value type.
|
||||
/// </remarks>
|
||||
public virtual object FormatDataForPersistence(ContentPropertyData editorValue, object currentValue)
|
||||
public virtual object ConvertEditorToDb(ContentPropertyData editorValue, object currentValue)
|
||||
{
|
||||
var result = TryConvertValueToCrlType(editorValue.Value);
|
||||
if (result.Success == false)
|
||||
@@ -182,7 +190,7 @@ namespace Umbraco.Core.PropertyEditors
|
||||
//TODO: Change the result to object so we can pass back JSON or json converted clr types if we want!
|
||||
|
||||
/// <summary>
|
||||
/// A method used to format the databse value to a value that can be used by the editor
|
||||
/// A method used to format the database value to a value that can be used by the editor
|
||||
/// </summary>
|
||||
/// <param name="dbValue"></param>
|
||||
/// <returns></returns>
|
||||
@@ -190,7 +198,7 @@ namespace Umbraco.Core.PropertyEditors
|
||||
/// The object returned will automatically be serialized into json notation. For most property editors
|
||||
/// the value returned is probably just a string but in some cases a json structure will be returned.
|
||||
/// </remarks>
|
||||
public virtual object FormatDataForEditor(object dbValue)
|
||||
public virtual object ConvertDbToEditor(object dbValue)
|
||||
{
|
||||
if (dbValue == null) return string.Empty;
|
||||
|
||||
@@ -235,7 +243,7 @@ namespace Umbraco.Core.PropertyEditors
|
||||
/// </summary>
|
||||
/// <param name="property"></param>
|
||||
/// <returns></returns>
|
||||
public virtual object FormatValueForCache(Property property)
|
||||
public virtual string ConvertDbToString(Property property)
|
||||
{
|
||||
if (property.Value == null)
|
||||
{
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace Umbraco.Tests.PropertyEditors
|
||||
var dataTypeService = dataTypeServiceMock.Object;
|
||||
var editor = new PublishValuesMultipleValueEditor(true, dataTypeService, new PropertyValueEditor());
|
||||
|
||||
var result = editor.FormatValueForCache(
|
||||
var result = editor.ConvertDbToString(
|
||||
new Property(1, Guid.NewGuid(),
|
||||
new PropertyType(new DataTypeDefinition(1, "Test.TestEditor")),
|
||||
"1234,4567,8910"));
|
||||
@@ -50,7 +50,7 @@ namespace Umbraco.Tests.PropertyEditors
|
||||
var dataTypeService = dataTypeServiceMock.Object;
|
||||
var editor = new PublishValuesMultipleValueEditor(false, dataTypeService, new PropertyValueEditor());
|
||||
|
||||
var result = editor.FormatValueForCache(
|
||||
var result = editor.ConvertDbToString(
|
||||
new Property(1, Guid.NewGuid(),
|
||||
new PropertyType(new DataTypeDefinition(1, "Test.TestEditor")),
|
||||
"1234,4567,8910"));
|
||||
@@ -74,7 +74,7 @@ namespace Umbraco.Tests.PropertyEditors
|
||||
var dataTypeService = dataTypeServiceMock.Object;
|
||||
var editor = new PublishValueValueEditor(dataTypeService, new PropertyValueEditor());
|
||||
|
||||
var result = editor.FormatValueForCache(
|
||||
var result = editor.ConvertDbToString(
|
||||
new Property(1, Guid.NewGuid(),
|
||||
new PropertyType(new DataTypeDefinition(1, "Test.TestEditor")),
|
||||
"1234"));
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace Umbraco.Tests.PropertyEditors
|
||||
ValueType = "STRING"
|
||||
};
|
||||
|
||||
var result = valueEditor.FormatDataForEditor(value);
|
||||
var result = valueEditor.ConvertDbToEditor(value);
|
||||
Assert.AreEqual(isOk, !(result is string));
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace Umbraco.Tests.PropertyEditors
|
||||
ValueType = valueType
|
||||
};
|
||||
|
||||
var result = valueEditor.FormatDataForEditor(val);
|
||||
var result = valueEditor.ConvertDbToEditor(val);
|
||||
Assert.AreEqual(expected, result);
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ namespace Umbraco.Tests.PropertyEditors
|
||||
ValueType = "DATE"
|
||||
};
|
||||
|
||||
var result = valueEditor.FormatDataForEditor(now);
|
||||
var result = valueEditor.ConvertDbToEditor(now);
|
||||
Assert.AreEqual(now.ToIsoString(), result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ namespace Umbraco.Web.Editors
|
||||
//don't persist any bound value if the editor is readonly
|
||||
if (valueEditor.IsReadOnly == false)
|
||||
{
|
||||
dboProperty.Value = p.PropertyEditor.ValueEditor.FormatDataForPersistence(data, dboProperty.Value);
|
||||
dboProperty.Value = p.PropertyEditor.ValueEditor.ConvertEditorToDb(data, dboProperty.Value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
var result = new T
|
||||
{
|
||||
Id = property.Id,
|
||||
Value = editor.ValueEditor.FormatDataForEditor(property.Value),
|
||||
Value = editor.ValueEditor.ConvertDbToEditor(property.Value),
|
||||
Alias = property.Alias
|
||||
};
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace Umbraco.Web.PropertyEditors
|
||||
Validators.Add(new DateTimeValidator());
|
||||
}
|
||||
|
||||
public override object FormatDataForEditor(object dbValue)
|
||||
public override object ConvertDbToEditor(object dbValue)
|
||||
{
|
||||
var date = dbValue.TryConvertTo<DateTime?>();
|
||||
if (date.Success == false || date.Result == null)
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace Umbraco.Web.PropertyEditors
|
||||
/// file path or use the existing file path.
|
||||
/// </param>
|
||||
/// <returns></returns>
|
||||
public override object FormatDataForPersistence(ContentPropertyData editorValue, object currentValue)
|
||||
public override object ConvertEditorToDb(ContentPropertyData editorValue, object currentValue)
|
||||
{
|
||||
if (currentValue == null)
|
||||
{
|
||||
|
||||
@@ -123,7 +123,7 @@ namespace Umbraco.Web.PropertyEditors
|
||||
/// <remarks>
|
||||
/// We will also check the pre-values here, if there are more items than what is allowed we'll just trim the end
|
||||
/// </remarks>
|
||||
public override object FormatDataForPersistence(ContentPropertyData editorValue, object currentValue)
|
||||
public override object ConvertEditorToDb(ContentPropertyData editorValue, object currentValue)
|
||||
{
|
||||
var asArray = editorValue.Value as JArray;
|
||||
if (asArray == null)
|
||||
@@ -165,7 +165,7 @@ namespace Umbraco.Web.PropertyEditors
|
||||
/// <remarks>
|
||||
/// The legacy property editor saved this data as new line delimited! strange but we have to maintain that.
|
||||
/// </remarks>
|
||||
public override object FormatDataForEditor(object dbValue)
|
||||
public override object ConvertDbToEditor(object dbValue)
|
||||
{
|
||||
return dbValue == null
|
||||
? new JObject[] {}
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace Umbraco.Web.PropertyEditors
|
||||
/// </summary>
|
||||
/// <param name="property"></param>
|
||||
/// <returns></returns>
|
||||
public override object FormatValueForCache(Property property)
|
||||
public override string ConvertDbToString(Property property)
|
||||
{
|
||||
var idAttempt = property.Value.TryConvertTo<int>();
|
||||
if (idAttempt.Success)
|
||||
@@ -55,7 +55,7 @@ namespace Umbraco.Web.PropertyEditors
|
||||
|
||||
|
||||
|
||||
return base.FormatValueForCache(property);
|
||||
return base.ConvertDbToString(property);
|
||||
}
|
||||
|
||||
protected IDictionary<string, PreValue> GetPreValues(Property property)
|
||||
|
||||
@@ -35,17 +35,17 @@ namespace Umbraco.Web.PropertyEditors
|
||||
/// </summary>
|
||||
/// <param name="property"></param>
|
||||
/// <returns></returns>
|
||||
public override object FormatValueForCache(Property property)
|
||||
public override string ConvertDbToString(Property property)
|
||||
{
|
||||
if (_publishIds)
|
||||
{
|
||||
return base.FormatValueForCache(property);
|
||||
return base.ConvertDbToString(property);
|
||||
}
|
||||
|
||||
var selectedIds = property.Value.ToString().Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries);
|
||||
if (selectedIds.Any() == false)
|
||||
{
|
||||
return base.FormatValueForCache(property);
|
||||
return base.ConvertDbToString(property);
|
||||
}
|
||||
|
||||
var preValues = GetPreValues(property);
|
||||
@@ -56,7 +56,7 @@ namespace Umbraco.Web.PropertyEditors
|
||||
preValues.Where(x => selectedIds.Contains(x.Value.Id.ToInvariantString())).Select(x => x.Value.Value));
|
||||
}
|
||||
|
||||
return base.FormatValueForCache(property);
|
||||
return base.ConvertDbToString(property);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -64,9 +64,9 @@ namespace Umbraco.Web.PropertyEditors
|
||||
/// </summary>
|
||||
/// <param name="dbValue"></param>
|
||||
/// <returns></returns>
|
||||
public override object FormatDataForEditor(object dbValue)
|
||||
public override object ConvertDbToEditor(object dbValue)
|
||||
{
|
||||
var delimited = base.FormatDataForEditor(dbValue).ToString();
|
||||
var delimited = base.ConvertDbToEditor(dbValue).ToString();
|
||||
return delimited.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ namespace Umbraco.Web.PropertyEditors
|
||||
/// <param name="editorValue"></param>
|
||||
/// <param name="currentValue"></param>
|
||||
/// <returns></returns>
|
||||
public override object FormatDataForPersistence(Core.Models.Editors.ContentPropertyData editorValue, object currentValue)
|
||||
public override object ConvertEditorToDb(Core.Models.Editors.ContentPropertyData editorValue, object currentValue)
|
||||
{
|
||||
var json = editorValue.Value as JArray;
|
||||
if (json == null)
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace Umbraco.Web.PropertyEditors
|
||||
/// </summary>
|
||||
/// <param name="dbValue"></param>
|
||||
/// <returns></returns>
|
||||
public override object FormatDataForEditor(object dbValue)
|
||||
public override object ConvertDbToEditor(object dbValue)
|
||||
{
|
||||
if (dbValue == null)
|
||||
return dbValue;
|
||||
@@ -53,7 +53,7 @@ namespace Umbraco.Web.PropertyEditors
|
||||
/// <param name="editorValue"></param>
|
||||
/// <param name="currentValue"></param>
|
||||
/// <returns></returns>
|
||||
public override object FormatDataForPersistence(Core.Models.Editors.ContentPropertyData editorValue, object currentValue)
|
||||
public override object ConvertEditorToDb(Core.Models.Editors.ContentPropertyData editorValue, object currentValue)
|
||||
{
|
||||
if (editorValue.Value == null)
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user