How about using some validator logic for this?
public class PageDataValidator : IValidate<PageData>
{
public IEnumerable<ValidationError> Validate(PageData instance)
{
// TODO: manipulate instace properties.
return new ValidationError[0];
}
}
I have used this approach to make sure the URLSegment property is always lower case. To validate other content types, simply change the type of class to validate in IValidate<T>
Probably I didnt describe clearly, what I'd like to do is to hook into Published event while publishing a block.
Ok, I sorted it out, there're also some equivalent events for block in DataFactory like: SavingContent, PublishingContent ...
If you do not want to access the events through direct access to DataFactory you can aslo find them defined on the interface IContentEvent which is registered in IOC container
Thanks Johan for this tips. I was looking for this interface ages ago, but no luck. EPiServer SDK still need to be improved :)
Hi,
As you know in DataFactory we have some public events like: CreatedPage, SavedPage, MovedPage ... then we can hook some custom implementation into those events. But those events are only for PageData since EPiServer uses IContentRepository instead of DataFactory to manipulate BlockData then I'm wondering is there anyway to do the same for BlockData?
Thank you very much!