IFeatureEventHandler in a Theme

Topics: Core, Writing modules, Writing themes
Developer
Mar 21, 2014 at 4:26 PM
I'm attempting to capture the enable event of a theme from within the theme.

This works for modules, and I've done it before.
I know the event for a feature get's passed through the IFeatureEventHandler gets passed through the interface.

But if I place an IFeatureEventHandler inside the theme, I cannot catch the event.

I have a feeling it's that IEventHandler's are not discovered from Themes.

Any ideas?

I have a repo that you can pull from to immediately show the problem.

https://orchard.codeplex.com/SourceControl/network/forks/StanleyGoldman/EventHandlersInThemes/changeset/4e1ec5599a0fec0388cdd3a5366fabdefbf8f34e
Developer
Mar 21, 2014 at 5:32 PM
I've done more testing, the events get registered.

And provided the themes are enabled the IFeatureEventHandler gets called from the theme.
The only difference between the IFeatureEventHandler for a Theme and for a Module is the IFeatureEventHandler for a Theme does not get called for that Theme being enabled.
Developer
Mar 21, 2014 at 5:38 PM
Developer
Mar 21, 2014 at 6:19 PM
In my source right there, I have two test projects and two test themes.
In both cases on depends on the other.
My base theme depends on TheThemeMachine

They all have IFeatureEventHandler's that log when they detect themselves being enabled.

The IFeatureEventHandler of Modules work as expected.
The IFeatureEventHandler of Themes don't.

When I cook the test recipe.
2014-03-21 13:10:40,249 [78] Module.Base.Handlers.ModuleBaseEventHandler - Default - ModuleBaseEventHandler Called: Module.Base
2014-03-21 13:10:40,250 [78] Module.Base.Handlers.ModuleBaseEventHandler - Default - ModuleBaseEventHandler Module.Base Enabled
2014-03-21 13:10:40,251 [78] Module.Child.Handlers.ModuleChildEventHandler - Default - ModuleChildEventHandler Called: Module.Base
2014-03-21 13:10:40,254 [78] Module.Base.Handlers.ModuleBaseEventHandler - Default - ModuleBaseEventHandler Called: Module.Child
2014-03-21 13:10:40,255 [78] Module.Child.Handlers.ModuleChildEventHandler - Default - ModuleChildEventHandler Called: Module.Child
2014-03-21 13:10:40,256 [78] Module.Child.Handlers.ModuleChildEventHandler - Default - ModuleChildEventHandler Module.Child Enabled
2014-03-21 13:10:40,260 [78] Module.Base.Handlers.ModuleBaseEventHandler - Default - ModuleBaseEventHandler Called: TheThemeMachine
2014-03-21 13:10:40,260 [78] Module.Child.Handlers.ModuleChildEventHandler - Default - ModuleChildEventHandler Called: TheThemeMachine
2014-03-21 13:10:40,264 [78] Module.Base.Handlers.ModuleBaseEventHandler - Default - ModuleBaseEventHandler Called: BaseTheme
2014-03-21 13:10:40,265 [78] Module.Child.Handlers.ModuleChildEventHandler - Default - ModuleChildEventHandler Called: BaseTheme
2014-03-21 13:10:40,268 [78] Module.Base.Handlers.ModuleBaseEventHandler - Default - ModuleBaseEventHandler Called: ChildTheme
2014-03-21 13:10:40,269 [78] Module.Child.Handlers.ModuleChildEventHandler - Default - ModuleChildEventHandler Called: ChildTheme
I can go into the admin, and switch the theme to TheThemeMachine.
Disable ChildTheme, which disables BaseTheme (huh?).
I then set ChildTheme as Active
2014-03-21 13:10:40,269 [78] Module.Child.Handlers.ModuleChildEventHandler - Default - ModuleChildEventHandler Called: ChildTheme
2014-03-21 13:18:11,801 [31] Module.Base.Handlers.ModuleBaseEventHandler - Default - ModuleBaseEventHandler Called: TheThemeMachine
2014-03-21 13:18:11,802 [31] Module.Child.Handlers.ModuleChildEventHandler - Default - ModuleChildEventHandler Called: TheThemeMachine
2014-03-21 13:18:11,803 [31] BaseTheme.Handlers.BaseThemeEventHandler - Default - BaseThemeEventHandler Called: TheThemeMachine
2014-03-21 13:18:11,804 [31] ChildTheme.Handlers.ChildThemeEventHandler - Default - ChildThemeEventHandler Called: TheThemeMachine
2014-03-21 13:18:11,806 [31] Module.Base.Handlers.ModuleBaseEventHandler - Default - ModuleBaseEventHandler Called: BaseTheme
2014-03-21 13:18:11,806 [31] Module.Child.Handlers.ModuleChildEventHandler - Default - ModuleChildEventHandler Called: BaseTheme
2014-03-21 13:18:11,807 [31] BaseTheme.Handlers.BaseThemeEventHandler - Default - BaseThemeEventHandler Called: BaseTheme
2014-03-21 13:18:11,807 [31] BaseTheme.Handlers.BaseThemeEventHandler - Default - BaseThemeEventHandler BaseTheme Enabled
2014-03-21 13:18:11,807 [31] ChildTheme.Handlers.ChildThemeEventHandler - Default - ChildThemeEventHandler Called: BaseTheme
2014-03-21 13:18:11,809 [31] Module.Base.Handlers.ModuleBaseEventHandler - Default - ModuleBaseEventHandler Called: ChildTheme
2014-03-21 13:18:11,810 [31] Module.Child.Handlers.ModuleChildEventHandler - Default - ModuleChildEventHandler Called: ChildTheme
2014-03-21 13:18:11,810 [31] BaseTheme.Handlers.BaseThemeEventHandler - Default - BaseThemeEventHandler Called: ChildTheme
2014-03-21 13:18:11,811 [31] ChildTheme.Handlers.ChildThemeEventHandler - Default - ChildThemeEventHandler Called: ChildTheme
2014-03-21 13:18:11,811 [31] ChildTheme.Handlers.ChildThemeEventHandler - Default - ChildThemeEventHandler ChildTheme Enabled
And I see that the BaseTheme and ChildTheme are now able to detect their activation.