-
-
Save islaytitans/36e865e1bdd79d810d77 to your computer and use it in GitHub Desktop.
Hackathon - SitecoreFieldMapper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace DevToolKit.EntityMapping | |
{ | |
public class SitecoreFieldMapper : ISitecoreFieldMapper | |
{ | |
public FieldModel MapToEntity(Field field) | |
{ | |
Assert.IsNotNull(field, "field can not be null"); | |
var baseTemplate = TemplateManager.GetTemplate( | |
Sitecore.Configuration.Settings.DefaultBaseTemplate, | |
field.Database); | |
Assert.IsNotNull(baseTemplate, "template can not be null"); | |
var template = field.GetTemplateField().Template; | |
var entity = new FieldModel | |
{ | |
Id = field.ID.ToString(), | |
Name = field.Name, | |
Value = field.Value, | |
StandardValue = field.GetStandardValue(), | |
TemplateName = template.Name, | |
TemplateId = template.ID.ToString(), | |
StandardField = baseTemplate.ContainsField(field.ID), | |
SortOrder = field.Sortorder, | |
SectionSortOrder = field.SectionSortorder, | |
}; | |
return entity; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment