[Module] Tiny MCE Activation/Desacticvation

Topics: Customizing Orchard
May 24, 2013 at 7:38 AM
Edited May 24, 2013 at 1:05 PM

I play with the module by activated and deactivated.
I notice the principal used file is Body-Html.Editor.cshtml.
So my question is how Orchard knows a module is available or not. I try to search "TinyMCE"

And I don't find any line relevant except about ViewsBackgroundCompilation.cs(77).
I search something corresponding to

"var builder = new ContainerBuilder();

In the database I don't find any table...

Finally the question is general, how the systeme determines a module is activated or not.
Do you have any documentation or link related to that.
Can you help.

May 24, 2013 at 11:57 PM
Let's start with the terminology: Modules themselves are class libraries, and aren't in any state: they are there in the Modules folder, or they aren't. However, a Module exposes one or more Features. These features are enabled or disabled. The way this works is by leveraging Autofac's type registration mechanism. Whenever Orchard fires up, it registers all classes that ultimately implement IDependency, BUT only for those classes who are part of enabled features. Whether a feature is enabled or not is stored in the Settings_ShellFeatureStateRecord table. To link a class with a feature, you use the OrchardDependencyAttribute. If you don't decorate classes with that attribute, they will be linked with the "implicit" feature of the module if you will (which has the exact same name as the module itself).
May 27, 2013 at 6:13 AM
"However, a Module exposes one or more Features"

In the table Settings_ShellFeatureStateRecord, so Lucene is a module isn't it and what is the feature?
Do you mean by Module <=> Category?
Not clear :(

Name InstallState EnableState ShellStateRecord
Orchard.Localization Up Up 1
Lucene Up Up 1

I opened the module Orchard.Forms, that means Autofac registers the class DefaultFormManager : IFormManager
and I find in OrchardStarter the line RegisterVolatileProvider<DefaultDependenciesFolder, IDependenciesFolder>(builder);
So is it this used line to registered DefaultFormManager by Autofac?
    public interface IFormManager : IDependency {
        dynamic Build(string formName, string prefix = "");
        dynamic Bind(dynamic formShape, IValueProvider state, string prefix = "");
        void Validate(ValidatingContext context);
Don't find OrchardDependencyAttribute I search ": Attribute", no relevant result.
May 27, 2013 at 11:28 AM
No. There is a module called Lucene and this module exposes a feature called Lucene.

The code snippet you pasted is the IFormManager interface. As you see, it derives from IDependency. Somewhere in Orchard, hidden under a big tree, there is code that finds all classes implementing an interface that ultimately derive from IDependency, and registers these classes with Autofac.

Sorry, I meant OrchardFeatureAttribute instead of OrchardDependencyAttribute (which is non-existent).
May 28, 2013 at 6:25 AM
It's clear and effectively Orchard.Designer.Tools have many features.

Last question :) about " there is code that finds all classes implementing an interface that ultimately derive from IDependency, and registers these classes with Autofac. "
Where is this code?
Is it in OrchardStarter as I propose?
May 28, 2013 at 9:27 AM
You got it.

This type registration code can be found in ShellContainerFactory.
May 28, 2013 at 12:24 PM
Nice thank you :)