Skip to content

Commit 5331e5f

Browse files
committed
realigned variable names.
adding more logging for FromArtifact for blockeditor.
1 parent c998d46 commit 5331e5f

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

src/Umbraco.Deploy.Contrib.Connectors/ValueConnectors/BlockEditorValueConnector.cs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public string ToArtifact(object value, PropertyType propertyType, ICollection<Ar
104104

105105
if (innerPropertyType == null)
106106
{
107-
_logger.Warn<BlockEditorValueConnector>("No property type found with alias {PropertyTypeAlias} on content type {ContentTypeAlias}.", key, contentType.Alias);
107+
_logger.Warn<BlockEditorValueConnector>("No property type found with alias {PropertyType} on content type {ContentType}.", key, contentType.Alias);
108108
continue;
109109
}
110110

@@ -116,7 +116,7 @@ public string ToArtifact(object value, PropertyType propertyType, ICollection<Ar
116116
var innerValue = block.PropertyValues[key];
117117
object parsedValue = propertyValueConnector.ToArtifact(innerValue, innerPropertyType, dependencies);
118118

119-
_logger.Debug<BlockEditorValueConnector>("Mapped {Key} value '{PropertyValue}' to '{ParsedValue}' using {PropertyValueConnectorType} for {PropertyTypeAlias}.", key, block.PropertyValues[key], parsedValue, propertyValueConnector.GetType(), innerPropertyType.Alias);
119+
_logger.Debug<BlockEditorValueConnector>("Mapped {Key} value '{PropertyValue}' to '{ParsedValue}' using {PropertyValueConnectorType} for {PropertyType}.", key, block.PropertyValues[key], parsedValue, propertyValueConnector.GetType(), innerPropertyType.Alias);
120120

121121
parsedValue = parsedValue?.ToString();
122122

@@ -131,6 +131,7 @@ public string ToArtifact(object value, PropertyType propertyType, ICollection<Ar
131131

132132
public object FromArtifact(string value, PropertyType propertyType, object currentValue)
133133
{
134+
_logger.Info<BlockEditorValueConnector>("Converting {PropertyType} from artifact.", propertyType.Alias);
134135
if (string.IsNullOrWhiteSpace(value))
135136
{
136137
return value;
@@ -144,7 +145,7 @@ public object FromArtifact(string value, PropertyType propertyType, object curre
144145
if (blockEditorValue == null)
145146
return value;
146147

147-
var allBlocks = blockEditorValue.Content.Concat(blockEditorValue.Settings);
148+
var allBlocks = blockEditorValue.Content.Concat(blockEditorValue.Settings).ToList();
148149

149150
var allContentTypes = allBlocks.Select(x => x.ContentTypeKey)
150151
.Distinct()
@@ -171,20 +172,21 @@ public object FromArtifact(string value, PropertyType propertyType, object curre
171172

172173
if (innerPropertyType == null)
173174
{
174-
_logger.Warn<BlockEditorValueConnector>("No property type found with alias {Key} on content type {ContentTypeAlias}.", key, contentType.Alias);
175+
_logger.Warn<BlockEditorValueConnector>("No property type found with alias {Key} on content type {ContentType}.", key, contentType.Alias);
175176
continue;
176177
}
177178

178179
// fetch the right value connector from the collection of connectors, intended for use with this property type.
179180
// throws if not found - no need for a null check
180-
var propValueConnector = ValueConnectors.Get(innerPropertyType);
181+
var propertyValueConnector = ValueConnectors.Get(innerPropertyType);
181182

182-
var propertyValue = block.PropertyValues[key];
183+
var innerValue = block.PropertyValues[key];
183184

184-
if (propertyValue != null)
185+
if (innerValue != null)
185186
{
186187
// pass the artifact value and property type to the connector to get a real value from the artifact
187-
var convertedValue = propValueConnector.FromArtifact(propertyValue.ToString(), innerPropertyType, null);
188+
var convertedValue = propertyValueConnector.FromArtifact(innerValue.ToString(), innerPropertyType, null);
189+
188190
if (convertedValue == null)
189191
{
190192
block.PropertyValues[key] = null;
@@ -193,14 +195,18 @@ public object FromArtifact(string value, PropertyType propertyType, object curre
193195
{
194196
block.PropertyValues[key] = convertedValue;
195197
}
198+
_logger.Debug<BlockEditorValueConnector>("Mapped {Key} value '{PropertyValue}' to '{ConvertedValue}' using {PropertyValueConnectorType} for {PropertyType}.", key, innerValue, convertedValue, propertyValueConnector.GetType(), innerPropertyType.Alias);
196199
}
197200
else
198201
{
199-
block.PropertyValues[key] = propertyValue;
202+
block.PropertyValues[key] = innerValue;
203+
_logger.Debug<BlockEditorValueConnector>("{Key} value was null. Setting value as null without conversion.", key);
200204
}
201205
}
202206
}
203207

208+
_logger.Info<BlockEditorValueConnector>("Finished converting {PropertyType} from artifact.", propertyType.Alias);
209+
204210
return JObject.FromObject(blockEditorValue);
205211
}
206212

0 commit comments

Comments
 (0)