November Happy Hour will be moved to Thursday December 5th.

Consuming the IContentSecurityRepository ContentSecuritySaved event

Vote:
 

Hi,

The IContentSecurityRepository interface defines the ContentSecuritySaved event:

http://world.episerver.com/Documentation/Class-library/?documentId=cms/7.5/6a3b465b-0d98-387f-66b8-1b28132e1b7c

Where is this interface implemented and how can it be consumed?

Thanks

#86778
May 30, 2014 14:02
Vote:
 

You should be able to get hold of the interface implementation from IOC container (e.g. ServiceLocator.Current.GetInstance<IContentSecurityRepository>). It is singleton scoped. A typical usage would be to have an InitializableModule (with a DependecyModule attribute to EPiServer.Web.InitiailizationModule) where you would hook up your eventhandler. The event will be raised whenever access right is changed for a content item.

#86783
May 30, 2014 15:51
Vote:
 

Thanks Johan.  Works perfectly, example below:

[ModuleDependency(typeof(EPiServer.Web.InitializationModule))]
    [InitializableModule]
    public class SecurityEventInitializationModule : IInitializableModule
    {
        public void Initialize(InitializationEngine context)                
        {            
            var secRepos = EPiServer.ServiceLocation.ServiceLocator.Current.GetInstance<IContentSecurityRepository>();            
            secRepos.ContentSecuritySaved += secRepos_ContentSecuritySaved;
            
        }        

        public void Preload(string[] parameters) { }

        public void Uninitialize(InitializationEngine context)
        {
            var secRepos = EPiServer.ServiceLocation.ServiceLocator.Current.GetInstance<IContentSecurityRepository>();
            secRepos.ContentSecuritySaved -= secRepos_ContentSecuritySaved;
        }

        void secRepos_ContentSecuritySaved(object sender, ContentSecurityEventArg e)
        {
            //todo: implement
        }
    }




#86822
Jun 02, 2014 12:22
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.