I'm using Sitecore 9.1.1, and in the sitecore.config there are a series of user events (user:created, user:created:remote, user:deleted, user:deleted:remote, user:updated, user:updated:remote, etc). Each entry has a comment that suggests the type of input it takes...for example, for user:created
, it shows a comment of user:created(System.Web.Security.MembershipUser user)
. I created a method like the following:
namespace Foundation.Core.Events {
public class UserEvents {
private readonly ILogRepository _logRepository;
public UserEvents(ILogRepository logRepository) {
_logRepository = logRepository;
}
public void OnUserCreated(System.Web.Security.MembershipUser user) {
_logRepository.Info("OnUserCreated fired");
}
}
}
And did a patch as follows:
<sitecore>
<events>
<event name="user:created">
<handler type="Foundation.Core.Events.UserEvents, Foundation.Core" method="OnUserCreated" resolve="true" />
</event>
</events>
</sitecore>
When I built out the code, I got back the following error:
Could not instantiate event handler. Type: Foundation.Core.Events.UserEvents. Method: OnUserCreated (method: Sitecore.Events.Event.BuildConfigSubscribersFromConfiguration()).
I tried paring the method down to remove the dependency injection and constructor, in case that was causing an issue, but I get the same error regardless. Since there are no "live" events in here, there's no direct pattern to follow, but I went with the definition from Sitecore's config as a guidance.
Has anyone ever used these events, and if so how did you tie into the system?