Virtual Happy Hour this month, Jun 28, we'll be getting a sneak preview at our soon to launch SaaS CMS!

Try our conversational search powered by Generative AI!

Is there anyway to hook into IContentRepository.Save() method?



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!

May 06, 2013 13:10

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>




Edited, May 06, 2013 13:20

Probably I didnt describe clearly, what I'd like to do is to hook into Published event while publishing a block.

May 06, 2013 13:24

Ok, I sorted it out, there're also some equivalent events for block in DataFactory like: SavingContent, PublishingContent ... 

Edited, May 06, 2013 13:36

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

May 06, 2013 14:03

Very nice Johan!

May 06, 2013 18:53

Thanks Johan for this tips. I was looking for this interface ages ago, but no luck. EPiServer SDK still need to be improved :)

May 07, 2013 12:18

Small correction. The interface name is IContentEvents :)

May 22, 2013 10:44
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.