Enabling/Enabled features order

Topics: Customizing Orchard, General, Troubleshooting, Writing modules
Sep 13, 2011 at 4:57 PM

I have a module (let's say Orchard.ModuleDepending) depending on another one (let's say Orchard.Module). I thought that when I would enable Orchard.ModuleDepending the events firing would respect the following order:

IFeatureEventHandler.Enabling for Orchard.ModuleDepending

IFeatureEventHandler.Enabling for Orchard.Module

IFeatureEventHandler.Enabled for Orchard.Module

IFeatureEventHandler.Enabled for Orchard.ModuleDepending

 

but actually it respects the following order (I debugged to double check):

 

IFeatureEventHandler.Enabling for Orchard.ModuleDepending

IFeatureEventHandler.Enabled for Orchard.ModuleDepending

IFeatureEventHandler.Enabling for Orchard.Module

IFeatureEventHandler.Enabled for Orchard.Module

 

Is it the expected order? Wouldn't it be better to respect the first order so in IFeatureEventHandler.Enabled for Orchard.ModuleDepending, we can be sure that we can correctly use dependencies (for example something has been created in the database during IFeatureEventHandler.Enabled for Orchard.Module and we can modify it in IFeatureEventHandler.Enabled for Orchard.ModuleDepending)?

Coordinator
Sep 13, 2011 at 10:22 PM

Ïs that causing a problem?

Sep 14, 2011 at 9:30 AM

Let's say it causes me a logical problem. It doesn't appear logical to me to do this way but that's only a point of view. My problem is more that in the depending module, once enabled, I want to create things which relieve on other things created in the first module. Let's take the example of groups of people: people are created (if they don't already exist) in the first module once this one is enabled. Several groups including those people are created (if they don't already exist) in the depending module once this one is enabled. With the current order of Enabled/Enabling events, it's not possible to do that.

Nevertheless, I guess I can try to use Migration.cs files to achieve what I want.

Sep 14, 2011 at 9:57 AM
Edited Sep 14, 2011 at 10:09 AM

Since Migrations implements IDependency, I managed to do what I wanted :). Not sure though if Create functions are called depending of modules names alphabetical order or dependencies order.

Nevertheless I could thing about scenarios where I would like to use Enabled/Enabling events in another call order that the current one.

Sep 14, 2011 at 10:27 AM

Looks like it follows dependencies order. That would be perfect. Could you confirm that?

Coordinator
Sep 14, 2011 at 10:34 PM

It is.